Пример #1
0
	def listVMTemplatesInfo(serverUUID):
	#def listVMTemplatesInfo(serverUUID, callbackURL):
		logging.debug("Enter listVMTemplatesInfo")
		server = VTDriver.getServerByUUID(serverUUID)
		xmlrpc_server = xmlrpclib.Server(server.getAgentURL())
		templates_info = xmlrpc_server.list_vm_templates(server.getAgentPassword())
		#templates_info = xmlrpc_server.list_vm_templates(callbackURL, server.getAgentPassword())
		return str(templates_info)
 def listVMTemplatesInfo(serverUUID):
     #def listVMTemplatesInfo(serverUUID, callbackURL):
     logging.debug("Enter listVMTemplatesInfo")
     server = VTDriver.getServerByUUID(serverUUID)
     xmlrpc_server = xmlrpclib.Server(server.getAgentURL())
     templates_info = xmlrpc_server.list_vm_templates(
         server.getAgentPassword())
     #templates_info = xmlrpc_server.list_vm_templates(callbackURL, server.getAgentPassword())
     return str(templates_info)
    def processProvisioning(provisioning):
		logging.debug("PROVISIONING STARTED...\n")
		for action in provisioning.action:
			actionModel = ActionController.ActionToModel(action,"provisioning")
			logging.debug("ACTION type: %s with id: %s" % (actionModel.type, actionModel.uuid))
			try:
				RuleTableManager.Evaluate(action,RuleTableManager.getDefaultName())
			except Exception as e:
				MAX_CHARS_ALLOWED = 200
				XmlRpcClient.callRPCMethod(threading.currentThread().callBackURL,"sendAsync",XmlHelper.craftXmlClass(XmlHelper.getProcessingResponse(Action.FAILED_STATUS, action,str(e)[0:MAX_CHARS_ALLOWED-1])))
				return None
			try:
				controller = VTDriver.getDriver(action.server.virtualization_type)
				#XXX:Change this when xml schema is updated
				server = VTDriver.getServerByUUID(action.server.uuid)
				#if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
				#	server = VTDriver.getServerByUUID(action.virtual_machine.server_id)
				#else:
				#	server = VTDriver.getVMbyUUID(action.virtual_machine.uuid).Server.get()
			except Exception as e:
				logging.error(e)
				raise e
			try:	
				#PROVISIONING CREATE
				if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
					try:
						vm = ProvisioningDispatcher.__createVM(controller, actionModel, action)
					except:
						vm = None
						raise
				#PROVISIONING DELETE, START, STOP, REBOOT
				else :
					ProvisioningDispatcher.__deleteStartStopRebootVM(controller, actionModel, action)
				XmlRpcClient.callRPCMethod(server.getAgentURL() ,"send", UrlUtils.getOwnCallbackURL(), 1, server.getAgentPassword(),XmlHelper.craftXmlClass(XmlHelper.getSimpleActionQuery(action)) )
				return
			except Exception as e:
				if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
					# If the VM creation was interrupted in the network
					# configuration, the created VM won't be returned
					try:
						if not vm:
							vm = controller.getVMbyUUID(action.server.virtual_machines[0].uuid)
						controller.deleteVM(vm)
						# Keep actions table up-to-date after each deletion
						actionModel.delete()
					except Exception as e:
						print "Could not delete VM. Exception: %s" % str(e)
				#XmlRpcClient.callRPCMethod(threading.currentThread().callBackURL,"sendAsync",XmlHelper.craftXmlClass(XmlHelper.getProcessingResponse(Action.FAILED_STATUS, action, str(e))))
		logging.debug("PROVISIONING FINISHED...")
