Properly set ephemeral size in agent drivers

This commit ensures that ephemeral_mb will be passed to an IPA
ramdisk, as it is what is expected by both IPA and ironic-lib.

This change also deduplicates some of the logic between
iscsi_deploy.build_instance_info_for_deploy and
deploy_utils.parse_instance_info methods.

Closes-bug: #1592895
Change-Id: I0c0ea7a887f9aeb9fc4280aa86098d59ee8cad20
This commit is contained in:
Vladyslav Drok 2016-06-15 19:45:20 +03:00
parent 136667493a
commit 2e0716720a
4 changed files with 19 additions and 9 deletions

View File

@ -1123,7 +1123,9 @@ def parse_instance_info(node):
" in node's instance_info") " in node's instance_info")
check_for_missing_params(i_info, error_msg) check_for_missing_params(i_info, error_msg)
i_info['swap_mb'] = int(info.get('swap_mb', 0)) # NOTE(vdrok): We're casting disk layout parameters to int only after
# ensuring that it is possible
i_info['swap_mb'] = info.get('swap_mb', 0)
i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0)
err_msg_invalid = _("Cannot validate parameter for driver deploy. " err_msg_invalid = _("Cannot validate parameter for driver deploy. "
"Invalid parameter %(param)s. Reason: %(reason)s") "Invalid parameter %(param)s. Reason: %(reason)s")
@ -1136,10 +1138,12 @@ def parse_instance_info(node):
{'param': param, {'param': param,
'reason': reason}) 'reason': reason})
i_info['root_mb'] = 1024 * int(info.get('root_gb')) i_info['root_mb'] = 1024 * int(i_info['root_gb'])
i_info['swap_mb'] = int(i_info['swap_mb'])
i_info['ephemeral_mb'] = 1024 * int(i_info['ephemeral_gb'])
if iwdi: if iwdi:
if int(i_info['swap_mb']) > 0 or int(i_info['ephemeral_gb']) > 0: if i_info['swap_mb'] > 0 or i_info['ephemeral_mb'] > 0:
err_msg_invalid = _("Cannot deploy whole disk image with " err_msg_invalid = _("Cannot deploy whole disk image with "
"swap or ephemeral size set") "swap or ephemeral size set")
raise exception.InvalidParameterValue(err_msg_invalid) raise exception.InvalidParameterValue(err_msg_invalid)

View File

@ -207,9 +207,9 @@ def get_deploy_info(node, address, iqn, port=None, lun='1'):
is_whole_disk_image = node.driver_internal_info['is_whole_disk_image'] is_whole_disk_image = node.driver_internal_info['is_whole_disk_image']
if not is_whole_disk_image: if not is_whole_disk_image:
params.update({'root_mb': 1024 * int(i_info['root_gb']), params.update({'root_mb': i_info['root_mb'],
'swap_mb': int(i_info['swap_mb']), 'swap_mb': i_info['swap_mb'],
'ephemeral_mb': 1024 * int(i_info['ephemeral_gb']), 'ephemeral_mb': i_info['ephemeral_mb'],
'preserve_ephemeral': i_info['preserve_ephemeral'], 'preserve_ephemeral': i_info['preserve_ephemeral'],
'boot_option': deploy_utils.get_boot_option(node), 'boot_option': deploy_utils.get_boot_option(node),
'boot_mode': _get_boot_mode(node)}) 'boot_mode': _get_boot_mode(node)})

View File

@ -2125,6 +2125,7 @@ class InstanceInfoTestCase(db_base.DbTestCase):
def test_parse_instance_info_valid_ephemeral_gb(self): def test_parse_instance_info_valid_ephemeral_gb(self):
ephemeral_gb = 10 ephemeral_gb = 10
ephemeral_mb = 1024 * ephemeral_gb
ephemeral_fmt = 'test-fmt' ephemeral_fmt = 'test-fmt'
info = dict(INST_INFO_DICT) info = dict(INST_INFO_DICT)
info['ephemeral_gb'] = ephemeral_gb info['ephemeral_gb'] = ephemeral_gb
@ -2134,7 +2135,7 @@ class InstanceInfoTestCase(db_base.DbTestCase):
driver_internal_info=DRV_INTERNAL_INFO_DICT, driver_internal_info=DRV_INTERNAL_INFO_DICT,
) )
data = utils.parse_instance_info(node) data = utils.parse_instance_info(node)
self.assertEqual(ephemeral_gb, data['ephemeral_gb']) self.assertEqual(ephemeral_mb, data['ephemeral_mb'])
self.assertEqual(ephemeral_fmt, data['ephemeral_format']) self.assertEqual(ephemeral_fmt, data['ephemeral_format'])
def test_parse_instance_info_unicode_swap_mb(self): def test_parse_instance_info_unicode_swap_mb(self):
@ -2308,9 +2309,9 @@ class InstanceInfoTestCase(db_base.DbTestCase):
) )
instance_info = utils.parse_instance_info(node) instance_info = utils.parse_instance_info(node)
self.assertIsNotNone(instance_info['image_source']) self.assertIsNotNone(instance_info['image_source'])
self.assertIsNotNone(instance_info['root_gb']) self.assertIsNotNone(instance_info['root_mb'])
self.assertEqual(0, instance_info['swap_mb']) self.assertEqual(0, instance_info['swap_mb'])
self.assertEqual(0, instance_info['ephemeral_gb']) self.assertEqual(0, instance_info['ephemeral_mb'])
self.assertIsNone(instance_info['configdrive']) self.assertIsNone(instance_info['configdrive'])
def test_parse_instance_info_whole_disk_image_missing_root(self): def test_parse_instance_info_whole_disk_image_missing_root(self):

View File

@ -0,0 +1,5 @@
---
fixes:
- Fixed a bug where the ironic python agent ramdisk was not creating an
ephemeral partition because the ephemeral partition size was not being
passed correctly to the agent.