def vmware_transform_image(self): # On entry the image points to our generic KVM raw image # Convert to stream-optimized VMDK and then update the image property target_image = self.image + ".tmp.vmdk" self.log.debug("Converting raw kvm image (%s) to vmware stream-optimized image (%s)" % (self.image, target_image)) convert_to_stream(self.image, target_image) self.log.debug("VMWare stream conversion complete") os.unlink(self.image) os.rename(self.image + ".tmp.vmdk", self.image)
def convert_images(files, outpath): ofils = [] for f in files: foutname = os.path.join(outpath, os.path.basename(f) + '.vmdk') sys.stdout.write('Converting {0} to {1}\n'.format(f, foutname)) convert_to_stream(f, foutname) ofils.append(foutname) sys.stdout.write('Converting done.\n') return ofils
def vmware_transform_image(self): # On entry the image points to our generic KVM raw image # Convert to stream-optimized VMDK and then update the image property target_image = self.app_config['imgdir'] + "/vmware-image-" + self.new_image_id + ".vmdk" self.log.debug("Converting raw kvm image (%s) to vmware stream-optimized image (%s)" % (self.image, target_image)) convert_to_stream(self.image, target_image) self.log.debug("VMWare stream conversion complete") # Save the original image file name but update our property to point to new VMWare image # TODO: Delete the original image? self.original_image = self.image self.image = target_image
def convert_images(files, outpath): ofils = [] for f in files: foutname = os.path.join(outpath, os.path.basename(f)+'.vmdk') sys.stdout.write('Converting {0} to {1}\n'.format(f, foutname)) convert_to_stream(f, foutname) ofils.append(foutname) sys.stdout.write('Converting done.\n') return ofils
def vmware_transform_image_stream_vmdk(self): if (check_qcow_size(self.image)) is not None: import subprocess self.log.debug("Input image is qcow; converting to raw") raw_output_fname = "{0}.raw".format(self.image) qemucmd = ['qemu-img', 'convert', '-f', 'qcow2', '-O', 'raw', self.image, raw_output_fname] subprocess.check_call(qemucmd) os.unlink(self.image) os.rename(raw_output_fname, self.image) # On entry the image points to our generic KVM raw image # Convert to stream-optimized VMDK and then update the image property target_image = self.image + ".tmp.vmdk" self.log.debug("Converting raw kvm image (%s) to vmware stream-optimized image (%s)" % (self.image, target_image)) convert_to_stream(self.image, target_image) self.log.debug("VMWare stream conversion complete") os.unlink(self.image) os.rename(self.image + ".tmp.vmdk", self.image)