Exemple #1
0
    def test__get_boot_iso_glance_image(self, deploy_info_mock,
                                        image_props_mock):
        deploy_info_mock.return_value = {
            'image_source': 'image-uuid',
            'ilo_deploy_iso': 'deploy_iso_uuid'
        }
        image_props_mock.return_value = {
            'boot_iso': u'glance://uui\u0111',
            'kernel_id': None,
            'ramdisk_id': None
        }

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info['boot_iso_created_in_web_server'] = False
            task.node.driver_internal_info = driver_internal_info
            task.node.save()
            boot_iso_actual = ilo_boot._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_iso_expected = u'glance://uui\u0111'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Exemple #2
0
    def test__get_boot_iso_uefi_no_glance_image(self, deploy_info_mock,
                                                image_props_mock, log_mock,
                                                boot_mode_mock):
        deploy_info_mock.return_value = {
            'image_source': 'image-uuid',
            'ilo_deploy_iso': 'deploy_iso_uuid'
        }
        image_props_mock.return_value = {
            'boot_iso': None,
            'kernel_id': None,
            'ramdisk_id': None
        }
        properties = {'capabilities': 'boot_mode:uefi'}

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            task.node.properties = properties
            boot_iso_result = ilo_boot._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'])
            self.assertTrue(log_mock.called)
            self.assertFalse(boot_mode_mock.called)
            self.assertIsNone(boot_iso_result)
Exemple #3
0
    def test__get_boot_iso_recreate_boot_iso_use_webserver(
        self,
        deploy_info_mock,
        image_props_mock,
        capability_mock,
        boot_object_name_mock,
        create_boot_iso_mock,
        tempfile_mock,
        copy_file_mock,
    ):
        CONF.ilo.swift_ilo_container = "ilo-cont"
        CONF.ilo.use_web_server_for_images = True
        CONF.deploy.http_url = "http://10.10.1.30/httpboot"
        CONF.deploy.http_root = "/httpboot"
        CONF.pxe.pxe_append_params = "kernel-params"

        fileobj_mock = mock.MagicMock(spec=file)
        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

        ramdisk_href = "http://10.10.1.30/httpboot/ramdisk"
        kernel_href = "http://10.10.1.30/httpboot/kernel"
        deploy_info_mock.return_value = {"image_source": "image-uuid", "ilo_deploy_iso": "deploy_iso_uuid"}
        image_props_mock.return_value = {"boot_iso": None, "kernel_id": kernel_href, "ramdisk_id": ramdisk_href}
        boot_object_name_mock.return_value = "new_boot_iso"
        create_boot_iso_mock.return_value = "/path/to/boot-iso"
        capability_mock.return_value = "uefi"
        copy_file_mock.return_value = "http://10.10.1.30/httpboot/new_boot_iso"

        with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info["boot_iso_created_in_web_server"] = True
            instance_info = task.node.instance_info
            old_boot_iso = "http://10.10.1.30/httpboot/old_boot_iso"
            instance_info["ilo_boot_iso"] = old_boot_iso
            boot_iso_actual = ilo_boot._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_href,
                ramdisk_href,
                "deploy_iso_uuid",
                "root-uuid",
                "kernel-params",
                "uefi",
            )
            boot_iso_expected = "http://10.10.1.30/httpboot/new_boot_iso"
            self.assertEqual(boot_iso_expected, boot_iso_actual)
            copy_file_mock.assert_called_once_with(fileobj_mock.name, "new_boot_iso")
