def stopVM(vmid, vm): try: # Just try to stop KVMManager.stopDomain(vm) KVMProvisioningDispatcher.logger.info("VM named " + vm.name + " has been stopped.") # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "SUCCESS", "") except Exception as e: KVMProvisioningDispatcher.logger.error(str(e)) # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "FAILED", str(e)) return
def startVM(vmid, vm): KVMProvisioningDispatcher.logger.info("XXX startVM start") try: # Trigger HdManager.startHook(vm) KVMManager.startDomain(vm) KVMProvisioningDispatcher.logger.info("VM named " + vm.name + " has been started.") # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "SUCCESS", "") except Exception as e: KVMProvisioningDispatcher.logger.error(str(e)) # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "FAILED", str(e)) KVMProvisioningDispatcher.logger.info("XXX startVM end") return
def listActiveVMs(vmid, server): try: doms = KVMManager.retrieveActiveDomainsByUUID() XmlRpcClient.sendAsyncMonitoringActiveVMsInfo(vmid, "SUCCESS", doms, server) except Exception as e: # Send async notification XmlRpcClient.sendAsyncMonitoringActionStatus(vmid, "FAILED", str(e)) KVMMonitoringDispatcher.logger.error(str(e)) return
def deleteVM(vmid, vm): try: try: # if it wasn't stopped, do it KVMManager.stopDomain(vm) except Exception as e: pass # Trigger Hd Deletion in Remote HdManager.delete(vm) # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "SUCCESS", "") except Exception as e: KVMProvisioningDispatcher.logger.error(str(e)) KVMProvisioningDispatcher.logger.exception("XXX") # Send async notification XmlRpcClient.sendAsyncProvisioningActionStatus(vmid, "FAILED", str(e)) return