File: virtualmachinedisk.py

package info (click to toggle)
bootstrap-vz 0.9.11%2B20180121git-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,244 kB
  • sloc: python: 8,800; sh: 813; makefile: 16
file content (27 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from qemuvolume import QEMUVolume


class VirtualMachineDisk(QEMUVolume):

    extension = 'vmdk'
    qemu_format = 'vmdk'
    ovf_uri = 'http://www.vmware.com/specifications/vmdk.html#sparse'

    def get_uuid(self):
        if not hasattr(self, 'uuid'):
            import uuid
            self.uuid = uuid.uuid4()
        return self.uuid
        # import uuid
        # with open(self.image_path) as image:
        #     line = ''
        #     lines_read = 0
        #     while 'ddb.uuid.image="' not in line:
        #         line = image.read()
        #         lines_read += 1
        #         if lines_read > 100:
        #             from common.exceptions import VolumeError
        #             raise VolumeError('Unable to find UUID in VMDK file.')
        #     import re
        #     matches = re.search('ddb.uuid.image="(?P<uuid>[^"]+)"', line)
        #     return uuid.UUID(hex=matches.group('uuid'))