Exemple #4
0
    def test__get_boot_iso_recreate_boot_iso_use_webserver(
            self, deploy_info_mock, image_props_mock,
            capability_mock, boot_object_name_mock,
            create_boot_iso_mock, tempfile_mock,
            copy_file_mock):
        CONF.ilo.swift_ilo_container = 'ilo-cont'
        CONF.ilo.use_web_server_for_images = True
        CONF.deploy.http_url = "http://10.10.1.30/httpboot"
        CONF.deploy.http_root = "/httpboot"
        CONF.pxe.pxe_append_params = 'kernel-params'

        fileobj_mock = mock.MagicMock(spec=file)
        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

        ramdisk_href = "http://10.10.1.30/httpboot/ramdisk"
        kernel_href = "http://10.10.1.30/httpboot/kernel"
        deploy_info_mock.return_value = {'image_source': 'image-uuid',
                                         'ilo_deploy_iso': 'deploy_iso_uuid'}
        image_props_mock.return_value = {'boot_iso': None,
                                         'kernel_id': kernel_href,
                                         'ramdisk_id': ramdisk_href}
        boot_object_name_mock.return_value = 'new_boot_iso'
        create_boot_iso_mock.return_value = '/path/to/boot-iso'
        capability_mock.return_value = 'uefi'
        copy_file_mock.return_value = "http://10.10.1.30/httpboot/new_boot_iso"

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info['boot_iso_created_in_web_server'] = True
            instance_info = task.node.instance_info
            old_boot_iso = 'http://10.10.1.30/httpboot/old_boot_iso'
            instance_info['ilo_boot_iso'] = old_boot_iso
            boot_iso_actual = ilo_boot._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_href,
                                                         ramdisk_href,
                                                         'deploy_iso_uuid',
                                                         'root-uuid',
                                                         'kernel-params',
                                                         'uefi')
            boot_iso_expected = 'http://10.10.1.30/httpboot/new_boot_iso'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
            copy_file_mock.assert_called_once_with(fileobj_mock.name,
                                                   'new_boot_iso')
Exemple #5
0
    def test__get_boot_iso_http_url(self, service_mock):
        url = "http://abc.org/image/qcow2"
        i_info = self.node.instance_info
        i_info["ilo_boot_iso"] = url
        self.node.instance_info = i_info
        self.node.save()

        with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
            boot_iso_actual = ilo_boot._get_boot_iso(task, "root-uuid")
            service_mock.assert_called_once_with(mock.ANY, url)
            self.assertEqual(url, boot_iso_actual)
Exemple #6
0
    def test__get_boot_iso_recreate_boot_iso_use_webserver(
            self, deploy_info_mock, image_props_mock,
            capability_mock, boot_object_name_mock,
            create_boot_iso_mock, tempfile_mock,
            copy_file_mock):
        CONF.ilo.swift_ilo_container = 'ilo-cont'
        CONF.ilo.use_web_server_for_images = True
        CONF.deploy.http_url = "http://10.10.1.30/httpboot"
        CONF.deploy.http_root = "/httpboot"
        CONF.pxe.pxe_append_params = 'kernel-params'

        fileobj_mock = mock.MagicMock(spec=file)
        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

        ramdisk_href = "http://10.10.1.30/httpboot/ramdisk"
        kernel_href = "http://10.10.1.30/httpboot/kernel"
        deploy_info_mock.return_value = {'image_source': 'image-uuid',
                                         'ilo_deploy_iso': 'deploy_iso_uuid'}
        image_props_mock.return_value = {'boot_iso': None,
                                         'kernel_id': kernel_href,
                                         'ramdisk_id': ramdisk_href}
        boot_object_name_mock.return_value = 'new_boot_iso'
        create_boot_iso_mock.return_value = '/path/to/boot-iso'
        capability_mock.return_value = 'uefi'
        copy_file_mock.return_value = "http://10.10.1.30/httpboot/new_boot_iso"

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info['boot_iso_created_in_web_server'] = True
            instance_info = task.node.instance_info
            old_boot_iso = 'http://10.10.1.30/httpboot/old_boot_iso'
            instance_info['ilo_boot_iso'] = old_boot_iso
            boot_iso_actual = ilo_boot._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_href,
                                                         ramdisk_href,
                                                         'deploy_iso_uuid',
                                                         'root-uuid',
                                                         'kernel-params',
                                                         'uefi')
            boot_iso_expected = 'http://10.10.1.30/httpboot/new_boot_iso'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
            copy_file_mock.assert_called_once_with(fileobj_mock.name,
                                                   'new_boot_iso')
Exemple #7
0
    def test__get_boot_iso_http_url(self, service_mock):
        url = 'http://abc.org/image/qcow2'
        i_info = self.node.instance_info
        i_info['ilo_boot_iso'] = url
        self.node.instance_info = i_info
        self.node.save()

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_boot._get_boot_iso(task, 'root-uuid')
            service_mock.assert_called_once_with(mock.ANY, url)
            self.assertEqual(url, boot_iso_actual)
