summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Junaid <junaid@redhat.com>2012-05-21 15:47:28 +0530
committerVijay Bellur <vijay@gluster.com>2012-05-25 10:22:16 -0700
commit69392d4daa9df0612630813713ae02a99cc068e0 (patch)
treef02a7eb5731c385a0fbd712b30f17074f9ad33ef
parent65275d048bb031f93a690c69cb32bb751298c212 (diff)
swift: Passing account name in container_update.
This patch also contains fixes to bugs * 811501 * 812498 * 821310 Also, removed the default set of users in the proxy-server.conf file. Change-Id: Ief83905d10ff7bf7c43685ada4d7f05959cee9d1 BUG: 821310 Signed-off-by: Mohammed Junaid <junaid@redhat.com> Reviewed-on: http://review.gluster.com/3440 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--swift/1.4.8/gluster-swift-plugin.spec60
-rw-r--r--swift/1.4.8/gluster-swift.spec396
-rw-r--r--swift/1.4.8/plugins/DiskDir.py4
-rw-r--r--swift/1.4.8/plugins/DiskFile.py20
-rw-r--r--swift/1.4.8/plugins/Glusterfs.py1
-rw-r--r--swift/1.4.8/plugins/conf/proxy-server.conf4
-rw-r--r--swift/1.4.8/plugins/utils.py24
-rw-r--r--swift/1.4.8/swift.diff1572
8 files changed, 1282 insertions, 799 deletions
diff --git a/swift/1.4.8/gluster-swift-plugin.spec b/swift/1.4.8/gluster-swift-plugin.spec
new file mode 100644
index 00000000000..746f75c5f5d
--- /dev/null
+++ b/swift/1.4.8/gluster-swift-plugin.spec
@@ -0,0 +1,60 @@
+############################################################################################################
+# Command to build rpms.#
+# $ rpmbuild -ta %{name}-%{version}-%{release}.tar.gz #
+############################################################################################################
+# Setting up the environment. #
+# * Create a directory %{name}-%{version} under $HOME/rpmbuild/SOURCES #
+# * Copy the contents of plugins directory into $HOME/rpmbuild/SOURCES/%{name}-%{version} #
+# * tar zcvf %{name}-%{version}-%{release}.tar.gz $HOME/rpmbuild/SOURCES/%{name}-%{version} %{name}.spec #
+# For more information refer #
+# http://fedoraproject.org/wiki/How_to_create_an_RPM_package #
+############################################################################################################
+
+%define _confdir /etc/swift
+%define _swiftdir /usr/lib/python2.6/site-packages/swift
+%define _ufo_version 1.0
+%define _ufo_release 3
+
+Summary : GlusterFS Unified File and Object Storage.
+Name : gluster-swift-plugin
+Version : %{_ufo_version}
+Release : %{_ufo_release}
+Group : Application/File
+Vendor : Red Hat Inc.
+Source0 : %{name}-%{version}-%{release}.tar.gz
+Packager : gluster-users@gluster.org
+License : Apache
+BuildArch: noarch
+Requires : memcached
+Requires : openssl
+Requires : python
+Requires : gluster-swift
+
+%description
+Gluster Unified File and Object Storage unifies NAS and object storage
+technology. This provides a system for data storage that enables users to access
+the same data as an object and as a file, simplifying management and controlling
+storage costs.
+
+%prep
+%setup -q
+
+%install
+rm -rf %{buildroot}
+
+mkdir -p %{buildroot}/%{_swiftdir}/plugins
+mkdir -p %{buildroot}/%{_confdir}/
+
+cp constraints.py %{buildroot}/%{_swiftdir}/plugins
+cp DiskDir.py %{buildroot}/%{_swiftdir}/plugins
+cp DiskFile.py %{buildroot}/%{_swiftdir}/plugins
+cp Glusterfs.py %{buildroot}/%{_swiftdir}/plugins
+cp __init__.py %{buildroot}/%{_swiftdir}/plugins
+cp utils.py %{buildroot}/%{_swiftdir}/plugins
+
+cp -r conf/* %{buildroot}/%{_confdir}/
+
+%files
+%defattr(-,root,root)
+%{_swiftdir}/plugins
+%{_confdir}/
diff --git a/swift/1.4.8/gluster-swift.spec b/swift/1.4.8/gluster-swift.spec
new file mode 100644
index 00000000000..640b944e8cb
--- /dev/null
+++ b/swift/1.4.8/gluster-swift.spec
@@ -0,0 +1,396 @@
+%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+%endif
+
+Name: gluster-swift
+Version: 1.4.8
+Release: 3%{?dist}
+Summary: OpenStack Object Storage (swift)
+
+Group: Development/Languages
+License: ASL 2.0
+URL: http://launchpad.net/swift
+Source0: http://launchpad.net/swift/essex/%{version}/+download/swift-%{version}.tar.gz
+Source1: %{name}-functions
+Source2: %{name}-account.init
+Source4: %{name}-container.init
+Source5: %{name}-object.init
+Source6: %{name}-proxy.init
+Patch0: openstack-swift-newdeps.patch
+Patch1: openstack-swift-docmod.patch
+Patch2: openstack-swift-nonet.patch
+Patch3: gluster.patch
+
+BuildRoot: %{_tmppath}/swift-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch: noarch
+BuildRequires: dos2unix
+BuildRequires: python-devel
+BuildRequires: python-setuptools
+BuildRequires: python-netifaces
+BuildRequires: python-paste-deploy
+Requires: python-configobj
+Requires: python-eventlet >= 0.9.8
+Requires: python-greenlet >= 0.3.1
+Requires: python-paste-deploy
+Requires: python-simplejson
+Requires: python-webob1.0
+Requires: pyxattr
+Requires: python-setuptools
+Requires: python-netifaces
+Requires: python-netifaces
+
+Conflicts: openstack-swift
+
+Requires(post): chkconfig
+Requires(postun): initscripts
+Requires(preun): chkconfig
+Requires(pre): shadow-utils
+Obsoletes: openstack-swift-auth <= 1.4.0
+
+%description
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+Objects are written to multiple hardware devices in the data center, with the
+OpenStack software responsible for ensuring data replication and integrity
+across the cluster. Storage clusters can scale horizontally by adding new nodes,
+which are automatically configured. Should a node fail, OpenStack works to
+replicate its content from other active nodes. Because OpenStack uses software
+logic to ensure data replication and distribution across different devices,
+inexpensive commodity hard drives and servers can be used in lieu of more
+expensive equipment.
+
+%package account
+Summary: A swift account server
+Group: Applications/System
+
+Requires: %{name} = %{version}-%{release}
+
+%description account
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+
+This package contains the %{name} account server.
+
+%package container
+Summary: A swift container server
+Group: Applications/System
+
+Requires: %{name} = %{version}-%{release}
+
+%description container
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+
+This package contains the %{name} container server.
+
+%package object
+Summary: A swift object server
+Group: Applications/System
+
+Requires: %{name} = %{version}-%{release}
+Requires: rsync >= 3.0
+
+%description object
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+
+This package contains the %{name} object server.
+
+%package proxy
+Summary: A swift proxy server
+Group: Applications/System
+
+Requires: %{name} = %{version}-%{release}
+
+%description proxy
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+
+This package contains the %{name} proxy server.
+
+%package doc
+Summary: Documentation for %{name}
+Group: Documentation
+#%if 0%{?rhel} >= 6
+#BuildRequires: python-sphinx10 >= 1.0
+#%endif
+%if 0%{?fedora} >= 14
+BuildRequires: python-sphinx >= 1.0
+%endif
+# Required for generating docs
+BuildRequires: python-eventlet
+BuildRequires: python-simplejson
+BuildRequires: python-webob1.0
+BuildRequires: pyxattr
+
+%description doc
+OpenStack Object Storage (swift) aggregates commodity servers to work together
+in clusters for reliable, redundant, and large-scale storage of static objects.
+
+This package contains documentation files for %{name}.
+
+%prep
+%setup -q -n swift-%{version}
+%patch0 -p1 -b .newdeps
+%patch1 -p1 -b .docmod
+%patch2 -p1 -b .nonet
+%patch3 -p1 -b .gluster
+# Fix wrong-file-end-of-line-encoding warning
+dos2unix LICENSE
+
+%build
+%{__python} setup.py build
+# Fails unless we create the build directory
+mkdir -p doc/build
+# Build docs
+%if 0%{?fedora} >= 14
+%{__python} setup.py build_sphinx
+%endif
+#%if 0%{?rhel} >= 6
+#export PYTHONPATH="$( pwd ):$PYTHONPATH"
+#SPHINX_DEBUG=1 sphinx-1.0-build -b html doc/source doc/build/html
+#SPHINX_DEBUG=1 sphinx-1.0-build -b man doc/source doc/build/man
+#%endif
+# Fix hidden-file-or-dir warning
+#rm doc/build/html/.buildinfo
+
+%install
+rm -rf %{buildroot}
+%{__python} setup.py install -O1 --skip-build --root %{buildroot}
+# Init helper functions
+install -p -D -m 644 %{SOURCE1} %{buildroot}%{_datarootdir}/%{name}/functions
+# Init scripts
+install -p -D -m 755 %{SOURCE2} %{buildroot}%{_initrddir}/%{name}-account
+install -p -D -m 755 %{SOURCE4} %{buildroot}%{_initrddir}/%{name}-container
+install -p -D -m 755 %{SOURCE5} %{buildroot}%{_initrddir}/%{name}-object
+install -p -D -m 755 %{SOURCE6} %{buildroot}%{_initrddir}/%{name}-proxy
+# Remove tests
+rm -fr %{buildroot}/%{python_sitelib}/test
+# Misc other
+install -d -m 755 %{buildroot}%{_sysconfdir}/swift
+install -d -m 755 %{buildroot}%{_sysconfdir}/swift/account-server
+install -d -m 755 %{buildroot}%{_sysconfdir}/swift/container-server
+install -d -m 755 %{buildroot}%{_sysconfdir}/swift/object-server
+install -d -m 755 %{buildroot}%{_sysconfdir}/swift/proxy-server
+# Install pid directory
+install -d -m 755 %{buildroot}%{_localstatedir}/run/swift
+install -d -m 755 %{buildroot}%{_localstatedir}/run/swift/account-server
+install -d -m 755 %{buildroot}%{_localstatedir}/run/swift/container-server
+install -d -m 755 %{buildroot}%{_localstatedir}/run/swift/object-server
+install -d -m 755 %{buildroot}%{_localstatedir}/run/swift/proxy-server
+
+%clean
+rm -rf %{buildroot}
+
+%pre
+getent group swift >/dev/null || groupadd -r swift -g 160
+getent passwd swift >/dev/null || \
+useradd -r -g swift -u 160 -d %{_sharedstatedir}/swift -s /sbin/nologin \
+-c "OpenStack Swift Daemons" swift
+exit 0
+
+%post account
+/sbin/chkconfig --add %{name}-account
+
+%preun account
+if [ $1 = 0 ] ; then
+ /sbin/service %{name}-account stop >/dev/null 2>&1
+ /sbin/chkconfig --del %{name}-account
+fi
+
+%postun account
+if [ "$1" -ge "1" ] ; then
+ /sbin/service %{name}-account condrestart >/dev/null 2>&1 || :
+fi
+
+%post container
+/sbin/chkconfig --add %{name}-container
+
+%preun container
+if [ $1 = 0 ] ; then
+ /sbin/service %{name}-container stop >/dev/null 2>&1
+ /sbin/chkconfig --del %{name}-container
+fi
+
+%postun container
+if [ "$1" -ge "1" ] ; then
+ /sbin/service %{name}-container condrestart >/dev/null 2>&1 || :
+fi
+
+%post object
+/sbin/chkconfig --add %{name}-object
+
+%preun object
+if [ $1 = 0 ] ; then
+ /sbin/service %{name}-object stop >/dev/null 2>&1
+ /sbin/chkconfig --del %{name}-object
+fi
+
+%postun object
+if [ "$1" -ge "1" ] ; then
+ /sbin/service %{name}-object condrestart >/dev/null 2>&1 || :
+fi
+
+%post proxy
+/sbin/chkconfig --add %{name}-proxy
+
+%preun proxy
+if [ $1 = 0 ] ; then
+ /sbin/service %{name}-proxy stop >/dev/null 2>&1
+ /sbin/chkconfig --del %{name}-proxy
+fi
+
+%postun proxy
+if [ "$1" -ge "1" ] ; then
+ /sbin/service %{name}-proxy condrestart >/dev/null 2>&1 || :
+fi
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS LICENSE README
+%doc etc/dispersion.conf-sample etc/drive-audit.conf-sample etc/object-expirer.conf-sample
+%doc etc/swift.conf-sample
+%dir %{_datarootdir}/%{name}/functions
+%dir %attr(0755, swift, swift) %{_localstatedir}/run/swift
+%dir %{_sysconfdir}/swift
+%dir %{python_sitelib}/swift
+%{_bindir}/swift
+%{_bindir}/swift-account-audit
+%{_bindir}/swift-bench
+%{_bindir}/swift-drive-audit
+%{_bindir}/swift-get-nodes
+%{_bindir}/swift-init
+%{_bindir}/swift-ring-builder
+%{_bindir}/swift-dispersion-populate
+%{_bindir}/swift-dispersion-report
+%{_bindir}/swift-recon*
+%{_bindir}/swift-object-expirer
+%{_bindir}/swift-oldies
+%{_bindir}/swift-orphans
+%{_bindir}/swift-form-signature
+%{_bindir}/swift-temp-url
+%{python_sitelib}/swift/*.py*
+%{python_sitelib}/swift/common
+%{python_sitelib}/swift-%{version}-*.egg-info
+
+%files account
+%defattr(-,root,root,-)
+%doc etc/account-server.conf-sample
+%dir %{_initrddir}/%{name}-account
+%dir %attr(0755, swift, swift) %{_localstatedir}/run/swift/account-server
+%dir %{_sysconfdir}/swift/account-server
+%{_bindir}/swift-account-auditor
+%{_bindir}/swift-account-reaper
+%{_bindir}/swift-account-replicator
+%{_bindir}/swift-account-server
+%{python_sitelib}/swift/account
+
+
+%files container
+%defattr(-,root,root,-)
+%doc etc/container-server.conf-sample
+%dir %{_initrddir}/%{name}-container
+%dir %attr(0755, swift, swift) %{_localstatedir}/run/swift/container-server
+%dir %{_sysconfdir}/swift/container-server
+%{_bindir}/swift-container-auditor
+%{_bindir}/swift-container-server
+%{_bindir}/swift-container-replicator
+%{_bindir}/swift-container-updater
+%{_bindir}/swift-container-sync
+%{python_sitelib}/swift/container
+
+%files object
+%defattr(-,root,root,-)
+%doc etc/object-server.conf-sample etc/rsyncd.conf-sample
+%dir %{_initrddir}/%{name}-object
+%dir %attr(0755, swift, swift) %{_localstatedir}/run/swift/object-server
+%dir %{_sysconfdir}/swift/object-server
+%{_bindir}/swift-object-auditor
+%{_bindir}/swift-object-info
+%{_bindir}/swift-object-replicator
+%{_bindir}/swift-object-server
+%{_bindir}/swift-object-updater
+%{python_sitelib}/swift/obj
+
+%files proxy
+%defattr(-,root,root,-)
+%doc etc/proxy-server.conf-sample
+%dir %{_initrddir}/%{name}-proxy
+%dir %attr(0755, swift, swift) %{_localstatedir}/run/swift/proxy-server
+%dir %{_sysconfdir}/swift/proxy-server
+%{_bindir}/swift-proxy-server
+%{python_sitelib}/swift/proxy
+
+%files doc
+%defattr(-,root,root,-)
+%doc LICENSE
+#%doc doc/build/html
+
+%changelog
+* Thu Apr 26 2012 Anthony Towns <atowns@redhat.com> 1.4.8-2
+- Apply gluster patches
+- Rename to gluster-swift
+
+* Thu Mar 22 2012 Alan Pevec <apevec@redhat.com> 1.4.8-1
+- Update to 1.4.8
+
+* Fri Mar 09 2012 Alan Pevec <apevec@redhat.com> 1.4.7-1
+- Update to 1.4.7
+
+* Mon Feb 13 2012 Alan Pevec <apevec@redhat.com> 1.4.6-1
+- Update to 1.4.6
+
+* Thu Jan 12 2012 Alan Pevec <apevec@redhat.com> 1.4.4-2
+- add back /var/run/swift for el6
+
+* Wed Jan 04 2012 Alan Pevec <apevec@redhat.com> 1.4.4-1
+- Use updated parallel install versions of epel packages (pbrady)
+- Ensure the docs aren't built with the system glance module (pbrady)
+- Ensure we don't access the net when building docs (pbrady)
+- Update to 1.4.4
+
+* Wed Nov 23 2011 David Nalley <david@gnsa.us> -1.4.3-2
+* fixed some missing requires
+
+* Sat Nov 05 2011 David Nalley <david@gnsa.us> - 1.4.3-1
+- Update to 1.4.3
+- fix init script add, registration, deletion BZ 685155
+- fixing BR to facilitate epel6 building
+
+* Tue Aug 23 2011 David Nalley <david@gnsa.us> - 1.4.0-2
+- adding uid:gid for bz 732693
+
+* Wed Jun 22 2011 David Nalley <david@gnsa.us> - 1.4.1-1
+- Update to 1.4.0
+- change the name of swift binary from st to swift
+
+* Sat Jun 04 2011 David Nalley <david@gnsa.us> - 1.4.0-1
+- Update to 1.4.0
+
+* Fri May 20 2011 David Nalley <david@gnsa.us> - 1.3.0-1
+- Update to 1.3.0
+
+* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.0-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Sun Dec 05 2010 Silas Sewell <silas@sewell.ch> - 1.1.0-1
+- Update to 1.1.0
+
+* Sun Aug 08 2010 Silas Sewell <silas@sewell.ch> - 1.0.2-5
+- Update for new Python macro guidelines
+- Use dos2unix instead of sed
+- Make gecos field more descriptive
+
+* Wed Jul 28 2010 Silas Sewell <silas@sewell.ch> - 1.0.2-4
+- Rename to openstack-swift
+
+* Wed Jul 28 2010 Silas Sewell <silas@sewell.ch> - 1.0.2-3
+- Fix return value in swift-functions
+
+* Tue Jul 27 2010 Silas Sewell <silas@sewell.ch> - 1.0.2-2
+- Add swift user
+- Update init scripts
+
+* Sun Jul 18 2010 Silas Sewell <silas@sewell.ch> - 1.0.2-1
+- Initial build
diff --git a/swift/1.4.8/plugins/DiskDir.py b/swift/1.4.8/plugins/DiskDir.py
index 4b813167196..28671be3cd9 100644
--- a/swift/1.4.8/plugins/DiskDir.py
+++ b/swift/1.4.8/plugins/DiskDir.py
@@ -220,14 +220,14 @@ class DiskDir(DiskCommon):
self.metadata[X_BYTES_USED] = int(self.metadata[X_BYTES_USED]) - int(content_length)
self.put_metadata(self.metadata)
- def put_container(self, timestamp, object_count, bytes_used):
+ def put_container(self, container, put_timestamp, del_timestamp, object_count, bytes_used):
"""
For account server.
"""
self.metadata[X_OBJECTS_COUNT] = 0
self.metadata[X_BYTES_USED] = 0
self.metadata[X_CONTAINER_COUNT] = int(self.metadata[X_CONTAINER_COUNT]) + 1
- self.metadata[X_PUT_TIMESTAMP] = timestamp
+ self.metadata[X_PUT_TIMESTAMP] = 1
self.put_metadata(self.metadata)
def delete_container(self, object_count, bytes_used):
diff --git a/swift/1.4.8/plugins/DiskFile.py b/swift/1.4.8/plugins/DiskFile.py
index 815e1c3ab54..6f77eaaa57a 100644
--- a/swift/1.4.8/plugins/DiskFile.py
+++ b/swift/1.4.8/plugins/DiskFile.py
@@ -15,6 +15,8 @@
import os
from eventlet import tpool
+from tempfile import mkstemp
+from contextlib import contextmanager
from swift.common.utils import normalize_timestamp, renamer
from swift.plugins.utils import mkdirs, rmdirs, validate_object, \
check_valid_account, create_object_metadata, do_open, \
@@ -294,3 +296,21 @@ class Gluster_DiskFile(DiskFile):
if X_OBJECT_TYPE in self.metadata:
self.metadata.pop(X_OBJECT_TYPE)
+ @contextmanager
+ def mkstemp(self):
+ """Contextmanager to make a temporary file."""
+
+ if not os.path.exists(self.tmpdir):
+ mkdirs(self.tmpdir)
+ fd, tmppath = mkstemp(dir=self.tmpdir)
+ try:
+ yield fd, tmppath
+ finally:
+ try:
+ os.close(fd)
+ except OSError:
+ pass
+ try:
+ os.unlink(tmppath)
+ except OSError:
+ pass
diff --git a/swift/1.4.8/plugins/Glusterfs.py b/swift/1.4.8/plugins/Glusterfs.py
index d5e847a8239..eb8d535dbf9 100644
--- a/swift/1.4.8/plugins/Glusterfs.py
+++ b/swift/1.4.8/plugins/Glusterfs.py
@@ -67,7 +67,6 @@ class Glusterfs(object):
def get_export_list_remote(self):
export_list = []
cmnd = 'ssh %s gluster volume info' % self.mount_ip
- print 'Remote'
if os.system(cmnd + ' >> /dev/null'):
raise Exception('Getting volume info failed %s, make sure to have \
diff --git a/swift/1.4.8/plugins/conf/proxy-server.conf b/swift/1.4.8/plugins/conf/proxy-server.conf
index 7f23d85ccd9..1fcde8e0d3a 100644
--- a/swift/1.4.8/plugins/conf/proxy-server.conf
+++ b/swift/1.4.8/plugins/conf/proxy-server.conf
@@ -13,10 +13,6 @@ account_autocreate = true
[filter:tempauth]
use = egg:swift#tempauth
-user_admin_admin = admin .admin .reseller_admin
-user_test_tester = testing .admin
-user_test2_tester2 = testing2 .admin
-user_test_tester3 = testing3
[filter:healthcheck]
use = egg:swift#healthcheck
diff --git a/swift/1.4.8/plugins/utils.py b/swift/1.4.8/plugins/utils.py
index 57c6180fdd1..e28a6bd853c 100644
--- a/swift/1.4.8/plugins/utils.py
+++ b/swift/1.4.8/plugins/utils.py
@@ -323,33 +323,21 @@ def check_user_xattr(path):
def _check_valid_account(account, fs_object):
mount_path = getattr(fs_object, 'mount_path', MOUNT_PATH)
- if not check_account_exists(fs_object.get_export_from_account_id(account), \
- fs_object):
+ if os.path.ismount(os.path.join(mount_path, account)):
+ return True
+
+ if not check_account_exists(fs_object.get_export_from_account_id(account), fs_object):
logging.error('Account not present %s', account)
return False
- if not os.path.ismount(os.path.join(mount_path, account)):
- if not os.path.isdir(os.path.join(mount_path, account)):
- mkdirs(os.path.join(mount_path, account))
-
+ if not os.path.isdir(os.path.join(mount_path, account)):
+ mkdirs(os.path.join(mount_path, account))
fs_object.unmount(os.path.join(mount_path, account))
if fs_object:
if not fs_object.mount(account):
return False
- if not check_user_xattr(os.path.join(mount_path, account)):
- logging.error('Error: No support for user.xattr on backend %s' % account)
- return False
-
- chmod_cmd = ['chmod 777 %s' % (mount_path), \
- 'chmod 777 %s/%s' % (mount_path, account)]
-
- for cmd in chmod_cmd:
- if os.system(cmd):
- logging.error('Chmod failed: %s' % (cmd))
- return False
-
return True
def check_valid_account(account, fs_object):
diff --git a/swift/1.4.8/swift.diff b/swift/1.4.8/swift.diff
index 15201b8cd14..ef7f06fc250 100644
--- a/swift/1.4.8/swift.diff
+++ b/swift/1.4.8/swift.diff
@@ -1,774 +1,798 @@
-diff --git a/setup.py b/setup.py
-index d195d34..b5b5ca2 100644
---- a/setup.py
-+++ b/setup.py
-@@ -1,5 +1,6 @@
- #!/usr/bin/python
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -94,6 +95,7 @@ setup(
- 'tempurl=swift.common.middleware.tempurl:filter_factory',
- 'formpost=swift.common.middleware.formpost:filter_factory',
- 'name_check=swift.common.middleware.name_check:filter_factory',
-+ 'gluster=swift.common.middleware.gluster:filter_factory',
- ],
- },
- )
-diff --git a/swift/account/server.py b/swift/account/server.py
-index 800b3c0..99f5de3 100644
---- a/swift/account/server.py
-+++ b/swift/account/server.py
-@@ -1,4 +1,5 @@
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -31,7 +32,7 @@ import simplejson
- 
- from swift.common.db import AccountBroker
- from swift.common.utils import get_logger, get_param, hash_path, \
-- normalize_timestamp, split_path, storage_directory
-+ normalize_timestamp, split_path, storage_directory, plugin_enabled
- from swift.common.constraints import ACCOUNT_LISTING_LIMIT, \
- check_mount, check_float, check_utf8
- from swift.common.db_replicator import ReplicatorRpc
-@@ -39,6 +40,8 @@ from swift.common.db_replicator import ReplicatorRpc
- 
- DATADIR = 'accounts'
- 
-+if plugin_enabled():
-+ from swift.plugins.DiskDir import DiskAccount
- 
- class AccountController(object):
- """WSGI controller for the account server."""
-@@ -52,8 +55,12 @@ class AccountController(object):
- self.mount_check, logger=self.logger)
- self.auto_create_account_prefix = \
- conf.get('auto_create_account_prefix') or '.'
-+ self.fs_object = None
- 
- def _get_account_broker(self, drive, part, account):
-+ if self.fs_object:
-+ return DiskAccount(self.root, account, self.fs_object);
-+
- hsh = hash_path(account)
- db_dir = storage_directory(DATADIR, part, hsh)
- db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
-@@ -121,9 +128,15 @@ class AccountController(object):
- if broker.is_deleted():
- return HTTPConflict(request=req)
- metadata = {}
-- metadata.update((key, (value, timestamp))
-- for key, value in req.headers.iteritems()
-- if key.lower().startswith('x-account-meta-'))
-+ if not self.fs_object:
-+ metadata.update((key, (value, timestamp))
-+ for key, value in req.headers.iteritems()
-+ if key.lower().startswith('x-account-meta-'))
-+ else:
-+ metadata.update((key, value)
-+ for key, value in req.headers.iteritems()
-+ if key.lower().startswith('x-account-meta-'))
-+
- if metadata:
- broker.update_metadata(metadata)
- if created:
-@@ -153,6 +166,9 @@ class AccountController(object):
- broker.stale_reads_ok = True
- if broker.is_deleted():
- return HTTPNotFound(request=req)
-+ if self.fs_object:
-+ broker.list_containers_iter(None, None,None,
-+ None, None)
- info = broker.get_info()
- headers = {
- 'X-Account-Container-Count': info['container_count'],
-@@ -164,9 +180,16 @@ class AccountController(object):
- container_ts = broker.get_container_timestamp(container)
- if container_ts is not None:
- headers['X-Container-Timestamp'] = container_ts
-- headers.update((key, value)
-- for key, (value, timestamp) in broker.metadata.iteritems()
-- if value != '')
-+ if not self.fs_object:
-+ headers.update((key, value)
-+ for key, (value, timestamp) in broker.metadata.iteritems()
-+ if value != '')
-+ else:
-+ headers.update((key, value)
-+ for key, value in broker.metadata.iteritems()
-+ if value != '')
-+
-+
- return HTTPNoContent(request=req, headers=headers)
- 
- def GET(self, req):
-@@ -190,9 +213,15 @@ class AccountController(object):
- 'X-Account-Bytes-Used': info['bytes_used'],
- 'X-Timestamp': info['created_at'],
- 'X-PUT-Timestamp': info['put_timestamp']}
-- resp_headers.update((key, value)
-- for key, (value, timestamp) in broker.metadata.iteritems()
-- if value != '')
-+ if not self.fs_object:
-+ resp_headers.update((key, value)
-+ for key, (value, timestamp) in broker.metadata.iteritems()
-+ if value != '')
-+ else:
-+ resp_headers.update((key, value)
-+ for key, value in broker.metadata.iteritems()
-+ if value != '')
-+
- try:
- prefix = get_param(req, 'prefix')
- delimiter = get_param(req, 'delimiter')
-@@ -224,6 +253,7 @@ class AccountController(object):
- content_type='text/plain', request=req)
- account_list = broker.list_containers_iter(limit, marker, end_marker,
- prefix, delimiter)
-+
- if out_content_type == 'application/json':
- json_pattern = ['"name":%s', '"count":%s', '"bytes":%s']
- json_pattern = '{' + ','.join(json_pattern) + '}'
-@@ -298,15 +328,29 @@ class AccountController(object):
- return HTTPNotFound(request=req)
- timestamp = normalize_timestamp(req.headers['x-timestamp'])
- metadata = {}
-- metadata.update((key, (value, timestamp))
-- for key, value in req.headers.iteritems()
-- if key.lower().startswith('x-account-meta-'))
-+ if not self.fs_object:
-+ metadata.update((key, (value, timestamp))
-+ for key, value in req.headers.iteritems()
-+ if key.lower().startswith('x-account-meta-'))
-+ else:
-+ metadata.update((key, value)
-+ for key, value in req.headers.iteritems()
-+ if key.lower().startswith('x-account-meta-'))
- if metadata:
- broker.update_metadata(metadata)
- return HTTPNoContent(request=req)
- 
-+ def plugin(self, env):
-+ if env.get('Gluster_enabled', False):
-+ self.fs_object = env.get('fs_object')
-+ self.root = env.get('root')
-+ self.mount_check = False
-+ else:
-+ self.fs_object = None
-+
- def __call__(self, env, start_response):
- start_time = time.time()
-+ self.plugin(env)
- req = Request(env)
- self.logger.txn_id = req.headers.get('x-trans-id', None)
- if not check_utf8(req.path_info):
-diff --git a/swift/common/middleware/gluster.py b/swift/common/middleware/gluster.py
-new file mode 100644
-index 0000000..341285d
---- /dev/null
-+++ b/swift/common/middleware/gluster.py
-@@ -0,0 +1,55 @@
-+# Copyright (c) 2011 Red Hat, Inc.
-+#
-+# Licensed under the Apache License, Version 2.0 (the "License");
-+# you may not use this file except in compliance with the License.
-+# You may obtain a copy of the License at
-+#
-+# http://www.apache.org/licenses/LICENSE-2.0
-+#
-+# Unless required by applicable law or agreed to in writing, software
-+# distributed under the License is distributed on an "AS IS" BASIS,
-+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-+# implied.
-+# See the License for the specific language governing permissions and
-+# limitations under the License.
-+
-+from swift.common.utils import get_logger, plugin_enabled
-+from swift import plugins
-+from ConfigParser import ConfigParser
-+
-+class Gluster_plugin(object):
-+ """
-+ Update the environment with keys that reflect Gluster_plugin enabled
-+ """
-+
-+ def __init__(self, app, conf):
-+ self.app = app
-+ self.conf = conf
-+ self.fs_name = 'Glusterfs'
-+ self.logger = get_logger(conf, log_route='gluster')
-+
-+ def __call__(self, env, start_response):
-+ if not plugin_enabled():
-+ return self.app(env, start_response)
-+ env['Gluster_enabled'] =True
-+ fs_object = getattr(plugins, self.fs_name, False)
-+ if not fs_object:
-+ raise Exception('%s plugin not found', self.fs_name)
-+
-+ env['fs_object'] = fs_object()
-+ fs_conf = ConfigParser()
-+ if fs_conf.read('/etc/swift/fs.conf'):
-+ try:
-+ env['root'] = fs_conf.get ('DEFAULT', 'mount_path')
-+ except NoSectionError, NoOptionError:
-+ self.logger.exception(_('ERROR mount_path not present'))
-+ return self.app(env, start_response)
-+
-+def filter_factory(global_conf, **local_conf):
-+ """Returns a WSGI filter app for use with paste.deploy."""
-+ conf = global_conf.copy()
-+ conf.update(local_conf)
-+
-+ def gluster_filter(app):
-+ return Gluster_plugin(app, conf)
-+ return gluster_filter
-diff --git a/swift/common/utils.py b/swift/common/utils.py
-index 47edce8..afc356c 100644
---- a/swift/common/utils.py
-+++ b/swift/common/utils.py
-@@ -1,4 +1,5 @@
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -1138,3 +1139,12 @@ def streq_const_time(s1, s2):
- for (a, b) in zip(s1, s2):
- result |= ord(a) ^ ord(b)
- return result == 0
-+
-+def plugin_enabled():
-+ swift_conf = ConfigParser()
-+ swift_conf.read(os.path.join('/etc/swift', 'swift.conf'))
-+ try:
-+ return swift_conf.get('DEFAULT', 'Enable_plugin', 'no') in TRUE_VALUES
-+ except NoOptionError, NoSectionError:
-+ return False
-+
-diff --git a/swift/container/server.py b/swift/container/server.py
-index 8a18cfd..741c81a 100644
---- a/swift/container/server.py
-+++ b/swift/container/server.py
-@@ -1,4 +1,5 @@
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -31,7 +32,8 @@ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
- 
- from swift.common.db import ContainerBroker
- from swift.common.utils import get_logger, get_param, hash_path, \
-- normalize_timestamp, storage_directory, split_path, validate_sync_to
-+ normalize_timestamp, storage_directory, split_path, validate_sync_to, \
-+ plugin_enabled
- from swift.common.constraints import CONTAINER_LISTING_LIMIT, \
- check_mount, check_float, check_utf8
- from swift.common.bufferedhttp import http_connect
-@@ -40,6 +42,9 @@ from swift.common.db_replicator import ReplicatorRpc
- 
- DATADIR = 'containers'
- 
-+if plugin_enabled():
-+ from swift.plugins.DiskDir import DiskDir
-+
- 
- class ContainerController(object):
- """WSGI Controller for the container server."""
-@@ -62,6 +67,7 @@ class ContainerController(object):
- ContainerBroker, self.mount_check, logger=self.logger)
- self.auto_create_account_prefix = \
- conf.get('auto_create_account_prefix') or '.'
-+ self.fs_object = None
- 
- def _get_container_broker(self, drive, part, account, container):
- """
-@@ -73,6 +79,11 @@ class ContainerController(object):
- :param container: container name
- :returns: ContainerBroker object
- """
-+ if self.fs_object:
-+ return DiskDir(self.root, drive, part, account,
-+ container, self.logger,
-+ fs_object = self.fs_object)
-+
- hsh = hash_path(account, container)
- db_dir = storage_directory(DATADIR, part, hsh)
- db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
-@@ -211,10 +222,18 @@ class ContainerController(object):
- if broker.is_deleted():
- return HTTPConflict(request=req)
- metadata = {}
-- metadata.update((key, (value, timestamp))
-- for key, value in req.headers.iteritems()
-- if key.lower() in self.save_headers or
-- key.lower().startswith('x-container-meta-'))
-+ #Note: check the structure of req.headers
-+ if not self.fs_object:
-+ metadata.update((key, (value, timestamp))
-+ for key, value in req.headers.iteritems()
-+ if key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-'))
-+ else:
-+ metadata.update((key, value)
-+ for key, value in req.headers.iteritems()
-+ if key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-'))
-+
- if metadata:
- if 'X-Container-Sync-To' in metadata:
- if 'X-Container-Sync-To' not in broker.metadata or \
-@@ -222,6 +241,7 @@ class ContainerController(object):
- broker.metadata['X-Container-Sync-To'][0]:
- broker.set_x_container_sync_points(-1, -1)
- broker.update_metadata(metadata)
-+
- resp = self.account_update(req, account, container, broker)
- if resp:
- return resp
-@@ -252,10 +272,17 @@ class ContainerController(object):
- 'X-Timestamp': info['created_at'],
- 'X-PUT-Timestamp': info['put_timestamp'],
- }
-- headers.update((key, value)
-- for key, (value, timestamp) in broker.metadata.iteritems()
-- if value != '' and (key.lower() in self.save_headers or
-- key.lower().startswith('x-container-meta-')))
-+ if not self.fs_object:
-+ headers.update((key, value)
-+ for key, (value, timestamp) in broker.metadata.iteritems()
-+ if value != '' and (key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-')))
-+ else:
-+ headers.update((key, value)
-+ for key, value in broker.metadata.iteritems()
-+ if value != '' and (key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-')))
-+
- return HTTPNoContent(request=req, headers=headers)
- 
- def GET(self, req):
-@@ -268,6 +295,7 @@ class ContainerController(object):
- request=req)
- if self.mount_check and not check_mount(self.root, drive):
- return Response(status='507 %s is not mounted' % drive)
-+
- broker = self._get_container_broker(drive, part, account, container)
- broker.pending_timeout = 0.1
- broker.stale_reads_ok = True
-@@ -280,10 +308,17 @@ class ContainerController(object):
- 'X-Timestamp': info['created_at'],
- 'X-PUT-Timestamp': info['put_timestamp'],
- }
-- resp_headers.update((key, value)
-- for key, (value, timestamp) in broker.metadata.iteritems()
-- if value != '' and (key.lower() in self.save_headers or
-- key.lower().startswith('x-container-meta-')))
-+ if not self.fs_object:
-+ resp_headers.update((key, value)
-+ for key, (value, timestamp) in broker.metadata.iteritems()
-+ if value != '' and (key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-')))
-+ else:
-+ resp_headers.update((key, value)
-+ for key, value in broker.metadata.iteritems()
-+ if value != '' and (key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-')))
-+
- try:
- path = get_param(req, 'path')
- prefix = get_param(req, 'prefix')
-@@ -414,10 +449,17 @@ class ContainerController(object):
- return HTTPNotFound(request=req)
- timestamp = normalize_timestamp(req.headers['x-timestamp'])
- metadata = {}
-- metadata.update((key, (value, timestamp))
-- for key, value in req.headers.iteritems()
-- if key.lower() in self.save_headers or
-- key.lower().startswith('x-container-meta-'))
-+ if not self.fs_object:
-+ metadata.update((key, (value, timestamp))
-+ for key, value in req.headers.iteritems()
-+ if key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-'))
-+ else:
-+ metadata.update((key, value)
-+ for key, value in req.headers.iteritems()
-+ if key.lower() in self.save_headers or
-+ key.lower().startswith('x-container-meta-'))
-+
- if metadata:
- if 'X-Container-Sync-To' in metadata:
- if 'X-Container-Sync-To' not in broker.metadata or \
-@@ -427,8 +469,19 @@ class ContainerController(object):
- broker.update_metadata(metadata)
- return HTTPNoContent(request=req)
- 
-+ def plugin(self, env):
-+ if env.get('Gluster_enabled', False):
-+ self.fs_object = env.get('fs_object')
-+ if not self.fs_object:
-+ raise NoneTypeError
-+ self.root = env.get('root')
-+ self.mount_check = False
-+ else:
-+ self.fs_object = None
-+
- def __call__(self, env, start_response):
- start_time = time.time()
-+ self.plugin(env)
- req = Request(env)
- self.logger.txn_id = req.headers.get('x-trans-id', None)
- if not check_utf8(req.path_info):
-diff --git a/swift/obj/server.py b/swift/obj/server.py
-index 9cca16b..37730ff 100644
---- a/swift/obj/server.py
-+++ b/swift/obj/server.py
-@@ -1,4 +1,5 @@
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -26,6 +27,7 @@ from hashlib import md5
- from tempfile import mkstemp
- from urllib import unquote
- from contextlib import contextmanager
-+from ConfigParser import ConfigParser
- 
- from webob import Request, Response, UTC
- from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
-@@ -37,16 +39,23 @@ from eventlet import sleep, Timeout, tpool
- 
- from swift.common.utils import mkdirs, normalize_timestamp, \
- storage_directory, hash_path, renamer, fallocate, \
-- split_path, drop_buffer_cache, get_logger, write_pickle
-+ split_path, drop_buffer_cache, get_logger, write_pickle, \
-+ plugin_enabled
- from swift.common.bufferedhttp import http_connect
--from swift.common.constraints import check_object_creation, check_mount, \
-- check_float, check_utf8
-+if plugin_enabled():
-+ from swift.plugins.constraints import check_object_creation
-+ from swift.plugins.utils import X_TYPE, X_OBJECT_TYPE, FILE, DIR, MARKER_DIR, \
-+ OBJECT, DIR_TYPE, FILE_TYPE
-+else:
-+ from swift.common.constraints import check_object_creation
-+
-+from swift.common.constraints import check_mount, check_float, check_utf8
-+
- from swift.common.exceptions import ConnectionTimeout, DiskFileError, \
- DiskFileNotExist
- from swift.obj.replicator import tpooled_get_hashes, invalidate_hash, \
- quarantine_renamer
- 
--
- DATADIR = 'objects'
- ASYNCDIR = 'async_pending'
- PICKLE_PROTOCOL = 2
-@@ -339,6 +348,9 @@ class DiskFile(object):
- raise
- raise DiskFileNotExist('Data File does not exist.')
- 
-+if plugin_enabled():
-+ from swift.plugins.DiskFile import Gluster_DiskFile
-+
- 
- class ObjectController(object):
- """Implements the WSGI application for the Swift Object Server."""
-@@ -377,6 +389,17 @@ class ObjectController(object):
- 'expiring_objects'
- self.expiring_objects_container_divisor = \
- int(conf.get('expiring_objects_container_divisor') or 86400)
-+ self.fs_object = None
-+
-+ def get_DiskFile_obj(self, path, device, partition, account, container, obj,
-+ logger, keep_data_fp=False, disk_chunk_size=65536):
-+ if self.fs_object:
-+ return Gluster_DiskFile(path, device, partition, account, container,
-+ obj, logger, keep_data_fp,
-+ disk_chunk_size, fs_object = self.fs_object);
-+ else:
-+ return DiskFile(path, device, partition, account, container,
-+ obj, logger, keep_data_fp, disk_chunk_size)
- 
- def async_update(self, op, account, container, obj, host, partition,
- contdevice, headers_out, objdevice):
-@@ -493,7 +516,7 @@ class ObjectController(object):
- content_type='text/plain')
- if self.mount_check and not check_mount(self.devices, device):
- return Response(status='507 %s is not mounted' % device)
-- file = DiskFile(self.devices, device, partition, account, container,
-+ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
- obj, self.logger, disk_chunk_size=self.disk_chunk_size)
- 
- if 'X-Delete-At' in file.metadata and \
-@@ -548,7 +571,7 @@ class ObjectController(object):
- if new_delete_at and new_delete_at < time.time():
- return HTTPBadRequest(body='X-Delete-At in past', request=request,
- content_type='text/plain')
-- file = DiskFile(self.devices, device, partition, account, container,
-+ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
- obj, self.logger, disk_chunk_size=self.disk_chunk_size)
- orig_timestamp = file.metadata.get('X-Timestamp')
- upload_expiration = time.time() + self.max_upload_time
-@@ -580,12 +603,29 @@ class ObjectController(object):
- if 'etag' in request.headers and \
- request.headers['etag'].lower() != etag:
- return HTTPUnprocessableEntity(request=request)
-- metadata = {
-- 'X-Timestamp': request.headers['x-timestamp'],
-- 'Content-Type': request.headers['content-type'],
-- 'ETag': etag,
-- 'Content-Length': str(os.fstat(fd).st_size),
-- }
-+ content_type = request.headers['content-type']
-+ if self.fs_object and not content_type:
-+ content_type = FILE_TYPE
-+ if not self.fs_object:
-+ metadata = {
-+ 'X-Timestamp': request.headers['x-timestamp'],
-+ 'Content-Type': request.headers['content-type'],
-+ 'ETag': etag,
-+ 'Content-Length': str(os.fstat(fd).st_size),
-+ }
-+ else:
-+ metadata = {
-+ 'X-Timestamp': request.headers['x-timestamp'],
-+ 'Content-Type': request.headers['content-type'],
-+ 'ETag': etag,
-+ 'Content-Length': str(os.fstat(fd).st_size),
-+ X_TYPE: OBJECT,
-+ X_OBJECT_TYPE: FILE,
-+ }
-+
-+ if self.fs_object and \
-+ request.headers['content-type'].lower() == DIR_TYPE:
-+ metadata.update({X_OBJECT_TYPE: MARKER_DIR})
- metadata.update(val for val in request.headers.iteritems()
- if val[0].lower().startswith('x-object-meta-') and
- len(val[0]) > 14)
-@@ -626,9 +666,9 @@ class ObjectController(object):
- content_type='text/plain')
- if self.mount_check and not check_mount(self.devices, device):
- return Response(status='507 %s is not mounted' % device)
-- file = DiskFile(self.devices, device, partition, account, container,
-- obj, self.logger, keep_data_fp=True,
-- disk_chunk_size=self.disk_chunk_size)
-+ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
-+ obj, self.logger, keep_data_fp=True,
-+ disk_chunk_size=self.disk_chunk_size)
- if file.is_deleted() or ('X-Delete-At' in file.metadata and
- int(file.metadata['X-Delete-At']) <= time.time()):
- if request.headers.get('if-match') == '*':
-@@ -702,7 +742,7 @@ class ObjectController(object):
- return resp
- if self.mount_check and not check_mount(self.devices, device):
- return Response(status='507 %s is not mounted' % device)
-- file = DiskFile(self.devices, device, partition, account, container,
-+ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
- obj, self.logger, disk_chunk_size=self.disk_chunk_size)
- if file.is_deleted() or ('X-Delete-At' in file.metadata and
- int(file.metadata['X-Delete-At']) <= time.time()):
-@@ -744,7 +784,7 @@ class ObjectController(object):
- if self.mount_check and not check_mount(self.devices, device):
- return Response(status='507 %s is not mounted' % device)
- response_class = HTTPNoContent
-- file = DiskFile(self.devices, device, partition, account, container,
-+ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
- obj, self.logger, disk_chunk_size=self.disk_chunk_size)
- if 'x-if-delete-at' in request.headers and \
- int(request.headers['x-if-delete-at']) != \
-@@ -797,9 +837,18 @@ class ObjectController(object):
- raise hashes
- return Response(body=pickle.dumps(hashes))
- 
-+ def plugin(self, env):
-+ if env.get('Gluster_enabled', False):
-+ self.fs_object = env.get('fs_object')
-+ self.devices = env.get('root')
-+ self.mount_check = False
-+ else:
-+ self.fs_object = None
-+
- def __call__(self, env, start_response):
- """WSGI Application entry point for the Swift Object Server."""
- start_time = time.time()
-+ self.plugin(env)
- req = Request(env)
- self.logger.txn_id = req.headers.get('x-trans-id', None)
- if not check_utf8(req.path_info):
-diff --git a/swift/proxy/server.py b/swift/proxy/server.py
-index 17613b8..af1ef25 100644
---- a/swift/proxy/server.py
-+++ b/swift/proxy/server.py
-@@ -1,4 +1,5 @@
- # Copyright (c) 2010-2012 OpenStack, LLC.
-+# Copyright (c) 2011 Red Hat, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
-@@ -53,8 +54,20 @@ from webob import Request, Response
- 
- from swift.common.ring import Ring
- from swift.common.utils import cache_from_env, ContextPool, get_logger, \
-- get_remote_client, normalize_timestamp, split_path, TRUE_VALUES
-+ get_remote_client, normalize_timestamp, split_path, TRUE_VALUES, \
-+ plugin_enabled
- from swift.common.bufferedhttp import http_connect
-+
-+if plugin_enabled():
-+ from swift.plugins.constraints import check_object_creation, \
-+ MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
-+else:
-+ from swift.common.constraints import check_object_creation, \
-+ MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
-+
-+from swift.common.constraints import check_metadata, check_utf8, \
-+ CONTAINER_LISTING_LIMIT
-+
- from swift.common.constraints import check_metadata, check_object_creation, \
- check_utf8, CONTAINER_LISTING_LIMIT, MAX_ACCOUNT_NAME_LENGTH, \
- MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
-diff --git a/test/__init__.py b/test/__init__.py
-index ef2ce31..363a051 100644
---- a/test/__init__.py
-+++ b/test/__init__.py
-@@ -6,8 +6,16 @@ import sys
- import os
- from ConfigParser import MissingSectionHeaderError
- from StringIO import StringIO
--
- from swift.common.utils import readconf
-+from swift.common.utils import plugin_enabled
-+if plugin_enabled():
-+ from swift.plugins.constraints import MAX_OBJECT_NAME_LENGTH, \
-+ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
-+ MAX_FILE_SIZE
-+else:
-+ from swift.common.constraints import MAX_OBJECT_NAME_LENGTH, \
-+ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
-+ MAX_FILE_SIZE
- 
- setattr(__builtin__, '_', lambda x: x)
- 
-diff --git a/test/functional/tests.py b/test/functional/tests.py
-index b25b4fd..8d12f58 100644
---- a/test/functional/tests.py
-+++ b/test/functional/tests.py
-@@ -31,6 +31,16 @@ import urllib
- from test import get_config
- from swift import Account, AuthenticationFailed, Connection, Container, \
- File, ResponseError
-+from test import plugin_enabled
-+if plugin_enabled():
-+ from test import MAX_OBJECT_NAME_LENGTH, \
-+ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
-+ MAX_FILE_SIZE
-+else:
-+ from test import MAX_OBJECT_NAME_LENGTH, \
-+ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
-+ MAX_FILE_SIZE
-+
- 
- config = get_config()
- 
-@@ -361,7 +371,7 @@ class TestContainer(Base):
- set_up = False
- 
- def testContainerNameLimit(self):
-- limit = 256
-+ limit = MAX_CONTAINER_NAME_LENGTH
- 
- for l in (limit-100, limit-10, limit-1, limit,
- limit+1, limit+10, limit+100):
-@@ -949,7 +959,7 @@ class TestFile(Base):
- self.assert_status(404)
- 
- def testNameLimit(self):
-- limit = 1024
-+ limit = MAX_OBJECT_NAME_LENGTH
- 
- for l in (1, 10, limit/2, limit-1, limit, limit+1, limit*2):
- file = self.env.container.file('a'*l)
-@@ -1093,7 +1103,7 @@ class TestFile(Base):
- self.assert_(file.read(hdrs={'Range': r}) == data[0:1000])
- 
- def testFileSizeLimit(self):
-- limit = 5*2**30 + 2
-+ limit = MAX_FILE_SIZE
- tsecs = 3
- 
- for i in (limit-100, limit-10, limit-1, limit, limit+1, limit+10,
-diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py
-index 075700e..5b6f32d 100644
---- a/test/unit/obj/test_server.py
-+++ b/test/unit/obj/test_server.py
-@@ -1355,7 +1355,7 @@ class TestObjectController(unittest.TestCase):
- 
- def test_max_object_name_length(self):
- timestamp = normalize_timestamp(time())
-- req = Request.blank('/sda1/p/a/c/' + ('1' * 1024),
-+ req = Request.blank('/sda1/p/a/c/' + ('1' * MAX_OBJECT_NAME_LENGTH),
- environ={'REQUEST_METHOD': 'PUT'},
- headers={'X-Timestamp': timestamp,
- 'Content-Length': '4',
-diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
-index 364370e..c17fe59 100644
---- a/test/unit/proxy/test_server.py
-+++ b/test/unit/proxy/test_server.py
-@@ -21,7 +21,6 @@ import os
- import sys
- import unittest
- from nose import SkipTest
--from ConfigParser import ConfigParser
- from contextlib import contextmanager
- from cStringIO import StringIO
- from gzip import GzipFile
-@@ -44,8 +43,18 @@ from swift.account import server as account_server
- from swift.container import server as container_server
- from swift.obj import server as object_server
- from swift.common import ring
--from swift.common.constraints import MAX_META_NAME_LENGTH, \
-- MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, MAX_FILE_SIZE
-+from swift.common.utils import plugin_enabled
-+if plugin_enabled():
-+ from swift.plugins.constraints import MAX_META_NAME_LENGTH, \
-+ MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \
-+ MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, \
-+ MAX_OBJECT_NAME_LENGTH
-+else:
-+ from swift.plugins.constraints import MAX_META_NAME_LENGTH, \
-+ MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \
-+ MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, \
-+ MAX_OBJECT_NAME_LENGTH
-+
- from swift.common.utils import mkdirs, normalize_timestamp, NullLogger
- from swift.common.wsgi import monkey_patch_mimetools
- 
-@@ -3207,7 +3216,8 @@ class TestContainerController(unittest.TestCase):
- def test_PUT_max_container_name_length(self):
- with save_globals():
- controller = proxy_server.ContainerController(self.app, 'account',
-- '1' * 256)
-+ '1' *
-+ MAX_CONTAINER_NAME_LENGTH,)
- self.assert_status_map(controller.PUT,
- (200, 200, 200, 201, 201, 201), 201,
- missing_container=True)
-@@ -3813,7 +3823,8 @@ class TestAccountController(unittest.TestCase):
- def test_PUT_max_account_name_length(self):
- with save_globals():
- self.app.allow_account_management = True
-- controller = proxy_server.AccountController(self.app, '1' * 256)
-+ controller = proxy_server.AccountController(self.app, '1' *
-+ MAX_ACCOUNT_NAME_LENGTH)
- self.assert_status_map(controller.PUT, (201, 201, 201), 201)
- controller = proxy_server.AccountController(self.app, '2' * 257)
- self.assert_status_map(controller.PUT, (201, 201, 201), 400)
+diff --git a/setup.py b/setup.py
+index d195d34..b5b5ca2 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1,5 +1,6 @@
+ #!/usr/bin/python
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -94,6 +95,7 @@ setup(
+ 'tempurl=swift.common.middleware.tempurl:filter_factory',
+ 'formpost=swift.common.middleware.formpost:filter_factory',
+ 'name_check=swift.common.middleware.name_check:filter_factory',
++ 'gluster=swift.common.middleware.gluster:filter_factory',
+ ],
+ },
+ )
+diff --git a/swift/account/server.py b/swift/account/server.py
+index 800b3c0..99f5de3 100644
+--- a/swift/account/server.py
++++ b/swift/account/server.py
+@@ -1,4 +1,5 @@
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -31,7 +32,7 @@ import simplejson
+
+ from swift.common.db import AccountBroker
+ from swift.common.utils import get_logger, get_param, hash_path, \
+- normalize_timestamp, split_path, storage_directory
++ normalize_timestamp, split_path, storage_directory, plugin_enabled
+ from swift.common.constraints import ACCOUNT_LISTING_LIMIT, \
+ check_mount, check_float, check_utf8
+ from swift.common.db_replicator import ReplicatorRpc
+@@ -39,6 +40,8 @@ from swift.common.db_replicator import ReplicatorRpc
+
+ DATADIR = 'accounts'
+
++if plugin_enabled():
++ from swift.plugins.DiskDir import DiskAccount
+
+ class AccountController(object):
+ """WSGI controller for the account server."""
+@@ -52,8 +55,12 @@ class AccountController(object):
+ self.mount_check, logger=self.logger)
+ self.auto_create_account_prefix = \
+ conf.get('auto_create_account_prefix') or '.'
++ self.fs_object = None
+
+ def _get_account_broker(self, drive, part, account):
++ if self.fs_object:
++ return DiskAccount(self.root, account, self.fs_object);
++
+ hsh = hash_path(account)
+ db_dir = storage_directory(DATADIR, part, hsh)
+ db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
+@@ -121,9 +128,15 @@ class AccountController(object):
+ if broker.is_deleted():
+ return HTTPConflict(request=req)
+ metadata = {}
+- metadata.update((key, (value, timestamp))
+- for key, value in req.headers.iteritems()
+- if key.lower().startswith('x-account-meta-'))
++ if not self.fs_object:
++ metadata.update((key, (value, timestamp))
++ for key, value in req.headers.iteritems()
++ if key.lower().startswith('x-account-meta-'))
++ else:
++ metadata.update((key, value)
++ for key, value in req.headers.iteritems()
++ if key.lower().startswith('x-account-meta-'))
++
+ if metadata:
+ broker.update_metadata(metadata)
+ if created:
+@@ -153,6 +166,9 @@ class AccountController(object):
+ broker.stale_reads_ok = True
+ if broker.is_deleted():
+ return HTTPNotFound(request=req)
++ if self.fs_object:
++ broker.list_containers_iter(None, None,None,
++ None, None)
+ info = broker.get_info()
+ headers = {
+ 'X-Account-Container-Count': info['container_count'],
+@@ -164,9 +180,16 @@ class AccountController(object):
+ container_ts = broker.get_container_timestamp(container)
+ if container_ts is not None:
+ headers['X-Container-Timestamp'] = container_ts
+- headers.update((key, value)
+- for key, (value, timestamp) in broker.metadata.iteritems()
+- if value != '')
++ if not self.fs_object:
++ headers.update((key, value)
++ for key, (value, timestamp) in broker.metadata.iteritems()
++ if value != '')
++ else:
++ headers.update((key, value)
++ for key, value in broker.metadata.iteritems()
++ if value != '')
++
++
+ return HTTPNoContent(request=req, headers=headers)
+
+ def GET(self, req):
+@@ -190,9 +213,15 @@ class AccountController(object):
+ 'X-Account-Bytes-Used': info['bytes_used'],
+ 'X-Timestamp': info['created_at'],
+ 'X-PUT-Timestamp': info['put_timestamp']}
+- resp_headers.update((key, value)
+- for key, (value, timestamp) in broker.metadata.iteritems()
+- if value != '')
++ if not self.fs_object:
++ resp_headers.update((key, value)
++ for key, (value, timestamp) in broker.metadata.iteritems()
++ if value != '')
++ else:
++ resp_headers.update((key, value)
++ for key, value in broker.metadata.iteritems()
++ if value != '')
++
+ try:
+ prefix = get_param(req, 'prefix')
+ delimiter = get_param(req, 'delimiter')
+@@ -224,6 +253,7 @@ class AccountController(object):
+ content_type='text/plain', request=req)
+ account_list = broker.list_containers_iter(limit, marker, end_marker,
+ prefix, delimiter)
++
+ if out_content_type == 'application/json':
+ json_pattern = ['"name":%s', '"count":%s', '"bytes":%s']
+ json_pattern = '{' + ','.join(json_pattern) + '}'
+@@ -298,15 +328,29 @@ class AccountController(object):
+ return HTTPNotFound(request=req)
+ timestamp = normalize_timestamp(req.headers['x-timestamp'])
+ metadata = {}
+- metadata.update((key, (value, timestamp))
+- for key, value in req.headers.iteritems()
+- if key.lower().startswith('x-account-meta-'))
++ if not self.fs_object:
++ metadata.update((key, (value, timestamp))
++ for key, value in req.headers.iteritems()
++ if key.lower().startswith('x-account-meta-'))
++ else:
++ metadata.update((key, value)
++ for key, value in req.headers.iteritems()
++ if key.lower().startswith('x-account-meta-'))
+ if metadata:
+ broker.update_metadata(metadata)
+ return HTTPNoContent(request=req)
+
++ def plugin(self, env):
++ if env.get('Gluster_enabled', False):
++ self.fs_object = env.get('fs_object')
++ self.root = env.get('root')
++ self.mount_check = False
++ else:
++ self.fs_object = None
++
+ def __call__(self, env, start_response):
+ start_time = time.time()
++ self.plugin(env)
+ req = Request(env)
+ self.logger.txn_id = req.headers.get('x-trans-id', None)
+ if not check_utf8(req.path_info):
+diff --git a/swift/common/middleware/gluster.py b/swift/common/middleware/gluster.py
+new file mode 100644
+index 0000000..341285d
+--- /dev/null
++++ b/swift/common/middleware/gluster.py
+@@ -0,0 +1,55 @@
++# Copyright (c) 2011 Red Hat, Inc.
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++# http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
++# implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++
++from swift.common.utils import get_logger, plugin_enabled
++from swift import plugins
++from ConfigParser import ConfigParser
++
++class Gluster_plugin(object):
++ """
++ Update the environment with keys that reflect Gluster_plugin enabled
++ """
++
++ def __init__(self, app, conf):
++ self.app = app
++ self.conf = conf
++ self.fs_name = 'Glusterfs'
++ self.logger = get_logger(conf, log_route='gluster')
++
++ def __call__(self, env, start_response):
++ if not plugin_enabled():
++ return self.app(env, start_response)
++ env['Gluster_enabled'] =True
++ fs_object = getattr(plugins, self.fs_name, False)
++ if not fs_object:
++ raise Exception('%s plugin not found', self.fs_name)
++
++ env['fs_object'] = fs_object()
++ fs_conf = ConfigParser()
++ if fs_conf.read('/etc/swift/fs.conf'):
++ try:
++ env['root'] = fs_conf.get ('DEFAULT', 'mount_path')
++ except NoSectionError, NoOptionError:
++ self.logger.exception(_('ERROR mount_path not present'))
++ return self.app(env, start_response)
++
++def filter_factory(global_conf, **local_conf):
++ """Returns a WSGI filter app for use with paste.deploy."""
++ conf = global_conf.copy()
++ conf.update(local_conf)
++
++ def gluster_filter(app):
++ return Gluster_plugin(app, conf)
++ return gluster_filter
+diff --git a/swift/common/utils.py b/swift/common/utils.py
+index 47edce8..afc356c 100644
+--- a/swift/common/utils.py
++++ b/swift/common/utils.py
+@@ -1,4 +1,5 @@
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -1138,3 +1139,12 @@ def streq_const_time(s1, s2):
+ for (a, b) in zip(s1, s2):
+ result |= ord(a) ^ ord(b)
+ return result == 0
++
++def plugin_enabled():
++ swift_conf = ConfigParser()
++ swift_conf.read(os.path.join('/etc/swift', 'swift.conf'))
++ try:
++ return swift_conf.get('DEFAULT', 'Enable_plugin', 'no') in TRUE_VALUES
++ except NoOptionError, NoSectionError:
++ return False
++
+diff --git a/swift/container/server.py b/swift/container/server.py
+index 8a18cfd..356150f 100644
+--- a/swift/container/server.py
++++ b/swift/container/server.py
+@@ -1,4 +1,5 @@
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -31,7 +32,8 @@ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
+
+ from swift.common.db import ContainerBroker
+ from swift.common.utils import get_logger, get_param, hash_path, \
+- normalize_timestamp, storage_directory, split_path, validate_sync_to
++ normalize_timestamp, storage_directory, split_path, validate_sync_to, \
++ plugin_enabled
+ from swift.common.constraints import CONTAINER_LISTING_LIMIT, \
+ check_mount, check_float, check_utf8
+ from swift.common.bufferedhttp import http_connect
+@@ -40,6 +42,9 @@ from swift.common.db_replicator import ReplicatorRpc
+
+ DATADIR = 'containers'
+
++if plugin_enabled():
++ from swift.plugins.DiskDir import DiskDir
++
+
+ class ContainerController(object):
+ """WSGI Controller for the container server."""
+@@ -62,6 +67,7 @@ class ContainerController(object):
+ ContainerBroker, self.mount_check, logger=self.logger)
+ self.auto_create_account_prefix = \
+ conf.get('auto_create_account_prefix') or '.'
++ self.fs_object = None
+
+ def _get_container_broker(self, drive, part, account, container):
+ """
+@@ -73,6 +79,11 @@ class ContainerController(object):
+ :param container: container name
+ :returns: ContainerBroker object
+ """
++ if self.fs_object:
++ return DiskDir(self.root, drive, part, account,
++ container, self.logger,
++ fs_object = self.fs_object)
++
+ hsh = hash_path(account, container)
+ db_dir = storage_directory(DATADIR, part, hsh)
+ db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
+@@ -211,10 +222,18 @@ class ContainerController(object):
+ if broker.is_deleted():
+ return HTTPConflict(request=req)
+ metadata = {}
+- metadata.update((key, (value, timestamp))
+- for key, value in req.headers.iteritems()
+- if key.lower() in self.save_headers or
+- key.lower().startswith('x-container-meta-'))
++ #Note: check the structure of req.headers
++ if not self.fs_object:
++ metadata.update((key, (value, timestamp))
++ for key, value in req.headers.iteritems()
++ if key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-'))
++ else:
++ metadata.update((key, value)
++ for key, value in req.headers.iteritems()
++ if key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-'))
++
+ if metadata:
+ if 'X-Container-Sync-To' in metadata:
+ if 'X-Container-Sync-To' not in broker.metadata or \
+@@ -222,6 +241,7 @@ class ContainerController(object):
+ broker.metadata['X-Container-Sync-To'][0]:
+ broker.set_x_container_sync_points(-1, -1)
+ broker.update_metadata(metadata)
++
+ resp = self.account_update(req, account, container, broker)
+ if resp:
+ return resp
+@@ -245,6 +265,11 @@ class ContainerController(object):
+ broker.stale_reads_ok = True
+ if broker.is_deleted():
+ return HTTPNotFound(request=req)
++
++ if self.fs_object:
++ broker.list_objects_iter(None, None, None, None,
++ None, None)
++
+ info = broker.get_info()
+ headers = {
+ 'X-Container-Object-Count': info['object_count'],
+@@ -252,10 +277,17 @@ class ContainerController(object):
+ 'X-Timestamp': info['created_at'],
+ 'X-PUT-Timestamp': info['put_timestamp'],
+ }
+- headers.update((key, value)
+- for key, (value, timestamp) in broker.metadata.iteritems()
+- if value != '' and (key.lower() in self.save_headers or
+- key.lower().startswith('x-container-meta-')))
++ if not self.fs_object:
++ headers.update((key, value)
++ for key, (value, timestamp) in broker.metadata.iteritems()
++ if value != '' and (key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-')))
++ else:
++ headers.update((key, value)
++ for key, value in broker.metadata.iteritems()
++ if value != '' and (key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-')))
++
+ return HTTPNoContent(request=req, headers=headers)
+
+ def GET(self, req):
+@@ -268,6 +300,7 @@ class ContainerController(object):
+ request=req)
+ if self.mount_check and not check_mount(self.root, drive):
+ return Response(status='507 %s is not mounted' % drive)
++
+ broker = self._get_container_broker(drive, part, account, container)
+ broker.pending_timeout = 0.1
+ broker.stale_reads_ok = True
+@@ -280,10 +313,17 @@ class ContainerController(object):
+ 'X-Timestamp': info['created_at'],
+ 'X-PUT-Timestamp': info['put_timestamp'],
+ }
+- resp_headers.update((key, value)
+- for key, (value, timestamp) in broker.metadata.iteritems()
+- if value != '' and (key.lower() in self.save_headers or
+- key.lower().startswith('x-container-meta-')))
++ if not self.fs_object:
++ resp_headers.update((key, value)
++ for key, (value, timestamp) in broker.metadata.iteritems()
++ if value != '' and (key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-')))
++ else:
++ resp_headers.update((key, value)
++ for key, value in broker.metadata.iteritems()
++ if value != '' and (key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-')))
++
+ try:
+ path = get_param(req, 'path')
+ prefix = get_param(req, 'prefix')
+@@ -414,10 +454,17 @@ class ContainerController(object):
+ return HTTPNotFound(request=req)
+ timestamp = normalize_timestamp(req.headers['x-timestamp'])
+ metadata = {}
+- metadata.update((key, (value, timestamp))
+- for key, value in req.headers.iteritems()
+- if key.lower() in self.save_headers or
+- key.lower().startswith('x-container-meta-'))
++ if not self.fs_object:
++ metadata.update((key, (value, timestamp))
++ for key, value in req.headers.iteritems()
++ if key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-'))
++ else:
++ metadata.update((key, value)
++ for key, value in req.headers.iteritems()
++ if key.lower() in self.save_headers or
++ key.lower().startswith('x-container-meta-'))
++
+ if metadata:
+ if 'X-Container-Sync-To' in metadata:
+ if 'X-Container-Sync-To' not in broker.metadata or \
+@@ -427,8 +474,19 @@ class ContainerController(object):
+ broker.update_metadata(metadata)
+ return HTTPNoContent(request=req)
+
++ def plugin(self, env):
++ if env.get('Gluster_enabled', False):
++ self.fs_object = env.get('fs_object')
++ if not self.fs_object:
++ raise NoneTypeError
++ self.root = env.get('root')
++ self.mount_check = False
++ else:
++ self.fs_object = None
++
+ def __call__(self, env, start_response):
+ start_time = time.time()
++ self.plugin(env)
+ req = Request(env)
+ self.logger.txn_id = req.headers.get('x-trans-id', None)
+ if not check_utf8(req.path_info):
+diff --git a/swift/obj/server.py b/swift/obj/server.py
+index 9cca16b..a45daff 100644
+--- a/swift/obj/server.py
++++ b/swift/obj/server.py
+@@ -1,4 +1,5 @@
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -26,6 +27,7 @@ from hashlib import md5
+ from tempfile import mkstemp
+ from urllib import unquote
+ from contextlib import contextmanager
++from ConfigParser import ConfigParser
+
+ from webob import Request, Response, UTC
+ from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
+@@ -37,16 +39,23 @@ from eventlet import sleep, Timeout, tpool
+
+ from swift.common.utils import mkdirs, normalize_timestamp, \
+ storage_directory, hash_path, renamer, fallocate, \
+- split_path, drop_buffer_cache, get_logger, write_pickle
++ split_path, drop_buffer_cache, get_logger, write_pickle, \
++ plugin_enabled
+ from swift.common.bufferedhttp import http_connect
+-from swift.common.constraints import check_object_creation, check_mount, \
+- check_float, check_utf8
++if plugin_enabled():
++ from swift.plugins.constraints import check_object_creation
++ from swift.plugins.utils import X_TYPE, X_OBJECT_TYPE, FILE, DIR, MARKER_DIR, \
++ OBJECT, DIR_TYPE, FILE_TYPE
++else:
++ from swift.common.constraints import check_object_creation
++
++from swift.common.constraints import check_mount, check_float, check_utf8
++
+ from swift.common.exceptions import ConnectionTimeout, DiskFileError, \
+ DiskFileNotExist
+ from swift.obj.replicator import tpooled_get_hashes, invalidate_hash, \
+ quarantine_renamer
+
+-
+ DATADIR = 'objects'
+ ASYNCDIR = 'async_pending'
+ PICKLE_PROTOCOL = 2
+@@ -339,6 +348,9 @@ class DiskFile(object):
+ raise
+ raise DiskFileNotExist('Data File does not exist.')
+
++if plugin_enabled():
++ from swift.plugins.DiskFile import Gluster_DiskFile
++
+
+ class ObjectController(object):
+ """Implements the WSGI application for the Swift Object Server."""
+@@ -377,6 +389,17 @@ class ObjectController(object):
+ 'expiring_objects'
+ self.expiring_objects_container_divisor = \
+ int(conf.get('expiring_objects_container_divisor') or 86400)
++ self.fs_object = None
++
++ def get_DiskFile_obj(self, path, device, partition, account, container, obj,
++ logger, keep_data_fp=False, disk_chunk_size=65536):
++ if self.fs_object:
++ return Gluster_DiskFile(path, device, partition, account, container,
++ obj, logger, keep_data_fp,
++ disk_chunk_size, fs_object = self.fs_object);
++ else:
++ return DiskFile(path, device, partition, account, container,
++ obj, logger, keep_data_fp, disk_chunk_size)
+
+ def async_update(self, op, account, container, obj, host, partition,
+ contdevice, headers_out, objdevice):
+@@ -493,7 +516,7 @@ class ObjectController(object):
+ content_type='text/plain')
+ if self.mount_check and not check_mount(self.devices, device):
+ return Response(status='507 %s is not mounted' % device)
+- file = DiskFile(self.devices, device, partition, account, container,
++ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
+ obj, self.logger, disk_chunk_size=self.disk_chunk_size)
+
+ if 'X-Delete-At' in file.metadata and \
+@@ -548,7 +571,7 @@ class ObjectController(object):
+ if new_delete_at and new_delete_at < time.time():
+ return HTTPBadRequest(body='X-Delete-At in past', request=request,
+ content_type='text/plain')
+- file = DiskFile(self.devices, device, partition, account, container,
++ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
+ obj, self.logger, disk_chunk_size=self.disk_chunk_size)
+ orig_timestamp = file.metadata.get('X-Timestamp')
+ upload_expiration = time.time() + self.max_upload_time
+@@ -580,12 +603,29 @@ class ObjectController(object):
+ if 'etag' in request.headers and \
+ request.headers['etag'].lower() != etag:
+ return HTTPUnprocessableEntity(request=request)
+- metadata = {
+- 'X-Timestamp': request.headers['x-timestamp'],
+- 'Content-Type': request.headers['content-type'],
+- 'ETag': etag,
+- 'Content-Length': str(os.fstat(fd).st_size),
+- }
++ content_type = request.headers['content-type']
++ if self.fs_object and not content_type:
++ content_type = FILE_TYPE
++ if not self.fs_object:
++ metadata = {
++ 'X-Timestamp': request.headers['x-timestamp'],
++ 'Content-Type': request.headers['content-type'],
++ 'ETag': etag,
++ 'Content-Length': str(os.fstat(fd).st_size),
++ }
++ else:
++ metadata = {
++ 'X-Timestamp': request.headers['x-timestamp'],
++ 'Content-Type': request.headers['content-type'],
++ 'ETag': etag,
++ 'Content-Length': str(os.fstat(fd).st_size),
++ X_TYPE: OBJECT,
++ X_OBJECT_TYPE: FILE,
++ }
++
++ if self.fs_object and \
++ request.headers['content-type'].lower() == DIR_TYPE:
++ metadata.update({X_OBJECT_TYPE: MARKER_DIR})
+ metadata.update(val for val in request.headers.iteritems()
+ if val[0].lower().startswith('x-object-meta-') and
+ len(val[0]) > 14)
+@@ -612,7 +652,7 @@ class ObjectController(object):
+ 'x-timestamp': file.metadata['X-Timestamp'],
+ 'x-etag': file.metadata['ETag'],
+ 'x-trans-id': request.headers.get('x-trans-id', '-')},
+- device)
++ (self.fs_object and account) or device)
+ resp = HTTPCreated(request=request, etag=etag)
+ return resp
+
+@@ -626,9 +666,9 @@ class ObjectController(object):
+ content_type='text/plain')
+ if self.mount_check and not check_mount(self.devices, device):
+ return Response(status='507 %s is not mounted' % device)
+- file = DiskFile(self.devices, device, partition, account, container,
+- obj, self.logger, keep_data_fp=True,
+- disk_chunk_size=self.disk_chunk_size)
++ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
++ obj, self.logger, keep_data_fp=True,
++ disk_chunk_size=self.disk_chunk_size)
+ if file.is_deleted() or ('X-Delete-At' in file.metadata and
+ int(file.metadata['X-Delete-At']) <= time.time()):
+ if request.headers.get('if-match') == '*':
+@@ -702,7 +742,7 @@ class ObjectController(object):
+ return resp
+ if self.mount_check and not check_mount(self.devices, device):
+ return Response(status='507 %s is not mounted' % device)
+- file = DiskFile(self.devices, device, partition, account, container,
++ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
+ obj, self.logger, disk_chunk_size=self.disk_chunk_size)
+ if file.is_deleted() or ('X-Delete-At' in file.metadata and
+ int(file.metadata['X-Delete-At']) <= time.time()):
+@@ -744,7 +784,7 @@ class ObjectController(object):
+ if self.mount_check and not check_mount(self.devices, device):
+ return Response(status='507 %s is not mounted' % device)
+ response_class = HTTPNoContent
+- file = DiskFile(self.devices, device, partition, account, container,
++ file = self.get_DiskFile_obj(self.devices, device, partition, account, container,
+ obj, self.logger, disk_chunk_size=self.disk_chunk_size)
+ if 'x-if-delete-at' in request.headers and \
+ int(request.headers['x-if-delete-at']) != \
+@@ -797,9 +837,18 @@ class ObjectController(object):
+ raise hashes
+ return Response(body=pickle.dumps(hashes))
+
++ def plugin(self, env):
++ if env.get('Gluster_enabled', False):
++ self.fs_object = env.get('fs_object')
++ self.devices = env.get('root')
++ self.mount_check = False
++ else:
++ self.fs_object = None
++
+ def __call__(self, env, start_response):
+ """WSGI Application entry point for the Swift Object Server."""
+ start_time = time.time()
++ self.plugin(env)
+ req = Request(env)
+ self.logger.txn_id = req.headers.get('x-trans-id', None)
+ if not check_utf8(req.path_info):
+diff --git a/swift/proxy/server.py b/swift/proxy/server.py
+index 17613b8..d277d28 100644
+--- a/swift/proxy/server.py
++++ b/swift/proxy/server.py
+@@ -1,4 +1,5 @@
+ # Copyright (c) 2010-2012 OpenStack, LLC.
++# Copyright (c) 2011 Red Hat, Inc.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -53,11 +54,20 @@ from webob import Request, Response
+
+ from swift.common.ring import Ring
+ from swift.common.utils import cache_from_env, ContextPool, get_logger, \
+- get_remote_client, normalize_timestamp, split_path, TRUE_VALUES
++ get_remote_client, normalize_timestamp, split_path, TRUE_VALUES, \
++ plugin_enabled
+ from swift.common.bufferedhttp import http_connect
+-from swift.common.constraints import check_metadata, check_object_creation, \
+- check_utf8, CONTAINER_LISTING_LIMIT, MAX_ACCOUNT_NAME_LENGTH, \
+- MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
++
++if plugin_enabled():
++ from swift.plugins.constraints import check_object_creation, \
++ MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
++else:
++ from swift.common.constraints import check_object_creation, \
++ MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, MAX_FILE_SIZE
++
++from swift.common.constraints import check_metadata, check_utf8, \
++ CONTAINER_LISTING_LIMIT
++
+ from swift.common.exceptions import ChunkReadTimeout, \
+ ChunkWriteTimeout, ConnectionTimeout
+
+diff --git a/test/__init__.py b/test/__init__.py
+index ef2ce31..363a051 100644
+--- a/test/__init__.py
++++ b/test/__init__.py
+@@ -6,8 +6,16 @@ import sys
+ import os
+ from ConfigParser import MissingSectionHeaderError
+ from StringIO import StringIO
+-
+ from swift.common.utils import readconf
++from swift.common.utils import plugin_enabled
++if plugin_enabled():
++ from swift.plugins.constraints import MAX_OBJECT_NAME_LENGTH, \
++ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
++ MAX_FILE_SIZE
++else:
++ from swift.common.constraints import MAX_OBJECT_NAME_LENGTH, \
++ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
++ MAX_FILE_SIZE
+
+ setattr(__builtin__, '_', lambda x: x)
+
+diff --git a/test/functional/tests.py b/test/functional/tests.py
+index b25b4fd..8d12f58 100644
+--- a/test/functional/tests.py
++++ b/test/functional/tests.py
+@@ -31,6 +31,16 @@ import urllib
+ from test import get_config
+ from swift import Account, AuthenticationFailed, Connection, Container, \
+ File, ResponseError
++from test import plugin_enabled
++if plugin_enabled():
++ from test import MAX_OBJECT_NAME_LENGTH, \
++ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
++ MAX_FILE_SIZE
++else:
++ from test import MAX_OBJECT_NAME_LENGTH, \
++ MAX_CONTAINER_NAME_LENGTH, MAX_ACCOUNT_NAME_LENGTH, \
++ MAX_FILE_SIZE
++
+
+ config = get_config()
+
+@@ -361,7 +371,7 @@ class TestContainer(Base):
+ set_up = False
+
+ def testContainerNameLimit(self):
+- limit = 256
++ limit = MAX_CONTAINER_NAME_LENGTH
+
+ for l in (limit-100, limit-10, limit-1, limit,
+ limit+1, limit+10, limit+100):
+@@ -949,7 +959,7 @@ class TestFile(Base):
+ self.assert_status(404)
+
+ def testNameLimit(self):
+- limit = 1024
++ limit = MAX_OBJECT_NAME_LENGTH
+
+ for l in (1, 10, limit/2, limit-1, limit, limit+1, limit*2):
+ file = self.env.container.file('a'*l)
+@@ -1093,7 +1103,7 @@ class TestFile(Base):
+ self.assert_(file.read(hdrs={'Range': r}) == data[0:1000])
+
+ def testFileSizeLimit(self):
+- limit = 5*2**30 + 2
++ limit = MAX_FILE_SIZE
+ tsecs = 3
+
+ for i in (limit-100, limit-10, limit-1, limit, limit+1, limit+10,
+diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py
+index 075700e..5b6f32d 100644
+--- a/test/unit/obj/test_server.py
++++ b/test/unit/obj/test_server.py
+@@ -1355,7 +1355,7 @@ class TestObjectController(unittest.TestCase):
+
+ def test_max_object_name_length(self):
+ timestamp = normalize_timestamp(time())
+- req = Request.blank('/sda1/p/a/c/' + ('1' * 1024),
++ req = Request.blank('/sda1/p/a/c/' + ('1' * MAX_OBJECT_NAME_LENGTH),
+ environ={'REQUEST_METHOD': 'PUT'},
+ headers={'X-Timestamp': timestamp,
+ 'Content-Length': '4',
+diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
+index 364370e..c17fe59 100644
+--- a/test/unit/proxy/test_server.py
++++ b/test/unit/proxy/test_server.py
+@@ -21,7 +21,6 @@ import os
+ import sys
+ import unittest
+ from nose import SkipTest
+-from ConfigParser import ConfigParser
+ from contextlib import contextmanager
+ from cStringIO import StringIO
+ from gzip import GzipFile
+@@ -44,8 +43,18 @@ from swift.account import server as account_server
+ from swift.container import server as container_server
+ from swift.obj import server as object_server
+ from swift.common import ring
+-from swift.common.constraints import MAX_META_NAME_LENGTH, \
+- MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, MAX_FILE_SIZE
++from swift.common.utils import plugin_enabled
++if plugin_enabled():
++ from swift.plugins.constraints import MAX_META_NAME_LENGTH, \
++ MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \
++ MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, \
++ MAX_OBJECT_NAME_LENGTH
++else:
++ from swift.plugins.constraints import MAX_META_NAME_LENGTH, \
++ MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \
++ MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH, \
++ MAX_OBJECT_NAME_LENGTH
++
+ from swift.common.utils import mkdirs, normalize_timestamp, NullLogger
+ from swift.common.wsgi import monkey_patch_mimetools
+
+@@ -3207,7 +3216,8 @@ class TestContainerController(unittest.TestCase):
+ def test_PUT_max_container_name_length(self):
+ with save_globals():
+ controller = proxy_server.ContainerController(self.app, 'account',
+- '1' * 256)
++ '1' *
++ MAX_CONTAINER_NAME_LENGTH,)
+ self.assert_status_map(controller.PUT,
+ (200, 200, 200, 201, 201, 201), 201,
+ missing_container=True)
+@@ -3813,7 +3823,8 @@ class TestAccountController(unittest.TestCase):
+ def test_PUT_max_account_name_length(self):
+ with save_globals():
+ self.app.allow_account_management = True
+- controller = proxy_server.AccountController(self.app, '1' * 256)
++ controller = proxy_server.AccountController(self.app, '1' *
++ MAX_ACCOUNT_NAME_LENGTH)
+ self.assert_status_map(controller.PUT, (201, 201, 201), 201)
+ controller = proxy_server.AccountController(self.app, '2' * 257)
+ self.assert_status_map(controller.PUT, (201, 201, 201), 400)