def createVMfromImage(vmid, vm): KVMProvisioningDispatcher.logger.info("XXX createVMfromImage start") pathToMountPoint = "" KVMProvisioningDispatcher.logger.info("Initiating creation process for VM: " + vm.name + " under project: " + vm.project_id + " and slice: " + vm.slice_id) try: # Clone HD HdManager.clone(vm) KVMProvisioningDispatcher.logger.debug("HD cloned successfully...") # Mount copy pathToMountPoint = HdManager.mount(vm) KVMProvisioningDispatcher.logger.debug("Mounting at: " + pathToMountPoint) KVMProvisioningDispatcher.logger.debug("HD mounted successfully...") # Configure VM OS VMConfigurator.configureVmDisk(vm, pathToMountPoint) # Umount copy HdManager.umount(vm, pathToMountPoint) KVMProvisioningDispatcher.logger.debug("HD unmounted successfully...") # Synthesize config file VMConfigurator.createVmConfigurationFile(vm) KVMProvisioningDispatcher.logger.debug("KVM configuration file created successfully...") KVMProvisioningDispatcher.logger.info("Creation of VM " + vm.name + " has been successful!!") # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "SUCCESS", "") except Exception as e: KVMProvisioningDispatcher.logger.error(str(e)) KVMProvisioningDispatcher.logger.error(traceback.format_exc()) # Send async notification try: HdManager.umount(vm, pathToMountPoint) except: pass try: # Delete VM disc and conf file if the error is not due because # the VM already exists if not isinstance(e, VMalreadyExists): KVMProvisioningDispatcher.deleteVM(vmid, vm) except: pass XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "FAILED", str(e)) KVMProvisioningDispatcher.logger.info("XXX createVMfromImage end") return