Exemple #8
0
    def test__get_boot_iso_uefi_no_glance_image(self, deploy_info_mock, image_props_mock, log_mock, boot_mode_mock):
        deploy_info_mock.return_value = {"image_source": "image-uuid", "ilo_deploy_iso": "deploy_iso_uuid"}
        image_props_mock.return_value = {"boot_iso": None, "kernel_id": None, "ramdisk_id": None}
        properties = {"capabilities": "boot_mode:uefi"}

        with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
            task.node.properties = properties
            boot_iso_result = ilo_boot._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"]
            )
            self.assertTrue(log_mock.called)
            self.assertFalse(boot_mode_mock.called)
            self.assertIsNone(boot_iso_result)
Exemple #9
0
    def test__get_boot_iso_glance_image(self, deploy_info_mock, image_props_mock):
        deploy_info_mock.return_value = {"image_source": "image-uuid", "ilo_deploy_iso": "deploy_iso_uuid"}
        image_props_mock.return_value = {"boot_iso": u"glance://uui\u0111", "kernel_id": None, "ramdisk_id": None}

        with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info["boot_iso_created_in_web_server"] = False
            task.node.driver_internal_info = driver_internal_info
            task.node.save()
            boot_iso_actual = ilo_boot._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_iso_expected = u"glance://uui\u0111"
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Exemple #10
0
    def test__get_boot_iso_create(
        self,
        deploy_info_mock,
        image_props_mock,
        capability_mock,
        boot_object_name_mock,
        swift_api_mock,
        create_boot_iso_mock,
        tempfile_mock,
    ):
        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(spec=file)
        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", "ilo_deploy_iso": "deploy_iso_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"
        capability_mock.return_value = "uefi"
        with task_manager.acquire(self.context, self.node.uuid, shared=False) as task:
            boot_iso_actual = ilo_boot._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",
                "deploy_iso_uuid",
                "root-uuid",
                "kernel-params",
                "uefi",
            )
            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)
Exemple #11
0
    def test__get_boot_iso_create(self, deploy_info_mock, image_props_mock,
                                  capability_mock, boot_object_name_mock,
                                  swift_api_mock,
                                  create_boot_iso_mock, tempfile_mock):
        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(spec=file)
        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',
                                         'ilo_deploy_iso': 'deploy_iso_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'
        capability_mock.return_value = 'uefi'
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_boot._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',
                                                         'deploy_iso_uuid',
                                                         'root-uuid',
                                                         'kernel-params',
                                                         'uefi')
            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)
Exemple #12
0
    def test__get_boot_iso_create(self, deploy_info_mock, image_props_mock,
                                  capability_mock, boot_object_name_mock,
                                  swift_api_mock,
                                  create_boot_iso_mock, tempfile_mock):
        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(spec=file)
        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',
                                         'ilo_deploy_iso': 'deploy_iso_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'
        capability_mock.return_value = 'uefi'
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            boot_iso_actual = ilo_boot._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',
                                                         'deploy_iso_uuid',
                                                         'root-uuid',
                                                         'kernel-params',
                                                         'uefi')
            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)
Exemple #13
0
    def test__get_boot_iso_glance_image(self, deploy_info_mock,
                                        image_props_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid',
                                         'ilo_deploy_iso': 'deploy_iso_uuid'}
        image_props_mock.return_value = {'boot_iso': u'glance://uui\u0111',
                                         'kernel_id': None,
                                         'ramdisk_id': None}

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            driver_internal_info = task.node.driver_internal_info
            driver_internal_info['boot_iso_created_in_web_server'] = False
            task.node.driver_internal_info = driver_internal_info
            task.node.save()
            boot_iso_actual = ilo_boot._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_iso_expected = u'glance://uui\u0111'
            self.assertEqual(boot_iso_expected, boot_iso_actual)
Exemple #14
0
    def test__get_boot_iso_uefi_no_glance_image(self,
                                                deploy_info_mock,
                                                image_props_mock,
                                                log_mock,
                                                boot_mode_mock):
        deploy_info_mock.return_value = {'image_source': 'image-uuid',
                                         'ilo_deploy_iso': 'deploy_iso_uuid'}
        image_props_mock.return_value = {'boot_iso': None,
                                         'kernel_id': None,
                                         'ramdisk_id': None}
        properties = {'capabilities': 'boot_mode:uefi'}

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            task.node.properties = properties
            boot_iso_result = ilo_boot._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'])
            self.assertTrue(log_mock.called)
            self.assertFalse(boot_mode_mock.called)
            self.assertIsNone(boot_iso_result)