swift fixes
This commit is contained in:
parent
148e9ab95d
commit
ba62af4d2f
@ -6,7 +6,7 @@
|
||||
keys=root
|
||||
|
||||
[logger_root]
|
||||
level=INFO
|
||||
level=DEBUG
|
||||
handlers=hand01
|
||||
formatter=form01
|
||||
|
||||
|
@ -41,6 +41,10 @@
|
||||
"sqlite3": {
|
||||
"version": "3.7*",
|
||||
"removable": true
|
||||
},
|
||||
"xfsprogs": {
|
||||
"version": "3.1*",
|
||||
"removable": true
|
||||
}
|
||||
},
|
||||
"rhel-6": {
|
||||
|
@ -54,6 +54,10 @@ REQ_PKGS = ['general.json', 'swift.json']
|
||||
class SwiftUninstaller(comp.PythonUninstallComponent):
|
||||
def __init__(self, *args, **kargs):
|
||||
comp.PythonUninstallComponent.__init__(self, TYPE, *args, **kargs)
|
||||
self.datadir = sh.joinpths(self.appdir, self.cfg.get('swift', 'data_location'))
|
||||
|
||||
def pre_uninstall(self):
|
||||
sh.umount(sh.joinpths(self.datadir, 'drives/sdb1'))
|
||||
|
||||
|
||||
class SwiftInstaller(comp.PythonInstallComponent):
|
||||
@ -104,12 +108,12 @@ class SwiftInstaller(comp.PythonInstallComponent):
|
||||
}
|
||||
|
||||
def __create_data_location(self):
|
||||
self.fs_image = sh.joinpths(self.datadir, '/drives/images/swift.img')
|
||||
self.fs_image = sh.joinpths(self.datadir, 'drives/images/swift.img')
|
||||
sh.create_loopback_file(fname=self.fs_image,
|
||||
size=self.cfg.get('swift',
|
||||
'partition_power_size'),
|
||||
size=int(self.cfg.get('swift',
|
||||
'loopback_disk_size')),
|
||||
fs_type='xfs')
|
||||
self.fs_dev = sh.joinpths(self.datadir, '/drives/sdb1')
|
||||
self.fs_dev = sh.joinpths(self.datadir, 'drives/sdb1/')
|
||||
sh.mount_loopback_file(self.fs_image, self.fs_dev, 'xfs',
|
||||
run_as_root=False)
|
||||
|
||||
@ -126,14 +130,14 @@ class SwiftInstaller(comp.PythonInstallComponent):
|
||||
|
||||
def __create_nodes(self):
|
||||
for i in range(1, 5):
|
||||
sh.mkdirslist(sh.joinpths(self.fs_dev), '%d/node' % i)
|
||||
sh.mkdirslist(sh.joinpths(self.fs_dev, '%d/node' % i))
|
||||
sh.symlink(sh.joinpths(self.fs_dev, str(i)),
|
||||
sh.joinpths(self.datadir, str(i)))
|
||||
self.__create_node_config(i, 6010 + (i - 1) * 5)
|
||||
|
||||
def __turn_on_rsync(self):
|
||||
sh.symlink(sh.joinpths(self.cfgdir, RSYNC_CONF),
|
||||
sh.joinpths('/etc/rsyncd.conf'))
|
||||
'/etc/rsyncd.conf')
|
||||
sh.replace_in_file('/etc/default/rsync',
|
||||
'RSYNC_ENABLE=false',
|
||||
'RSYNC_ENABLE=true')
|
||||
|
@ -300,10 +300,12 @@ def rmdir(path, quiet=True):
|
||||
pass
|
||||
|
||||
|
||||
def symlink(source, link):
|
||||
def symlink(source, link, force=True):
|
||||
path = dirname(link)
|
||||
mkdirslist(path)
|
||||
LOG.debug("Creating symlink from %s => %s" % (link, source))
|
||||
if force and exists(link):
|
||||
unlink(link, True)
|
||||
os.symlink(source, link)
|
||||
|
||||
|
||||
@ -348,10 +350,10 @@ def getgroupname(gid=None):
|
||||
return gid_info.gr_name
|
||||
|
||||
|
||||
def create_loopback_file(fname, size, bsize=1014, fs_type='ext3', run_as_root=False):
|
||||
def create_loopback_file(fname, size, bsize=1024, fs_type='ext3', run_as_root=False):
|
||||
dd_cmd = ['dd', 'if=/dev/zero', 'of=%s' % fname, 'bs=%d' % bsize,
|
||||
'count=0', 'seek=%d %size']
|
||||
mkfs_cmd = ['mkfs.%s' % fs_type, '-f', '-i', 'size=%d' % size, fname]
|
||||
'count=0', 'seek=%d' % size]
|
||||
mkfs_cmd = ['mkfs.%s' % fs_type, '-f', '-i', 'size=%d' % bsize, fname]
|
||||
|
||||
# make sure folder exists
|
||||
files = mkdirslist(dirname(fname))
|
||||
@ -360,20 +362,28 @@ def create_loopback_file(fname, size, bsize=1014, fs_type='ext3', run_as_root=Fa
|
||||
touch_file(fname)
|
||||
|
||||
# fill with zeroes
|
||||
execute(dd_cmd, run_as_root)
|
||||
execute(*dd_cmd, run_as_root=run_as_root)
|
||||
|
||||
# create fs on the file
|
||||
execute(mkfs_cmd, run_as_root)
|
||||
execute(*mkfs_cmd, run_as_root=run_as_root)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def mount_loopback_file(fname, device_name, fs_type='ext3', run_as_root=True):
|
||||
mount_cmd = ['mount', '-t', fs_type, '-o',
|
||||
'loop,noatime,nodiratime,nobarries,logbuf=8', fname,
|
||||
'loop,noatime,nodiratime,nobarrier,logbufs=8', fname,
|
||||
device_name]
|
||||
|
||||
execute(mount_cmd, run_as_root)
|
||||
files = mkdirslist(dirname(device_name))
|
||||
|
||||
execute(*mount_cmd, run_as_root=run_as_root)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def umount(dev_name, run_as_root=True):
|
||||
execute('umount', dev_name, run_as_root=run_as_root)
|
||||
|
||||
|
||||
def unlink(path, ignore_errors=True):
|
||||
@ -396,7 +406,7 @@ def chmod(fname, mode):
|
||||
|
||||
def replace_in_file(fname, search, replace):
|
||||
# fileinput with inplace=1 moves file to tmp and redirects stdio to file
|
||||
for line in fileinput.input(file, inplace=1):
|
||||
for line in fileinput.input(fname, inplace=1):
|
||||
if search in line:
|
||||
line = line.replace(search, replace)
|
||||
print line,
|
||||
@ -405,8 +415,8 @@ def replace_in_file(fname, search, replace):
|
||||
def copy_replace_file(fsrc, fdst, map_):
|
||||
files = mkdirslist(dirname(fdst))
|
||||
with open(fdst, 'w') as fh:
|
||||
for line in fileinput(fsrc):
|
||||
for (k, v) in map_:
|
||||
for line in fileinput.input(fsrc):
|
||||
for (k, v) in map_.items():
|
||||
line = line.replace(k, v)
|
||||
fh.write(line)
|
||||
return files
|
||||
|
Loading…
x
Reference in New Issue
Block a user