Esempio n. 1
0
    def test__get_boot_iso_glance_image(self, deploy_info_mock,
            image_prop_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_prop_mock.return_value = 'boot-iso-uuid'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_prop_mock.assert_called_once_with(task.context, 'image-uuid',
                'boot_iso')
            boot_iso_expected = 'glance:boot-iso-uuid'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Esempio n. 2
0
    def test__get_boot_iso_glance_image(self, deploy_info_mock,
                                        image_prop_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_prop_mock.return_value = 'boot-iso-uuid'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_prop_mock.assert_called_once_with(task.context, 'image-uuid',
                                                    'boot_iso')
            boot_iso_expected = 'glance:boot-iso-uuid'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Esempio n. 3
0
    def test__get_boot_iso_uefi_no_glance_image(self, deploy_info_mock,
            image_prop_mock, get_node_cap_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_prop_mock.return_value = None
        get_node_cap_mock.return_value = 'uefi'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_result = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_prop_mock.assert_called_once_with(task.context, 'image-uuid',
                'boot_iso')
            get_node_cap_mock.assert_called_once_with(task.node, 'boot_mode')
            self.assertIsNone(boot_iso_result)
Esempio n. 4
0
    def test__get_boot_iso_uefi_no_glance_image(self, deploy_info_mock,
                                                image_prop_mock,
                                                get_node_cap_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_prop_mock.return_value = None
        get_node_cap_mock.return_value = 'uefi'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_result = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_prop_mock.assert_called_once_with(task.context, 'image-uuid',
                                                    'boot_iso')
            get_node_cap_mock.assert_called_once_with(task.node, 'boot_mode')
            self.assertIsNone(boot_iso_result)
Esempio n. 5
0
    def test__get_boot_iso_create(self, deploy_info_mock, image_prop_mock,
                                  boot_object_name_mock, swift_api_mock,
                                  create_boot_iso_mock, tempfile_mock):
        CONF.keystone_authtoken.auth_uri = 'http://authurl'
        CONF.ilo.swift_ilo_container = 'ilo-cont'
        CONF.pxe.pxe_append_params = 'kernel-params'

        swift_obj_mock = swift_api_mock.return_value
        fileobj_mock = mock.MagicMock()
        fileobj_mock.name = 'tmpfile'
        mock_file_handle = mock.MagicMock(spec=file)
        mock_file_handle.__enter__.return_value = fileobj_mock
        tempfile_mock.return_value = mock_file_handle

        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_prop_mock.side_effect = [None, 'kernel-uuid', 'ramdisk-uuid']
        boot_object_name_mock.return_value = 'abcdef'
        create_boot_iso_mock.return_value = '/path/to/boot-iso'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_prop_mock.assert_any_call(task.context, 'image-uuid',
                'boot_iso')
            image_prop_mock.assert_any_call(task.context, 'image-uuid',
                'kernel_id')
            image_prop_mock.assert_any_call(task.context, 'image-uuid',
                'ramdisk_id')
            boot_object_name_mock.assert_called_once_with(task.node)
            create_boot_iso_mock.assert_called_once_with(task.context,
                    'tmpfile', 'kernel-uuid', 'ramdisk-uuid',
                    'root-uuid', 'kernel-params')
            swift_obj_mock.create_object.assert_called_once_with('ilo-cont',
                                                                 'abcdef',
                                                                 'tmpfile')
            boot_iso_expected = 'swift:abcdef'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Esempio n. 6
0
    def test__get_boot_iso_create(self, deploy_info_mock, image_props_mock,
                                  boot_object_name_mock, swift_api_mock,
                                  create_boot_iso_mock, tempfile_mock):
        CONF.keystone_authtoken.auth_uri = 'http://authurl'
        CONF.ilo.swift_ilo_container = 'ilo-cont'
        CONF.pxe.pxe_append_params = 'kernel-params'

        swift_obj_mock = swift_api_mock.return_value
        fileobj_mock = mock.MagicMock()
        fileobj_mock.name = 'tmpfile'
        mock_file_handle = mock.MagicMock(spec=file)
        mock_file_handle.__enter__.return_value = fileobj_mock
        tempfile_mock.return_value = mock_file_handle

        deploy_info_mock.return_value = {'image_source': 'image-uuid'}
        image_props_mock.return_value = {
            'boot_iso': None,
            'kernel_id': 'kernel_uuid',
            'ramdisk_id': 'ramdisk_uuid'
        }
        boot_object_name_mock.return_value = 'abcdef'
        create_boot_iso_mock.return_value = '/path/to/boot-iso'

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_deploy._get_boot_iso(task, 'root-uuid')
            deploy_info_mock.assert_called_once_with(task.node)
            image_props_mock.assert_called_once_with(
                task.context, 'image-uuid',
                ['boot_iso', 'kernel_id', 'ramdisk_id'])
            boot_object_name_mock.assert_called_once_with(task.node)
            create_boot_iso_mock.assert_called_once_with(
                task.context, 'tmpfile', 'kernel_uuid', 'ramdisk_uuid',
                'root-uuid', 'kernel-params')
            swift_obj_mock.create_object.assert_called_once_with(
                'ilo-cont', 'abcdef', 'tmpfile')
            boot_iso_expected = 'swift:abcdef'
            self.assertEqual(boot_iso_expected, boot_iso_actual)