예제 #1
0
파일: test_api.py 프로젝트: sstj/cot
    def test_convert_to_vmdk_streamoptimized(self):
        """Convert a disk to vmdk streamOptimized sub-format."""
        # Raw to stream-optimized vmdk
        temp_disk = os.path.join(self.temp_dir, "foo.img")
        try:
            create_disk_image(temp_disk, capacity="16M")
        except HelperNotFoundError as e:
            self.fail(e.strerror)
        try:
            new_disk_path = convert_disk_image(temp_disk, self.temp_dir,
                                               'vmdk', 'streamOptimized')
        except HelperNotFoundError as e:
            self.fail(e.strerror)

        (f, sf) = get_disk_format(new_disk_path)
        self.assertEqual(f, 'vmdk')
        self.assertEqual(sf, 'streamOptimized')

        # Non-stream-optimized to stream-optimized
        temp_disk = os.path.join(self.temp_dir, "foo.vmdk")
        create_disk_image(temp_disk, capacity="16M")
        new_disk_path = convert_disk_image(temp_disk, self.temp_dir,
                                           'vmdk', 'streamOptimized')
        (f, sf) = get_disk_format(new_disk_path)
        self.assertEqual(f, 'vmdk')
        self.assertEqual(sf, 'streamOptimized')
예제 #2
0
파일: test_api.py 프로젝트: sstj/cot
 def test_convert_no_work_needed(self):
     """Convert a disk to its own format."""
     try:
         new_disk_path = convert_disk_image(self.blank_vmdk, self.temp_dir,
                                            'vmdk', 'streamOptimized')
         # No change -> don't create a new disk but just return existing.
         self.assertEqual(new_disk_path, self.blank_vmdk)
     except HelperNotFoundError as e:
         self.fail(e.strerror)
예제 #3
0
파일: test_api.py 프로젝트: sstj/cot
 def test_convert_to_vmdk_streamoptimized_new_qemu(self):
     """Code flow for new QEMU version."""
     COT.helpers.api.QEMUIMG._version = StrictVersion("2.1.0")
     try:
         temp_disk = os.path.join(self.temp_dir, "foo.qcow2")
         create_disk_image(temp_disk, capacity="16M")
         new_disk_path = convert_disk_image(temp_disk, self.temp_dir,
                                            'vmdk', 'streamOptimized')
         self.assertEqual(new_disk_path,
                          os.path.join(self.temp_dir, 'foo.vmdk'))
         (f, sf) = get_disk_format(new_disk_path)
         self.assertEqual(f, 'vmdk')
         self.assertEqual(sf, 'streamOptimized')
     except HelperNotFoundError as e:
         self.fail(e.strerror)
     finally:
         COT.helpers.api.QEMUIMG._version = None