def test__cleanup_deploy_good(self, mock_update, mock_flavor): mock_flavor.return_value = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver="fake", instance_uuid="fake-id") instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) self.driver._cleanup_deploy(node, instance, None) expected_patch = [{"path": "/instance_uuid", "op": "remove"}] mock_update.assert_called_once_with(node.uuid, expected_patch)
def test_pxe_get_deploy_patch_fail_no_kr_id(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='pxe_fake') instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) self.assertRaises(exception.InvalidParameterValue, patcher.create(node).get_deploy_patch, instance, self.image_meta, self.flavor)
def test_pxe_get_cleanup_patch_no_flavor_kernel_ramdisk_ids(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='pxe_fake') patch = patcher.create(node).get_cleanup_patch(self.instance, None, self.flavor) # If there's no extra_specs patch should be exactly like a # generic patch self.assertEqual(self._expected_cleanup_patch, patch)
def test_pxe_get_deploy_patch_no_flavor_kernel_ramdisk_ids(self): flavor = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='pxe_fake') patch = patcher.create(node).get_deploy_patch( self.instance, self.image_meta, flavor) # If there's no extra_specs patch should be exactly like a # generic patch self.assertEqual(sorted(self._expected_deploy_patch), sorted(patch))
def test__cleanup_deploy_fail(self, mock_update, mock_flavor): mock_flavor.return_value = ironic_utils.get_test_flavor(extra_specs={}) mock_update.side_effect = ironic_exception.BadRequest() node = ironic_utils.get_test_node(driver='fake', instance_uuid='fake-id') instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) self.assertRaises(exception.InstanceTerminationFailure, self.driver._cleanup_deploy, node, instance, None)
def test__cleanup_deploy_good(self, mock_update, mock_flavor): mock_flavor.return_value = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='fake', instance_uuid='fake-id') instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) self.driver._cleanup_deploy(node, instance, None) expected_patch = [{'path': '/instance_uuid', 'op': 'remove'}] mock_update.assert_called_once_with(node.uuid, expected_patch)
def test_pxe_get_cleanup_patch_no_flavor_kernel_ramdisk_ids(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) driver_info = {'pxe_deploy_kernel': 'fake-kernel-id', 'pxe_deploy_ramdisk': 'fake-ramdisk-id'} node = ironic_utils.get_test_node(driver='pxe_fake', driver_info=driver_info) instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) patch = patcher.create(node).get_cleanup_patch(instance, None, self.flavor) self.assertEqual([], patch)
def test_pxe_get_cleanup_patch_no_flavor_kernel_ramdisk_ids(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) driver_info = { 'pxe_deploy_kernel': 'fake-kernel-id', 'pxe_deploy_ramdisk': 'fake-ramdisk-id' } node = ironic_utils.get_test_node(driver='pxe_fake', driver_info=driver_info) instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) patch = patcher.create(node).get_cleanup_patch(instance, None, self.flavor) self.assertEqual([], patch)
def test_pxe_get_deploy_patch_no_flavor_kernel_ramdisk_ids(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='pxe_fake') instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) expected = [{'path': '/instance_info/image_source', 'value': self.image_meta['id'], 'op': 'add'}, {'path': '/instance_info/root_gb', 'value': str(instance['root_gb']), 'op': 'add'}, {'path': '/instance_info/swap_mb', 'value': str(self.flavor['swap']), 'op': 'add'}] patch = patcher.create(node).get_deploy_patch( instance, self.image_meta, self.flavor) self.assertEqual(sorted(expected), sorted(patch))
def setUp(self): super(IronicDriverFieldsTestCase, self).setUp() self.image_meta = ironic_utils.get_test_image_meta() self.flavor = ironic_utils.get_test_flavor() self.ctx = nova_context.get_admin_context() self.instance = fake_instance.fake_instance_obj(self.ctx) # Generic expected patches self._expected_deploy_patch = [{'path': '/instance_info/image_source', 'value': self.image_meta['id'], 'op': 'add'}, {'path': '/instance_info/root_gb', 'value': str(self.instance['root_gb']), 'op': 'add'}, {'path': '/instance_info/swap_mb', 'value': str(self.flavor['swap']), 'op': 'add'}] self._expected_cleanup_patch = []
def test_pxe_get_deploy_patch_no_flavor_kernel_ramdisk_ids(self): self.flavor = ironic_utils.get_test_flavor(extra_specs={}) node = ironic_utils.get_test_node(driver='pxe_fake') instance = fake_instance.fake_instance_obj(self.ctx, node=node.uuid) expected = [{ 'path': '/instance_info/image_source', 'value': self.image_meta['id'], 'op': 'add' }, { 'path': '/instance_info/root_gb', 'value': str(instance['root_gb']), 'op': 'add' }, { 'path': '/instance_info/swap_mb', 'value': str(self.flavor['swap']), 'op': 'add' }] patch = patcher.create(node).get_deploy_patch(instance, self.image_meta, self.flavor) self.assertEqual(sorted(expected), sorted(patch))
def setUp(self): super(IronicDriverFieldsTestCase, self).setUp() self.image_meta = ironic_utils.get_test_image_meta() self.flavor = ironic_utils.get_test_flavor() self.ctx = nova_context.get_admin_context()