Exemplo n.º 1
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.º 2
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.º 3
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.º 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_show_ironic_no_interfaces(self, mock_get, mock_list_ports):
        properties = {'cpus': 1, 'memory_mb': 512, 'local_gb': 10}
        node = ironic_utils.get_test_node(properties=properties)
        mock_get.return_value = node
        mock_list_ports.return_value = []

        res_dict = self.controller.show(self.request, node.uuid)
        self.assertEqual([], res_dict['node']['interfaces'])
        mock_get.assert_called_once_with(node.uuid)
        mock_list_ports.assert_called_once_with(node.uuid)
Exemplo n.º 6
0
 def test_generic_get_deploy_patch_capabilities_nested_key(self):
     node = ironic_utils.get_test_node(driver='fake')
     self.flavor['extra_specs']['capabilities:key1:key2'] = '<in> bios'
     expected = [{'path': '/instance_info/capabilities',
                  'value': '{"key1:key2": "<in> bios"}',
                  'op': 'add'}]
     expected += self._expected_deploy_patch
     patch = patcher.create(node).get_deploy_patch(
             self.instance, self.image_meta, self.flavor)
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 7
0
 def test_generic_get_deploy_patch_preserve_ephemeral(self):
     node = ironic_utils.get_test_node(driver='fake')
     for preserve in [True, False]:
         patch = patcher.create(node).get_deploy_patch(
                 self.instance, self.image_meta, self.flavor,
                 preserve_ephemeral=preserve)
         expected = [{'path': '/instance_info/preserve_ephemeral',
                      'value': str(preserve), 'op': 'add', }]
         expected += self._expected_deploy_patch
         self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 8
0
 def test_pxe_get_cleanup_patch(self):
     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)
     patch = patcher.create(node).get_cleanup_patch(self.instance, None,
                                                    self.flavor)
     expected = [{'path': '/driver_info/pxe_deploy_kernel',
                  'op': 'remove'},
                 {'path': '/driver_info/pxe_deploy_ramdisk',
                  'op': 'remove'}]
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 9
0
 def test_pxe_get_deploy_patch(self):
     node = ironic_utils.get_test_node(driver='pxe_fake')
     extra_specs = self.flavor['extra_specs']
     expected = [{'path': '/driver_info/pxe_deploy_kernel',
                  'value': extra_specs['baremetal:deploy_kernel_id'],
                  'op': 'add'},
                 {'path': '/driver_info/pxe_deploy_ramdisk',
                  'value': extra_specs['baremetal:deploy_ramdisk_id'],
                  'op': 'add'}]
     expected += self._expected_deploy_patch
     patch = patcher.create(node).get_deploy_patch(
             self.instance, self.image_meta, self.flavor)
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 10
0
 def test_generic_get_deploy_patch_capabilities_nested_key(self):
     node = ironic_utils.get_test_node(driver='fake')
     self.flavor['extra_specs']['capabilities:key1:key2'] = '<in> bios'
     expected = [{
         'path': '/instance_info/capabilities',
         'value': '{"key1:key2": "<in> bios"}',
         'op': 'add'
     }]
     expected += self._expected_deploy_patch
     patch = patcher.create(node).get_deploy_patch(self.instance,
                                                   self.image_meta,
                                                   self.flavor)
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 11
0
 def test_generic_get_deploy_patch_preserve_ephemeral(self):
     node = ironic_utils.get_test_node(driver='fake')
     for preserve in [True, False]:
         patch = patcher.create(node).get_deploy_patch(
             self.instance,
             self.image_meta,
             self.flavor,
             preserve_ephemeral=preserve)
         expected = [{
             'path': '/instance_info/preserve_ephemeral',
             'value': str(preserve),
             'op': 'add',
         }]
         expected += self._expected_deploy_patch
         self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 12
0
 def test_generic_get_deploy_patch_ephemeral(self):
     CONF.set_override('default_ephemeral_format', 'testfmt')
     node = ironic_utils.get_test_node(driver='fake')
     instance = fake_instance.fake_instance_obj(self.ctx,
                                                ephemeral_gb=10)
     patch = patcher.create(node).get_deploy_patch(
             instance, self.image_meta, self.flavor)
     expected = [{'path': '/instance_info/ephemeral_gb',
                  'value': str(instance.ephemeral_gb),
                  'op': 'add'},
                 {'path': '/instance_info/ephemeral_format',
                  'value': 'testfmt',
                  'op': 'add'}]
     expected += self._expected_deploy_patch
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 13
0
    def test_index_ironic(self, mock_list):
        properties = {'cpus': 2, 'memory_mb': 1024, 'local_gb': 20}
        node = ironic_utils.get_test_node(properties=properties)
        mock_list.return_value = [node]

        res_dict = self.controller.index(self.request)
        expected_output = {'nodes':
                            [{'memory_mb': properties['memory_mb'],
                             'host': 'IRONIC MANAGED',
                             'disk_gb': properties['local_gb'],
                             'interfaces': [],
                             'task_state': None,
                             'id': node.uuid,
                             'cpus': properties['cpus']}]}
        self.assertEqual(expected_output, res_dict)
        mock_list.assert_called_once_with(detail=True)
