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'))
|