コード例 #1
0
    def test_ilo5_kernel_param_config(self):
        self.config(kernel_append_params="console=ttyS1", group='ilo')
        img_handler_obj = image_utils.ImageHandler(self.node.driver)
        actual_k_param = img_handler_obj.kernel_params
        expected_k_param = "console=ttyS1"

        self.assertEqual(expected_k_param, actual_k_param)
コード例 #2
0
    def test_unpublish_image_swift(self, mock_swift):
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            img_handler_obj = image_utils.ImageHandler(self.node.driver)
            object_name = 'image-%s' % task.node.uuid

            img_handler_obj.unpublish_image(object_name)

            mock_swift.SwiftAPI.assert_called_once_with()
            mock_swift_api = mock_swift.SwiftAPI.return_value

            mock_swift_api.delete_object.assert_called_once_with(
                'ironic_redfish_container', object_name)
コード例 #3
0
    def test_unpublish_image_local(self, mock_ironic_utils):
        self.config(use_swift=False, group='redfish')
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            img_handler_obj = image_utils.ImageHandler(self.node.driver)
            object_name = 'image-%s' % task.node.uuid

            expected_file = '/httpboot/redfish/' + object_name

            img_handler_obj.unpublish_image(object_name)

            mock_ironic_utils.unlink_without_raise.assert_called_once_with(
                expected_file)
コード例 #4
0
    def test_publish_image_local_link(
            self, mock_mkdir, mock_link, mock_shutil, mock_chmod):
        self.config(use_swift=False, group='redfish')
        self.config(http_url='http://localhost', group='deploy')
        img_handler_obj = image_utils.ImageHandler(self.node.driver)

        url = img_handler_obj.publish_image('file.iso', 'boot.iso')

        self.assertEqual(
            'http://localhost/redfish/boot.iso?filename=file.iso', url)

        mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)
        mock_link.assert_called_once_with(
            'file.iso', '/httpboot/redfish/boot.iso')
        mock_chmod.assert_called_once_with('file.iso', 0o644)
コード例 #5
0
    def test_publish_image_swift(self, mock_swift):
        img_handler_obj = image_utils.ImageHandler(self.node.driver)
        mock_swift_api = mock_swift.SwiftAPI.return_value
        mock_swift_api.get_temp_url.return_value = 'https://a.b/c.f?e=f'

        url = img_handler_obj.publish_image('file.iso', 'boot.iso')

        self.assertEqual('https://a.b/c.f?e=f&filename=file.iso', url)

        mock_swift.SwiftAPI.assert_called_once_with()

        mock_swift_api.create_object.assert_called_once_with(
            mock.ANY, mock.ANY, mock.ANY, mock.ANY)

        mock_swift_api.get_temp_url.assert_called_once_with(
            mock.ANY, mock.ANY, mock.ANY)
コード例 #6
0
    def test_publish_image_local_copy(self, mock_mkdir, mock_link, mock_shutil,
                                      mock_chmod, mock__is_swift):
        mock__is_swift.return_value = False
        self.config(use_swift=False, group='redfish')
        self.config(http_url='http://localhost', group='deploy')
        img_handler_obj = image_utils.ImageHandler(self.node.driver)

        mock_link.side_effect = OSError()

        url = img_handler_obj.publish_image('file.iso', 'boot.iso')

        self.assertEqual('http://localhost/redfish/boot.iso?filename=file.iso',
                         url)

        mock_mkdir.assert_called_once_with('/httpboot/redfish', 0o755)

        mock_shutil.copyfile.assert_called_once_with(
            'file.iso', '/httpboot/redfish/boot.iso')
        mock_chmod.assert_called_once_with('/httpboot/redfish/boot.iso', 0o644)
コード例 #7
0
 def test__append_filename_param_with_filename(self):
     img_handler_obj = image_utils.ImageHandler(self.node.driver)
     res = img_handler_obj._append_filename_param(
         'http://a.b/c?filename=bootme.img', 'b.img')
     expected = 'http://a.b/c?filename=bootme.img'
     self.assertEqual(expected, res)