Exemplo n.º 14
0
 def test_pxe_get_cleanup_patch(self):
     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)
     patch = patcher.create(node).get_cleanup_patch(self.instance, None,
                                                    self.flavor)
     expected = [{
         'path': '/driver_info/pxe_deploy_kernel',
         'op': 'remove'
     }, {
         'path': '/driver_info/pxe_deploy_ramdisk',
         'op': 'remove'
     }]
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 15
0
 def test_pxe_get_deploy_patch(self):
     node = ironic_utils.get_test_node(driver='pxe_fake')
     extra_specs = self.flavor['extra_specs']
     expected = [{
         'path': '/driver_info/pxe_deploy_kernel',
         'value': extra_specs['baremetal:deploy_kernel_id'],
         'op': 'add'
     }, {
         'path': '/driver_info/pxe_deploy_ramdisk',
         'value': extra_specs['baremetal:deploy_ramdisk_id'],
         'op': 'add'
     }]
     expected += self._expected_deploy_patch
     patch = patcher.create(node).get_deploy_patch(self.instance,
                                                   self.image_meta,
                                                   self.flavor)
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 16
0
 def test_generic_get_deploy_patch_ephemeral(self):
     CONF.set_override('default_ephemeral_format', 'testfmt')
     node = ironic_utils.get_test_node(driver='fake')
     instance = fake_instance.fake_instance_obj(self.ctx, ephemeral_gb=10)
     patch = patcher.create(node).get_deploy_patch(instance,
                                                   self.image_meta,
                                                   self.flavor)
     expected = [{
         'path': '/instance_info/ephemeral_gb',
         'value': str(instance.ephemeral_gb),
         'op': 'add'
     }, {
         'path': '/instance_info/ephemeral_format',
         'value': 'testfmt',
         'op': 'add'
     }]
     expected += self._expected_deploy_patch
     self.assertEqual(sorted(expected), sorted(patch))
Exemplo n.º 17
0
    def test_show_ironic_no_properties(self, mock_get, mock_list_ports):
        properties = {}
        node = ironic_utils.get_test_node(properties=properties)
        port = ironic_utils.get_test_port()
        mock_get.return_value = node
        mock_list_ports.return_value = [port]

        res_dict = self.controller.show(self.request, node.uuid)
        expected_output = {'node':
                            {'memory_mb': 0,
                             'instance_uuid': None,
                             'host': 'IRONIC MANAGED',
                             'disk_gb': 0,
                             'interfaces': [{'address': port.address}],
                             'task_state': None,
                             'id': node.uuid,
                             'cpus': 0}}
        self.assertEqual(expected_output, res_dict)
        mock_get.assert_called_once_with(node.uuid)
        mock_list_ports.assert_called_once_with(node.uuid)
Exemplo n.º 18
0
 def test_show_ironic_not_implemented(self):
     with mock.patch.object(self.mod, 'ironic_client', None):
         properties = {'cpus': 1, 'memory_mb': 512, 'local_gb': 10}
         node = ironic_utils.get_test_node(properties=properties)
         self.assertRaises(exc.HTTPNotImplemented, self.controller.show,
                           self.request, node.uuid)
Exemplo n.º 19
0
 def test_generic_get_cleanup_patch(self):
     node = ironic_utils.get_test_node(driver='fake')
     patch = patcher.create(node).get_cleanup_patch(self.instance, None,
                                                    self.flavor)
     self.assertEqual(self._expected_cleanup_patch, patch)
Exemplo n.º 20
0
 def test_generic_get_deploy_patch(self):
     node = ironic_utils.get_test_node(driver='fake')
     patch = patcher.create(node).get_deploy_patch(
             self.instance, self.image_meta, self.flavor)
     self.assertEqual(sorted(self._expected_deploy_patch), sorted(patch))
Exemplo n.º 21
0
 def test_create_pxe(self):
     node = ironic_utils.get_test_node(driver='pxe_fake')
     patcher_obj = patcher.create(node)
     self.assertIsInstance(patcher_obj, patcher.PXEDriverFields)
Exemplo n.º 22
0
 def test_create_generic(self):
     node = ironic_utils.get_test_node(driver='fake')
     patcher_obj = patcher.create(node)
     self.assertIsInstance(patcher_obj, patcher.GenericDriverFields)
Exemplo n.º 23
0
 def test_create_generic(self):
     node = ironic_utils.get_test_node(driver='fake')
     patcher_obj = patcher.create(node)
     self.assertIsInstance(patcher_obj, patcher.GenericDriverFields)
Exemplo n.º 24
0
 def test_create_pxe(self):
     node = ironic_utils.get_test_node(driver='pxe_fake')
     patcher_obj = patcher.create(node)
     self.assertIsInstance(patcher_obj, patcher.PXEDriverFields)
Exemplo n.º 25
0
 def test_generic_get_deploy_patch(self):
     node = ironic_utils.get_test_node(driver='fake')
     patch = patcher.create(node).get_deploy_patch(self.instance,
                                                   self.image_meta,
                                                   self.flavor)
     self.assertEqual(sorted(self._expected_deploy_patch), sorted(patch))
Exemplo n.º 26
0
 def test_generic_get_cleanup_patch(self):
     node = ironic_utils.get_test_node(driver='fake')
     patch = patcher.create(node).get_cleanup_patch(self.instance, None,
                                                    self.flavor)
     self.assertEqual(self._expected_cleanup_patch, patch)