Esempio n. 1
0
    def test_ovf_process_not_admin(self, mock_find_file):
        mock_find_file.return_value = self.config_file_name

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        self.image.context.is_admin = False

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertRaises(RuntimeError, oprocess.execute, 'test_image_id',
                          ova_uri)
Esempio n. 2
0
    def test_ovf_process_not_admin(self, mock_find_file):
        mock_find_file.return_value = self.config_file_name

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        self.image.context.is_admin = False

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertRaises(RuntimeError, oprocess.execute, 'test_image_id',
                          ova_uri)
Esempio n. 3
0
    def test_ovf_process_no_config_file(self, mock_find_file):
        # Mimics a Glance deployment without the ovf-metadata.json file
        mock_find_file.return_value = None

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertEqual(ova_uri, oprocess.execute('test_image_id', ova_uri))

        # Note that the extracted disk image is overwritten onto the input
        # ova file.
        with open(ova_file_path, 'rb') as disk_image_file:
            content = disk_image_file.read()
        # b'ABCD' is the exact contents of the disk image file
        # testserver-disk1.vmdk contained in the testserver.ova package used
        # by this test
        self.assertEqual(b'ABCD', content)
        # No properties must be selected from the ovf file
        self.image.extra_properties.update.assert_called_once_with({})
        self.assertEqual('bare', self.image.container_format)
Esempio n. 4
0
    def test_ovf_process_no_config_file(self, mock_find_file):
        # Mimics a Glance deployment without the ovf-metadata.json file
        mock_find_file.return_value = None

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertEqual(ova_uri, oprocess.execute('test_image_id', ova_uri))

        # Note that the extracted disk image is overwritten onto the input
        # ova file.
        with open(ova_file_path, 'rb') as disk_image_file:
            content = disk_image_file.read()
        # b'ABCD' is the exact contents of the disk image file
        # testserver-disk1.vmdk contained in the testserver.ova package used
        # by this test
        self.assertEqual(b'ABCD', content)
        # No properties must be selected from the ovf file
        self.image.extra_properties.update.assert_called_once_with({})
        self.assertEqual('bare', self.image.container_format)
Esempio n. 5
0
    def test_ovf_process_success(self, mock_find_file):
        mock_find_file.return_value = self.config_file_name

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertEqual(ova_uri, oprocess.execute('test_image_id', ova_uri))

        # Note that the extracted disk image is overwritten onto the input ova
        # file
        with open(ova_file_path, 'rb') as disk_image_file:
            content = disk_image_file.read()
        # b'ABCD' is the exact contents of the disk image file
        # testserver-disk1.vmdk contained in the testserver.ova package used
        # by this test
        self.assertEqual(b'ABCD', content)
        # 'DMTF:x86:VT-d' is the value in the testerver.ovf file in the
        # testserver.ova package
        self.image.extra_properties.update.assert_called_once_with(
            {'cim_pasd_InstructionSetExtensionName': 'DMTF:x86:VT-d'})
        self.assertEqual('bare', self.image.container_format)
Esempio n. 6
0
    def test_ovf_process_success(self, mock_find_file):
        mock_find_file.return_value = self.config_file_name

        ova_file_path = self._copy_ova_to_tmpdir('testserver.ova')
        ova_uri = 'file://' + ova_file_path

        oprocess = ovf_process._OVF_Process('task_id', 'ovf_proc',
                                            self.img_repo)
        self.assertEqual(ova_uri, oprocess.execute('test_image_id', ova_uri))

        # Note that the extracted disk image is overwritten onto the input ova
        # file
        with open(ova_file_path, 'rb') as disk_image_file:
            content = disk_image_file.read()
        # b'ABCD' is the exact contents of the disk image file
        # testserver-disk1.vmdk contained in the testserver.ova package used
        # by this test
        self.assertEqual(b'ABCD', content)
        # 'DMTF:x86:VT-d' is the value in the testerver.ovf file in the
        # testserver.ova package
        self.image.extra_properties.update.assert_called_once_with(
            {'cim_pasd_InstructionSetExtensionName': 'DMTF:x86:VT-d'})
        self.assertEqual('bare', self.image.container_format)