Merge "Move testcases related to parse_instance_info()"
This commit is contained in:
commit
16bf176332
@ -2032,3 +2032,252 @@ class ValidateParametersTestCase(db_base.DbTestCase):
|
||||
|
||||
self._test__get_img_instance_info(
|
||||
driver_internal_info=driver_internal_info)
|
||||
|
||||
|
||||
class InstanceInfoTestCase(db_base.DbTestCase):
|
||||
|
||||
def test_parse_instance_info_good(self):
|
||||
# make sure we get back the expected things
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, driver='fake_pxe',
|
||||
instance_info=INST_INFO_DICT,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT
|
||||
)
|
||||
info = utils.parse_instance_info(node)
|
||||
self.assertIsNotNone(info.get('image_source'))
|
||||
self.assertIsNotNone(info.get('root_gb'))
|
||||
self.assertEqual(0, info.get('ephemeral_gb'))
|
||||
self.assertIsNone(info.get('configdrive'))
|
||||
|
||||
def test_parse_instance_info_missing_instance_source(self):
|
||||
# make sure error is raised when info is missing
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['image_source']
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_missing_root_gb(self):
|
||||
# make sure error is raised when info is missing
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['root_gb']
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_invalid_root_gb(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['root_gb'] = 'foobar'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_valid_ephemeral_gb(self):
|
||||
ephemeral_gb = 10
|
||||
ephemeral_fmt = 'test-fmt'
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = ephemeral_gb
|
||||
info['ephemeral_format'] = ephemeral_fmt
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = utils.parse_instance_info(node)
|
||||
self.assertEqual(ephemeral_gb, data.get('ephemeral_gb'))
|
||||
self.assertEqual(ephemeral_fmt, data.get('ephemeral_format'))
|
||||
|
||||
def test_parse_instance_info_unicode_swap_mb(self):
|
||||
swap_mb = u'10'
|
||||
swap_mb_int = 10
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['swap_mb'] = swap_mb
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = utils.parse_instance_info(node)
|
||||
self.assertEqual(swap_mb_int, data.get('swap_mb'))
|
||||
|
||||
def test_parse_instance_info_invalid_ephemeral_gb(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 'foobar'
|
||||
info['ephemeral_format'] = 'exttest'
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_valid_ephemeral_missing_format(self):
|
||||
ephemeral_gb = 10
|
||||
ephemeral_fmt = 'test-fmt'
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = ephemeral_gb
|
||||
info['ephemeral_format'] = None
|
||||
self.config(default_ephemeral_format=ephemeral_fmt, group='pxe')
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
instance_info = utils.parse_instance_info(node)
|
||||
self.assertEqual(ephemeral_fmt, instance_info['ephemeral_format'])
|
||||
|
||||
def test_parse_instance_info_valid_preserve_ephemeral_true(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
for opt in ['true', 'TRUE', 'True', 't',
|
||||
'on', 'yes', 'y', '1']:
|
||||
info['preserve_ephemeral'] = opt
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, uuid=uuidutils.generate_uuid(),
|
||||
instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = utils.parse_instance_info(node)
|
||||
self.assertTrue(data.get('preserve_ephemeral'))
|
||||
|
||||
def test_parse_instance_info_valid_preserve_ephemeral_false(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
for opt in ['false', 'FALSE', 'False', 'f',
|
||||
'off', 'no', 'n', '0']:
|
||||
info['preserve_ephemeral'] = opt
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, uuid=uuidutils.generate_uuid(),
|
||||
instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = utils.parse_instance_info(node)
|
||||
self.assertFalse(data.get('preserve_ephemeral'))
|
||||
|
||||
def test_parse_instance_info_invalid_preserve_ephemeral(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['preserve_ephemeral'] = 'foobar'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_invalid_ephemeral_disk(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 9,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test__check_disk_layout_unchanged_fails(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 20,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils._check_disk_layout_unchanged,
|
||||
node, info)
|
||||
|
||||
def test__check_disk_layout_unchanged(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 10,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertIsNone(utils._check_disk_layout_unchanged(node,
|
||||
info))
|
||||
|
||||
def test_parse_instance_info_configdrive(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['configdrive'] = 'http://1.2.3.4/cd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
instance_info = utils.parse_instance_info(node)
|
||||
self.assertEqual('http://1.2.3.4/cd', instance_info['configdrive'])
|
||||
|
||||
def test_parse_instance_info_nonglance_image(self):
|
||||
info = INST_INFO_DICT.copy()
|
||||
info['image_source'] = 'file:///image.qcow2'
|
||||
info['kernel'] = 'file:///image.vmlinuz'
|
||||
info['ramdisk'] = 'file:///image.initrd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
utils.parse_instance_info(node)
|
||||
|
||||
def test_parse_instance_info_nonglance_image_no_kernel(self):
|
||||
info = INST_INFO_DICT.copy()
|
||||
info['image_source'] = 'file:///image.qcow2'
|
||||
info['ramdisk'] = 'file:///image.initrd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
utils.parse_instance_info, node)
|
||||
|
||||
def test_parse_instance_info_whole_disk_image(self):
|
||||
driver_internal_info = dict(DRV_INTERNAL_INFO_DICT)
|
||||
driver_internal_info['is_whole_disk_image'] = True
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=INST_INFO_DICT,
|
||||
driver_internal_info=driver_internal_info,
|
||||
)
|
||||
instance_info = utils.parse_instance_info(node)
|
||||
self.assertIsNotNone(instance_info.get('image_source'))
|
||||
self.assertIsNotNone(instance_info.get('root_gb'))
|
||||
self.assertEqual(0, instance_info.get('swap_mb'))
|
||||
self.assertEqual(0, instance_info.get('ephemeral_gb'))
|
||||
self.assertIsNone(instance_info.get('configdrive'))
|
||||
|
||||
def test_parse_instance_info_whole_disk_image_missing_root(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['root_gb']
|
||||
node = obj_utils.create_test_node(self.context, instance_info=info)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
utils.parse_instance_info, node)
|
||||
|
@ -52,272 +52,6 @@ DRV_INFO_DICT = db_utils.get_test_pxe_driver_info()
|
||||
DRV_INTERNAL_INFO_DICT = db_utils.get_test_pxe_driver_internal_info()
|
||||
|
||||
|
||||
class IscsiDeployValidateParametersTestCase(db_base.DbTestCase):
|
||||
|
||||
def test_parse_instance_info_good(self):
|
||||
# make sure we get back the expected things
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, driver='fake_pxe',
|
||||
instance_info=INST_INFO_DICT,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT
|
||||
)
|
||||
info = deploy_utils.parse_instance_info(node)
|
||||
self.assertIsNotNone(info.get('image_source'))
|
||||
self.assertIsNotNone(info.get('root_gb'))
|
||||
self.assertEqual(0, info.get('ephemeral_gb'))
|
||||
self.assertIsNone(info.get('configdrive'))
|
||||
|
||||
def test_parse_instance_info_missing_instance_source(self):
|
||||
# make sure error is raised when info is missing
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['image_source']
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_missing_root_gb(self):
|
||||
# make sure error is raised when info is missing
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['root_gb']
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_invalid_root_gb(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['root_gb'] = 'foobar'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_valid_ephemeral_gb(self):
|
||||
ephemeral_gb = 10
|
||||
ephemeral_fmt = 'test-fmt'
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = ephemeral_gb
|
||||
info['ephemeral_format'] = ephemeral_fmt
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = deploy_utils.parse_instance_info(node)
|
||||
self.assertEqual(ephemeral_gb, data.get('ephemeral_gb'))
|
||||
self.assertEqual(ephemeral_fmt, data.get('ephemeral_format'))
|
||||
|
||||
def test_parse_instance_info_unicode_swap_mb(self):
|
||||
swap_mb = u'10'
|
||||
swap_mb_int = 10
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['swap_mb'] = swap_mb
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = deploy_utils.parse_instance_info(node)
|
||||
self.assertEqual(swap_mb_int, data.get('swap_mb'))
|
||||
|
||||
def test_parse_instance_info_invalid_ephemeral_gb(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 'foobar'
|
||||
info['ephemeral_format'] = 'exttest'
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_valid_ephemeral_missing_format(self):
|
||||
ephemeral_gb = 10
|
||||
ephemeral_fmt = 'test-fmt'
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = ephemeral_gb
|
||||
info['ephemeral_format'] = None
|
||||
self.config(default_ephemeral_format=ephemeral_fmt, group='pxe')
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
instance_info = deploy_utils.parse_instance_info(node)
|
||||
self.assertEqual(ephemeral_fmt, instance_info['ephemeral_format'])
|
||||
|
||||
def test_parse_instance_info_valid_preserve_ephemeral_true(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
for opt in ['true', 'TRUE', 'True', 't',
|
||||
'on', 'yes', 'y', '1']:
|
||||
info['preserve_ephemeral'] = opt
|
||||
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, uuid=uuidutils.generate_uuid(),
|
||||
instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = deploy_utils.parse_instance_info(node)
|
||||
self.assertTrue(data.get('preserve_ephemeral'))
|
||||
|
||||
def test_parse_instance_info_valid_preserve_ephemeral_false(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
for opt in ['false', 'FALSE', 'False', 'f',
|
||||
'off', 'no', 'n', '0']:
|
||||
info['preserve_ephemeral'] = opt
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, uuid=uuidutils.generate_uuid(),
|
||||
instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
data = deploy_utils.parse_instance_info(node)
|
||||
self.assertFalse(data.get('preserve_ephemeral'))
|
||||
|
||||
def test_parse_instance_info_invalid_preserve_ephemeral(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['preserve_ephemeral'] = 'foobar'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test_parse_instance_info_invalid_ephemeral_disk(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 9,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils.parse_instance_info,
|
||||
node)
|
||||
|
||||
def test__check_disk_layout_unchanged_fails(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 20,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils._check_disk_layout_unchanged,
|
||||
node, info)
|
||||
|
||||
def test__check_disk_layout_unchanged(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 20
|
||||
info['preserve_ephemeral'] = True
|
||||
drv_internal_dict = {'instance': {'ephemeral_gb': 10,
|
||||
'swap_mb': 0,
|
||||
'root_gb': 20}}
|
||||
drv_internal_dict.update(DRV_INTERNAL_INFO_DICT)
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=drv_internal_dict,
|
||||
)
|
||||
self.assertIsNone(deploy_utils._check_disk_layout_unchanged(node,
|
||||
info))
|
||||
|
||||
def test__save_disk_layout(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 10
|
||||
info['preserve_ephemeral'] = False
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
iscsi_deploy._save_disk_layout(node, info)
|
||||
node.refresh()
|
||||
for param in ('ephemeral_gb', 'swap_mb', 'root_gb'):
|
||||
self.assertEqual(
|
||||
info[param], node.driver_internal_info['instance'][param]
|
||||
)
|
||||
|
||||
def test_parse_instance_info_configdrive(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['configdrive'] = 'http://1.2.3.4/cd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
instance_info = deploy_utils.parse_instance_info(node)
|
||||
self.assertEqual('http://1.2.3.4/cd', instance_info['configdrive'])
|
||||
|
||||
def test_parse_instance_info_nonglance_image(self):
|
||||
info = INST_INFO_DICT.copy()
|
||||
info['image_source'] = 'file:///image.qcow2'
|
||||
info['kernel'] = 'file:///image.vmlinuz'
|
||||
info['ramdisk'] = 'file:///image.initrd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
deploy_utils.parse_instance_info(node)
|
||||
|
||||
def test_parse_instance_info_nonglance_image_no_kernel(self):
|
||||
info = INST_INFO_DICT.copy()
|
||||
info['image_source'] = 'file:///image.qcow2'
|
||||
info['ramdisk'] = 'file:///image.initrd'
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=info,
|
||||
driver_internal_info=DRV_INTERNAL_INFO_DICT,
|
||||
)
|
||||
self.assertRaises(exception.MissingParameterValue,
|
||||
deploy_utils.parse_instance_info, node)
|
||||
|
||||
def test_parse_instance_info_whole_disk_image(self):
|
||||
driver_internal_info = dict(DRV_INTERNAL_INFO_DICT)
|
||||
driver_internal_info['is_whole_disk_image'] = True
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, instance_info=INST_INFO_DICT,
|
||||
driver_internal_info=driver_internal_info,
|
||||
)
|
||||
instance_info = deploy_utils.parse_instance_info(node)
|
||||
self.assertIsNotNone(instance_info.get('image_source'))
|
||||
self.assertIsNotNone(instance_info.get('root_gb'))
|
||||
self.assertEqual(0, instance_info.get('swap_mb'))
|
||||
self.assertEqual(0, instance_info.get('ephemeral_gb'))
|
||||
self.assertIsNone(instance_info.get('configdrive'))
|
||||
|
||||
def test_parse_instance_info_whole_disk_image_missing_root(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
del info['root_gb']
|
||||
node = obj_utils.create_test_node(self.context, instance_info=info)
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
deploy_utils.parse_instance_info, node)
|
||||
|
||||
|
||||
class IscsiDeployPrivateMethodsTestCase(db_base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -331,6 +65,21 @@ class IscsiDeployPrivateMethodsTestCase(db_base.DbTestCase):
|
||||
mgr_utils.mock_the_extension_manager(driver="fake_pxe")
|
||||
self.node = obj_utils.create_test_node(self.context, **n)
|
||||
|
||||
def test__save_disk_layout(self):
|
||||
info = dict(INST_INFO_DICT)
|
||||
info['ephemeral_gb'] = 10
|
||||
info['swap_mb'] = 0
|
||||
info['root_gb'] = 10
|
||||
info['preserve_ephemeral'] = False
|
||||
self.node.instance_info = info
|
||||
|
||||
iscsi_deploy._save_disk_layout(self.node, info)
|
||||
self.node.refresh()
|
||||
for param in ('ephemeral_gb', 'swap_mb', 'root_gb'):
|
||||
self.assertEqual(
|
||||
info[param], self.node.driver_internal_info['instance'][param]
|
||||
)
|
||||
|
||||
def test__get_image_dir_path(self):
|
||||
self.assertEqual(os.path.join(CONF.pxe.images_path,
|
||||
self.node.uuid),
|
||||
|
Loading…
x
Reference in New Issue
Block a user