summaryrefslogtreecommitdiffstats
path: root/swift/1.4.8/plugins/Glusterfs.py
diff options
context:
space:
mode:
authorPeter Portante <peter.portante@redhat.com>2012-11-08 01:16:56 -0500
committerPeter Portante <peter.portante@redhat.com>2013-04-29 16:35:56 -0400
commitdd826e28c7b34603771d5652574a8df235637380 (patch)
treef9900d838bb0c6e31cc00816f39edd11ff3eb236 /swift/1.4.8/plugins/Glusterfs.py
parentb85ce6f7e1513cd53a5adce7942a469fc96d38f3 (diff)
object-storage: final changes to remove swift diff
Final set of changes to remove the diffs carried to make UFO work with OpenStack Swift. The code is now a complete layering on top of OpenStack Swift where we either "monkey patch" or subclass as necessary. See BZ 870589 (https://bugzilla.redhat.com/show_bug.cgi?id=870589). There are a lot of changes here due for the most part to rearranging the directory hierarchy to have create a proper python module hierarchy under the "gluster" namespace. Plugin references have been removed. The differences that used to be in the swift.diff file are now replaced with server implementations for account, container, object, and proxy that subclass the swift versions. Additionally, the plugins/conf directory has been moved to the "etc" directory, and the plugins/bin directory promoted a level. Unit tests pass. A new setup.py file is provided so that the install process can use it for creating all the necessary python install infrastructure (eggs and paste support). A new RPM spec file is provided which to properly install the new code, and the sample configuration files have been modified to reference the new python egg. Change-Id: I4316c1b66dca80f847fe9b0d583174689c175599 BUG: 870589 Signed-off-by: Peter Portante <peter.portante@redhat.com> Reviewed-on: http://review.gluster.org/4180 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Mohammed Junaid <junaid@redhat.com> Tested-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'swift/1.4.8/plugins/Glusterfs.py')
-rw-r--r--swift/1.4.8/plugins/Glusterfs.py131
1 files changed, 0 insertions, 131 deletions
diff --git a/swift/1.4.8/plugins/Glusterfs.py b/swift/1.4.8/plugins/Glusterfs.py
deleted file mode 100644
index c176a24..0000000
--- a/swift/1.4.8/plugins/Glusterfs.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright (c) 2012 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.
-import logging
-import os, fcntl, time
-from ConfigParser import ConfigParser
-from swift.common.utils import TRUE_VALUES
-from swift.plugins.fs_utils import mkdirs
-
-
-#
-# Read the fs.conf file once at startup (module load)
-#
-_fs_conf = ConfigParser()
-AUTH_ACCOUNT = 'auth'
-MOUNT_IP = 'localhost'
-REMOTE_CLUSTER = False
-OBJECT_ONLY = False
-if _fs_conf.read(os.path.join('/etc/swift', 'fs.conf')):
- try:
- AUTH_ACCOUNT = _fs_conf.get('DEFAULT', 'auth_account', 'auth')
- except (NoSectionError, NoOptionError):
- pass
- try:
- MOUNT_IP = _fs_conf.get('DEFAULT', 'mount_ip', 'localhost')
- except (NoSectionError, NoOptionError):
- pass
- try:
- REMOTE_CLUSTER = _fs_conf.get('DEFAULT', 'remote_cluster', False) in TRUE_VALUES
- except (NoSectionError, NoOptionError):
- pass
- try:
- OBJECT_ONLY = _fs_conf.get('DEFAULT', 'object_only', "no") in TRUE_VALUES
- except (NoSectionError, NoOptionError):
- pass
-NAME = 'glusterfs'
-
-
-def _busy_wait(full_mount_path):
- # Iterate for definite number of time over a given
- # interval for successful mount
- for i in range(0, 5):
- if os.path.ismount(os.path.join(full_mount_path)):
- return True
- time.sleep(2)
- logging.error('Busy wait for mount timed out for mount %s', full_mount_path)
- return False
-
-def mount(root, drive):
- # FIXME: Possible thundering herd problem here
-
- el = _get_export_list()
- for export in el:
- if drive == export:
- break
- else:
- logging.error('No export found in %r matching drive %s', el, drive)
- return False
-
- # NOTE: root is typically the default value of /mnt/gluster-object
- full_mount_path = os.path.join(root, drive)
- if not os.path.isdir(full_mount_path):
- mkdirs(full_mount_path)
-
- pid_dir = "/var/lib/glusterd/vols/%s/run/" % drive
- pid_file = os.path.join(pid_dir, 'swift.pid');
-
- if not os.path.exists(pid_dir):
- mkdirs(pid_dir)
-
- fd = os.open(pid_file, os.O_CREAT|os.O_RDWR)
- with os.fdopen(fd, 'r+b') as f:
- try:
- fcntl.lockf(f, fcntl.LOCK_EX|fcntl.LOCK_NB)
- except:
- ex = sys.exc_info()[1]
- if isinstance(ex, IOError) and ex.errno in (EACCES, EAGAIN):
- # This means that some other process is mounting the
- # filesystem, so wait for the mount process to complete
- return _busy_wait(full_mount_path)
-
- mnt_cmd = 'mount -t glusterfs %s:%s %s' % (MOUNT_IP, export, \
- full_mount_path)
- if os.system(mnt_cmd) or not _busy_wait(full_mount_path):
- logging.error('Mount failed %s: %s', NAME, mnt_cmd)
- return False
- return True
-
-def unmount(full_mount_path):
- # FIXME: Possible thundering herd problem here
-
- umnt_cmd = 'umount %s 2>> /dev/null' % full_mount_path
- if os.system(umnt_cmd):
- logging.error('Unable to unmount %s %s' % (full_mount_path, NAME))
-
-def _get_export_list():
- if REMOTE_CLUSTER:
- cmnd = 'ssh %s gluster volume info' % MOUNT_IP
- else:
- cmnd = 'gluster volume info'
-
- export_list = []
-
- if os.system(cmnd + ' >> /dev/null'):
- if REMOTE_CLUSTER:
- logging.error('Getting volume info failed %s, make sure to have '\
- 'passwordless ssh on %s', NAME, MOUNT_IP)
- else:
- logging.error('Getting volume failed %s', NAME)
- else:
- fp = os.popen(cmnd)
- while True:
- item = fp.readline()
- if not item:
- break
- item = item.strip('\n').strip(' ')
- if item.lower().startswith('volume name:'):
- export_list.append(item.split(':')[1].strip(' '))
-
- return export_list