Allow fs creation if mountpoint is not specified
Such services as Swift-storage require partition with file
system without mountpoints, currently fuel-agent prevents
to do that.
Change-Id: Id9e90f81098de3736e0d9b1ca82e434122efd4e8
Closes-bug: #1650622
(cherry picked from commit d9f9f377e4
)
This commit is contained in:
parent
02b7979845
commit
08d578a81e
|
@ -433,16 +433,27 @@ class Nailgun(base.BaseDataDriver):
|
||||||
volume['partition_guid'])
|
volume['partition_guid'])
|
||||||
prt.set_guid(volume['partition_guid'])
|
prt.set_guid(volume['partition_guid'])
|
||||||
|
|
||||||
if 'mount' in volume and volume['mount'] != 'none':
|
fs = volume.get('file_system')
|
||||||
|
if fs == 'none':
|
||||||
|
fs = None
|
||||||
|
mount = volume.get('mount')
|
||||||
|
if mount == 'none':
|
||||||
|
mount = None
|
||||||
|
|
||||||
|
if fs is not None or mount is not None:
|
||||||
|
# NOTE(el): Set default file system to xfs for
|
||||||
|
# the purpose of backward compatibility with
|
||||||
|
# previous versions of fuel-agent.
|
||||||
|
if fs is None:
|
||||||
|
fs = 'xfs'
|
||||||
LOG.debug('Adding file system on partition: '
|
LOG.debug('Adding file system on partition: '
|
||||||
'mount=%s type=%s' %
|
'mount=%s type=%s', mount, fs)
|
||||||
(volume['mount'],
|
|
||||||
volume.get('file_system', 'xfs')))
|
|
||||||
partition_scheme.add_fs(
|
partition_scheme.add_fs(
|
||||||
device=prt.name, mount=volume['mount'],
|
device=prt.name,
|
||||||
fs_type=volume.get('file_system', 'xfs'),
|
mount=mount,
|
||||||
|
fs_type=fs,
|
||||||
fs_label=volume.get('disk_label'))
|
fs_label=volume.get('disk_label'))
|
||||||
if volume['mount'] == '/boot' and not self._boot_done:
|
if mount == '/boot' and not self._boot_done:
|
||||||
self._boot_done = True
|
self._boot_done = True
|
||||||
|
|
||||||
if volume['type'] == 'pv':
|
if volume['type'] == 'pv':
|
||||||
|
|
|
@ -547,9 +547,7 @@ class Manager(object):
|
||||||
LOG.debug('Mounting target file systems into a flat set '
|
LOG.debug('Mounting target file systems into a flat set '
|
||||||
'of temporary directories')
|
'of temporary directories')
|
||||||
mount_map = {}
|
mount_map = {}
|
||||||
for fs in self.driver.partition_scheme.fss:
|
for fs in self.driver.partition_scheme.fss_w_mountpoints:
|
||||||
if fs.mount == 'swap':
|
|
||||||
continue
|
|
||||||
# It is an ugly hack to resolve python2/3 encoding issues and
|
# It is an ugly hack to resolve python2/3 encoding issues and
|
||||||
# should be removed after transistion to python3
|
# should be removed after transistion to python3
|
||||||
try:
|
try:
|
||||||
|
@ -636,8 +634,6 @@ class Manager(object):
|
||||||
LOG.debug('Mounting target file systems: %s', chroot)
|
LOG.debug('Mounting target file systems: %s', chroot)
|
||||||
# Here we are going to mount all file systems in partition scheme.
|
# Here we are going to mount all file systems in partition scheme.
|
||||||
for fs in self.driver.partition_scheme.fs_sorted_by_depth():
|
for fs in self.driver.partition_scheme.fs_sorted_by_depth():
|
||||||
if fs.mount == 'swap':
|
|
||||||
continue
|
|
||||||
mount = chroot + fs.mount
|
mount = chroot + fs.mount
|
||||||
utils.makedirs_if_not_exists(mount)
|
utils.makedirs_if_not_exists(mount)
|
||||||
fu.mount_fs(fs.type, str(fs.device), mount)
|
fu.mount_fs(fs.type, str(fs.device), mount)
|
||||||
|
@ -664,8 +660,6 @@ class Manager(object):
|
||||||
fu.umount_fs(chroot + path)
|
fu.umount_fs(chroot + path)
|
||||||
for fs in self.driver.partition_scheme.fs_sorted_by_depth(
|
for fs in self.driver.partition_scheme.fs_sorted_by_depth(
|
||||||
reverse=True):
|
reverse=True):
|
||||||
if fs.mount == 'swap':
|
|
||||||
continue
|
|
||||||
fu.umount_fs(chroot + fs.mount)
|
fu.umount_fs(chroot + fs.mount)
|
||||||
|
|
||||||
def install_base_os(self, chroot):
|
def install_base_os(self, chroot):
|
||||||
|
@ -957,7 +951,9 @@ class Manager(object):
|
||||||
# at fstab line. Currently we set it into 0 which means
|
# at fstab line. Currently we set it into 0 which means
|
||||||
# a corresponding file system will never be checked. We assume
|
# a corresponding file system will never be checked. We assume
|
||||||
# puppet or other configuration tool will care of it.
|
# puppet or other configuration tool will care of it.
|
||||||
if fs.mount == '/':
|
if fs.mount is None:
|
||||||
|
LOG.debug('Skipping fstab entry creation for %s', fs)
|
||||||
|
elif fs.mount == '/':
|
||||||
f.write(u'UUID=%s %s %s defaults,errors=panic 0 0\n' %
|
f.write(u'UUID=%s %s %s defaults,errors=panic 0 0\n' %
|
||||||
(mount2uuid[fs.mount], fs.mount, fs.type))
|
(mount2uuid[fs.mount], fs.mount, fs.type))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -60,7 +60,7 @@ class PartitionScheme(object):
|
||||||
|
|
||||||
def add_fs(self, **kwargs):
|
def add_fs(self, **kwargs):
|
||||||
fs = f_fs.FileSystem(**kwargs)
|
fs = f_fs.FileSystem(**kwargs)
|
||||||
if not os.path.isabs(fs.mount) and fs.mount != 'swap':
|
if fs.mount and not os.path.isabs(fs.mount) and fs.mount != 'swap':
|
||||||
raise errors.WrongFSMount(
|
raise errors.WrongFSMount(
|
||||||
'Incorrect mount point %s' % fs.mount)
|
'Incorrect mount point %s' % fs.mount)
|
||||||
self.fss.append(fs)
|
self.fss.append(fs)
|
||||||
|
@ -144,7 +144,15 @@ class PartitionScheme(object):
|
||||||
"""
|
"""
|
||||||
def key(x):
|
def key(x):
|
||||||
return x.mount.rstrip(os.path.sep).count(os.path.sep)
|
return x.mount.rstrip(os.path.sep).count(os.path.sep)
|
||||||
return sorted(self.fss, key=key, reverse=reverse)
|
return sorted(self.fss_w_mountpoints, key=key, reverse=reverse)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fss_w_mountpoints(self):
|
||||||
|
"""Returns a list of file systems which have mountpoints"""
|
||||||
|
# NOTE: `swap` mountpoint is not a real mountpoint, so has
|
||||||
|
# to be skipped.
|
||||||
|
return filter(lambda f: f.mount is not None and f.mount != "swap",
|
||||||
|
self.fss)
|
||||||
|
|
||||||
def lv_by_device_name(self, device_name):
|
def lv_by_device_name(self, device_name):
|
||||||
return next((x for x in self.lvs if x.device_name == device_name),
|
return next((x for x in self.lvs if x.device_name == device_name),
|
||||||
|
|
|
@ -26,6 +26,16 @@ from fuel_agent.objects import image
|
||||||
from fuel_agent.utils import utils
|
from fuel_agent.utils import utils
|
||||||
|
|
||||||
|
|
||||||
|
SWIFT = {
|
||||||
|
'disk_label': None,
|
||||||
|
'file_system': 'xfs',
|
||||||
|
'mount': 'none',
|
||||||
|
'name': 'swift-storage',
|
||||||
|
'partition_guid': 'deadbeef-9d34-4175-8ded-1ce68967a5ee',
|
||||||
|
'size': 10,
|
||||||
|
'type': 'partition'
|
||||||
|
}
|
||||||
|
|
||||||
CEPH_JOURNAL = {
|
CEPH_JOURNAL = {
|
||||||
"partition_guid": "45b0969e-9b03-4f30-b4c6-b4b80ceff106",
|
"partition_guid": "45b0969e-9b03-4f30-b4c6-b4b80ceff106",
|
||||||
"name": "cephjournal",
|
"name": "cephjournal",
|
||||||
|
@ -1666,6 +1676,22 @@ class TestNailgunMockedMeta(unittest2.TestCase):
|
||||||
self.assertEqual(3, drv._get_partition_count('Boot'))
|
self.assertEqual(3, drv._get_partition_count('Boot'))
|
||||||
self.assertEqual(1, drv._get_partition_count('TMP'))
|
self.assertEqual(1, drv._get_partition_count('TMP'))
|
||||||
|
|
||||||
|
def test_partition_scheme_no_mount_fs(self, mock_lbd, mock_image_meta):
|
||||||
|
p_data = copy.deepcopy(PROVISION_SAMPLE_DATA)
|
||||||
|
for i in range(0, 3):
|
||||||
|
p_data['ks_meta']['pm_data']['ks_spaces'][i]['volumes'].append(
|
||||||
|
SWIFT)
|
||||||
|
mock_lbd.return_value = LIST_BLOCK_DEVICES_SAMPLE
|
||||||
|
drv = nailgun.Nailgun(p_data)
|
||||||
|
p_scheme = drv.partition_scheme
|
||||||
|
self.assertEqual(4, len(list(p_scheme.fss_w_mountpoints)))
|
||||||
|
self.assertEqual(8, len(p_scheme.fss))
|
||||||
|
self.assertEqual(4, len(p_scheme.pvs))
|
||||||
|
self.assertEqual(3, len(p_scheme.lvs))
|
||||||
|
self.assertEqual(2, len(p_scheme.vgs))
|
||||||
|
self.assertEqual(3, len(p_scheme.parteds))
|
||||||
|
self.assertEqual(3, drv._get_partition_count('swift-storage'))
|
||||||
|
|
||||||
def test_partition_scheme_ceph(self, mock_lbd, mock_image_meta):
|
def test_partition_scheme_ceph(self, mock_lbd, mock_image_meta):
|
||||||
# TODO(agordeev): perform better testing of ceph logic
|
# TODO(agordeev): perform better testing of ceph logic
|
||||||
p_data = copy.deepcopy(PROVISION_SAMPLE_DATA)
|
p_data = copy.deepcopy(PROVISION_SAMPLE_DATA)
|
||||||
|
@ -1677,6 +1703,7 @@ class TestNailgunMockedMeta(unittest2.TestCase):
|
||||||
mock_lbd.return_value = LIST_BLOCK_DEVICES_SAMPLE
|
mock_lbd.return_value = LIST_BLOCK_DEVICES_SAMPLE
|
||||||
drv = nailgun.Nailgun(p_data)
|
drv = nailgun.Nailgun(p_data)
|
||||||
p_scheme = drv.partition_scheme
|
p_scheme = drv.partition_scheme
|
||||||
|
self.assertEqual(4, len(list(p_scheme.fss_w_mountpoints)))
|
||||||
self.assertEqual(5, len(p_scheme.fss))
|
self.assertEqual(5, len(p_scheme.fss))
|
||||||
self.assertEqual(4, len(p_scheme.pvs))
|
self.assertEqual(4, len(p_scheme.pvs))
|
||||||
self.assertEqual(3, len(p_scheme.lvs))
|
self.assertEqual(3, len(p_scheme.lvs))
|
||||||
|
|
Loading…
Reference in New Issue