Fix logger issue in move_files_to_their_places function
A typo in manager.py was fixed. This typo doesn't break anything when old enough oslo.log module is used, but it breaks deployment process when newer OS is used to build bootstrap image. A minor issue with path build process was also fixed. Change-Id: I97616ef0bfbe0f7ffc6e625e4bf7c7ffde1a1919 Closes-Bug: #1597697
This commit is contained in:
parent
b70ff4e232
commit
e6a31c8456
|
@ -71,6 +71,10 @@ class LVNotFoundError(BaseError):
|
|||
pass
|
||||
|
||||
|
||||
class WrongFSMount(BaseError):
|
||||
pass
|
||||
|
||||
|
||||
class MDAlreadyExistsError(BaseError):
|
||||
pass
|
||||
|
||||
|
|
|
@ -507,16 +507,19 @@ class Manager(object):
|
|||
mount_map = self.mount_target_flat()
|
||||
for fs_mount in sorted(mount_map):
|
||||
head, tail = os.path.split(fs_mount)
|
||||
LOG.debug('Trying to move files for %s file system', fs_mount)
|
||||
while head != fs_mount:
|
||||
LOG.debug('Trying to move files for %s file system', fs_mount)
|
||||
LOG.debug('Checking whether %s is a separate mount point or '
|
||||
'not', head)
|
||||
if head in mount_map:
|
||||
LOG.debug('File system %s is mounted into %s',
|
||||
head, mount_map[head])
|
||||
check_path = os.path.join(mount_map[head], tail)
|
||||
LOG.debug('Trying to check if path %s exists', check_path)
|
||||
if os.path.exists(check_path):
|
||||
LOG.debug('Path %s exists. Trying to sync all files '
|
||||
'from there to %s', mount_map[fs_mount])
|
||||
LOG.debug('Path exists. Trying to sync all files '
|
||||
'from %s to %s', check_path,
|
||||
mount_map[fs_mount])
|
||||
src_path = check_path + '/'
|
||||
utils.execute('rsync', '-avH', src_path,
|
||||
mount_map[fs_mount])
|
||||
|
@ -548,6 +551,7 @@ class Manager(object):
|
|||
fs_mount = fs.mount.encode('ascii', 'ignore')
|
||||
except NameError:
|
||||
fs_mount = fs.mount
|
||||
fs_mount = os.path.normpath(fs_mount)
|
||||
mount_map[fs_mount] = fu.mount_fs_temp(fs.type, str(fs.device))
|
||||
LOG.debug('Flat mount map: %s', mount_map)
|
||||
return mount_map
|
||||
|
|
|
@ -60,6 +60,9 @@ class PartitionScheme(object):
|
|||
|
||||
def add_fs(self, **kwargs):
|
||||
fs = FileSystem(**kwargs)
|
||||
if not os.path.isabs(fs.mount) and fs.mount != 'swap':
|
||||
raise errors.WrongFSMount(
|
||||
'Incorrect mount point %s' % fs.mount)
|
||||
self.fss.append(fs)
|
||||
return fs
|
||||
|
||||
|
|
|
@ -912,7 +912,7 @@ none /run/shm tmpfs rw,nosuid,nodev 0 0"""
|
|||
self.mgr.driver.partition_scheme.add_fs(
|
||||
device='/dev/fake1', mount='/', fs_type='ext4')
|
||||
self.mgr.driver.partition_scheme.add_fs(
|
||||
device='/dev/fake2', mount='/var/lib', fs_type='ext4')
|
||||
device='/dev/fake2', mount='/var/lib/', fs_type='ext4')
|
||||
self.assertEqual({'/': '/tmp/dir1', '/var/lib': '/tmp/dir2'},
|
||||
self.mgr.mount_target_flat())
|
||||
self.assertEqual([mock.call('ext4', '/dev/fake1'),
|
||||
|
|
|
@ -123,13 +123,18 @@ class TestPartitionScheme(unittest2.TestCase):
|
|||
self.assertEqual(expected_fs, actual_fs)
|
||||
|
||||
def test_fs_by_mount(self):
|
||||
expected_fs = objects.FileSystem('d', mount='mount')
|
||||
expected_fs = objects.FileSystem('d', mount='/mount')
|
||||
self.p_scheme.fss.append(expected_fs)
|
||||
self.p_scheme.fss.append(objects.FileSystem('w_d',
|
||||
mount='wrong_mount'))
|
||||
actual_fs = self.p_scheme.fs_by_mount('mount')
|
||||
mount='/wrong_mount'))
|
||||
actual_fs = self.p_scheme.fs_by_mount('/mount')
|
||||
self.assertEqual(expected_fs, actual_fs)
|
||||
|
||||
def test_fs_malformed_mount(self):
|
||||
self.assertRaises(errors.WrongFSMount, self.p_scheme.add_fs,
|
||||
device='device', mount='fake_mount',
|
||||
fs_type='xfs', fs_label='fake_label')
|
||||
|
||||
def test_pv_by_name(self):
|
||||
expected_pv = objects.PhysicalVolume('pv')
|
||||
self.p_scheme.pvs.append(expected_pv)
|
||||
|
@ -184,21 +189,21 @@ class TestPartitionScheme(unittest2.TestCase):
|
|||
self.assertEqual(0, len(self.p_scheme.mds))
|
||||
self.assertEqual(0, len(self.p_scheme.fss))
|
||||
expected_md = objects.MultipleDevice('name', 'level')
|
||||
expected_fs = objects.FileSystem('name', mount='mount')
|
||||
expected_fs = objects.FileSystem('name', mount='/mount')
|
||||
self.p_scheme.mds.append(expected_md)
|
||||
self.p_scheme.fss.append(expected_fs)
|
||||
self.p_scheme.fss.append(objects.FileSystem('wrong_name',
|
||||
mount='wrong_mount'))
|
||||
self.assertEqual(expected_md, self.p_scheme.md_by_mount('mount'))
|
||||
mount='/wrong_mount'))
|
||||
self.assertEqual(expected_md, self.p_scheme.md_by_mount('/mount'))
|
||||
|
||||
def test_md_attach_by_mount_md_exists(self):
|
||||
self.assertEqual(0, len(self.p_scheme.mds))
|
||||
self.assertEqual(0, len(self.p_scheme.fss))
|
||||
expected_md = objects.MultipleDevice('name', 'level')
|
||||
expected_fs = objects.FileSystem('name', mount='mount')
|
||||
expected_fs = objects.FileSystem('name', mount='/mount')
|
||||
self.p_scheme.mds.append(expected_md)
|
||||
self.p_scheme.fss.append(expected_fs)
|
||||
actual_md = self.p_scheme.md_attach_by_mount('device', 'mount')
|
||||
actual_md = self.p_scheme.md_attach_by_mount('device', '/mount')
|
||||
self.assertIn('device', actual_md.devices)
|
||||
self.assertEqual(expected_md, actual_md)
|
||||
|
||||
|
@ -206,12 +211,12 @@ class TestPartitionScheme(unittest2.TestCase):
|
|||
self.assertEqual(0, len(self.p_scheme.mds))
|
||||
self.assertEqual(0, len(self.p_scheme.fss))
|
||||
actual_md = self.p_scheme.md_attach_by_mount(
|
||||
'device', 'mount', fs_type='fs_type', fs_options='-F',
|
||||
'device', '/mount', fs_type='fs_type', fs_options='-F',
|
||||
fs_label='fs_label', name='name', level='level')
|
||||
self.assertIn('device', actual_md.devices)
|
||||
self.assertEqual(1, len(self.p_scheme.fss))
|
||||
self.assertEqual('name', self.p_scheme.fss[0].device)
|
||||
self.assertEqual('mount', self.p_scheme.fss[0].mount)
|
||||
self.assertEqual('/mount', self.p_scheme.fss[0].mount)
|
||||
self.assertEqual('fs_type', self.p_scheme.fss[0].type)
|
||||
self.assertEqual('fs_label', self.p_scheme.fss[0].label)
|
||||
self.assertEqual('-F', self.p_scheme.fss[0].options)
|
||||
|
@ -229,7 +234,7 @@ class TestPartitionScheme(unittest2.TestCase):
|
|||
self.p_scheme.add_lv(name='fake_lv', vgname=vg.name, size=1)
|
||||
lv = self.p_scheme.lvs[0]
|
||||
|
||||
self.p_scheme.add_fs(device=lv.device_name, mount='fake_mount',
|
||||
self.p_scheme.add_fs(device=lv.device_name, mount='/fake/mount',
|
||||
fs_type='xfs', fs_label='fake_label')
|
||||
fs = self.p_scheme.fss[0]
|
||||
|
||||
|
|
Loading…
Reference in New Issue