def delete_basevm(base_path, base_hashvalue): if base_path is not None and base_hashvalue is not None: disk_path=base_path hash_value=base_hashvalue dbconn, matching_basevm = PackagingUtil._get_matching_basevm(disk_path) if matching_basevm: dbconn.del_item(matching_basevm) if matching_basevm: base_dir = os.path.dirname(base_path) shutil.rmtree(base_dir)
def delete_basevm(base_path, base_hashvalue): if base_path is not None and base_hashvalue is not None: disk_path = base_path hash_value = base_hashvalue dbconn, matching_basevm = PackagingUtil._get_matching_basevm( disk_path) if matching_basevm: dbconn.del_item(matching_basevm) if matching_basevm: base_dir = os.path.dirname(base_path) shutil.rmtree(base_dir)
def test_export_base(self): disk_path = self.base_vm_path dbconn, matching_basevm = PackagingUtil._get_matching_basevm(disk_path) self.assertTrue(matching_basevm is not None, "Cannot find the requested base VM") try: PackagingUtil.export_basevm(self.export_outpath, matching_basevm.disk_path, matching_basevm.hash_value) except Exception as e: self.assertTrue(False, "Failed to export base VM: %s" % str(e)) else: self.assertTrue(os.path.join(self.export_outpath))
def test_export_base(self): disk_path=self.base_vm_path dbconn, matching_basevm = PackagingUtil._get_matching_basevm(disk_path) self.assertTrue(matching_basevm is not None, "Cannot find the requested base VM") try: PackagingUtil.export_basevm( self.export_outpath, matching_basevm.disk_path, matching_basevm.hash_value ) except Exception as e: self.assertTrue(False, "Failed to export base VM: %s" % str(e)) else: self.assertTrue(os.path.join(self.export_outpath))
def test_create_vm_overlay(self): disk_path=self.base_vm_path dbconn, matching_basevm = PackagingUtil._get_matching_basevm(disk_path) base_diskpath = matching_basevm.disk_path options = Options() options.TRIM_SUPPORT = True options.ZIP_CONTAINER = True options.FREE_SUPPORT = False options.DISK_ONLY = False try: vm_overlay = synthesis.VM_Overlay(base_diskpath, options) machine = vm_overlay.resume_basevm() VM_status = VMUtility.get_VM_status(machine) self.assertEqual(VM_status, libvirt.VIR_DOMAIN_RUNNING) # wait for VM running time.sleep(10) vm_overlay.create_overlay() self.overlay_filepath = vm_overlay.overlay_zipfile self.assertTrue(os.path.exists(self.overlay_filepath), True) except Exception as e: self.assertTrue(False, "cannot create VM overlay: %s" % str(e))