Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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))
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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))
Exemplo n.º 12
0
 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 = []
Exemplo n.º 13
0
 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))
Exemplo n.º 14
0
 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()
Exemplo n.º 15
0
 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()