Пример #4
0
    def processProvisioning(provisioning):
		logging.debug("PROVISIONING STARTED...\n")
		for action in provisioning.action:
			actionModel = ActionController.ActionToModel(action,"provisioning")
			logging.debug("ACTION type: %s with id: %s" % (actionModel.type, actionModel.uuid))
			try:
				RuleTableManager.Evaluate(action,RuleTableManager.getDefaultName())
			except Exception as e:
				MAX_CHARS_ALLOWED = 200
				XmlRpcClient.callRPCMethod(threading.currentThread().callBackURL,"sendAsync",XmlHelper.craftXmlClass(XmlHelper.getProcessingResponse(Action.FAILED_STATUS, action,str(e)[0:MAX_CHARS_ALLOWED-1])))
				return None
			try:
				controller = VTDriver.getDriver(action.server.virtualization_type)
				#XXX:Change this when xml schema is updated
				server = VTDriver.getServerByUUID(action.server.uuid)
				#if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
				#	server = VTDriver.getServerByUUID(action.virtual_machine.server_id)
				#else:
				#	server = VTDriver.getVMbyUUID(action.virtual_machine.uuid).Server.get()
			except Exception as e:
				logging.error(e)
				raise e
			try:	
				#PROVISIONING CREATE
				if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
					try:
						vm = ProvisioningDispatcher.__createVM(controller, actionModel, action)
					except:
						vm = None
						raise
				#PROVISIONING DELETE, START, STOP, REBOOT
				else :
					ProvisioningDispatcher.__deleteStartStopRebootVM(controller, actionModel, action)
				XmlRpcClient.callRPCMethod(server.getAgentURL() ,"send", UrlUtils.getOwnCallbackURL(), 1, server.getAgentPassword(),XmlHelper.craftXmlClass(XmlHelper.getSimpleActionQuery(action)) )
				return
			except Exception as e:
				if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
					# If the VM creation was interrupted in the network
					# configuration, the created VM won't be returned
					try:
						if not vm:
							vm = controller.getVMbyUUID(action.server.virtual_machines[0].uuid)
						controller.deleteVM(vm)
						# Keep actions table up-to-date after each deletion
						actionModel.delete()
					except Exception as e:
						print "Could not delete VM. Exception: %s" % str(e)
				#XmlRpcClient.callRPCMethod(threading.currentThread().callBackURL,"sendAsync",XmlHelper.craftXmlClass(XmlHelper.getProcessingResponse(Action.FAILED_STATUS, action, str(e))))
		logging.debug("PROVISIONING FINISHED...")
Пример #5
0
    def processProvisioning(provisioning):

        logging.debug("PROVISIONING STARTED...\n")
        for action in provisioning.action:
            actionModel = ActionController.ActionToModel(
                action, "provisioning")
            logging.debug("ACTION type: %s with id: %s" %
                          (actionModel.type, actionModel.uuid))

            try:
                RuleTableManager.Evaluate(action,
                                          RuleTableManager.getDefaultName())
            except Exception as e:
                a = str(e)
                if len(a) > 200:
                    a = a[0:199]

                XmlRpcClient.callRPCMethod(
                    threading.currentThread().callBackURL, "sendAsync",
                    XmlHelper.craftXmlClass(
                        XmlHelper.getProcessingResponse(
                            Action.FAILED_STATUS, action, a)))
                #				XmlRpcClient.callRPCMethod(threading.currentThread().callBackURL,"sendAsync",XmlHelper.craftXmlClass(XmlHelper.getProcessingResponse('FAILED', action, 'You requested more than the 128Mbytes allowed for your project')))
                return None
            try:

                controller = VTDriver.getDriver(
                    action.server.virtualization_type)

                #XXX:Change this when xml schema is updated
                server = VTDriver.getServerByUUID(action.server.uuid)
                #if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
                #	server = VTDriver.getServerByUUID(action.virtual_machine.server_id)
                #else:
                #	server = VTDriver.getVMbyUUID(action.virtual_machine.uuid).Server.get()
            except Exception as e:
                logging.error(e)
                raise e

            try:
                #PROVISIONING CREATE
                if actionModel.getType() == Action.PROVISIONING_VM_CREATE_TYPE:
                    try:
                        vm = ProvisioningDispatcher.__createVM(
                            controller, actionModel, action)
                    except:
                        vm = None
                        raise
                #PROVISIONING DELETE, START, STOP, REBOOT

                else:

                    ProvisioningDispatcher.__deleteStartStopRebootVM(
                        controller, actionModel, action)

                XmlRpcClient.callRPCMethod(
                    server.getAgentURL(), "send", UrlUtils.getOwnCallbackURL(),
                    1, server.getAgentPassword(),
                    XmlHelper.craftXmlClass(
                        XmlHelper.getSimpleActionQuery(action)))
            except Exception as e:
                if actionModel.getType(
                ) == Action.PROVISIONING_VM_CREATE_TYPE and vm:
                    controller.deleteVM(vm)
                XmlRpcClient.callRPCMethod(
                    threading.currentThread().callBackURL, "sendAsync",
                    XmlHelper.craftXmlClass(
                        XmlHelper.getProcessingResponse(
                            Action.FAILED_STATUS, action, str(e))))

        logging.debug("PROVISIONING FINISHED...")