def processResponse(rspec):

        print "-------------------> Monitoring!!!!!"

        for action in rspec.response.monitoring.action:
            print action
            if not action.type_ == "listActiveVMs":
                raise Exception("Cannot process Monitoring action:" +
                                action.type_)
            try:
                actionModel = Action.getAndCheckActionByUUID(action.id)
            except Exception as e:
                logging.error("No action in DB with the incoming uuid\n%s", e)
                return

            if action.status == "ONGOING":
                print "----------------------->ONGOING"
                #ONGOING
                actionModel.setStatus(Action.ONGOING_STATUS)
                return
            elif action.status == "SUCCESS":
                from vt_manager.models.VTServer import VTServer
                from vt_manager.controller.monitoring.VMMonitor import VMMonitor

                print "----------------------->SUCCESS"
                server = VTServer.objects.get(uuid=actionModel.getObjectUUID())
                print "----------------------->SUCCESS2"
                VMMonitor.processUpdateVMsList(server,
                                               action.server.virtual_machines)
                actionModel.destroy()
            elif action.status == "FAILED":
                print "----------------------->FAILED!!"
                actionModel.setStatus(Action.FAILED_STATUS)
	def processResponse(rspec):
		from vt_manager.models.VTServer import VTServer
 		for action in rspec.response.monitoring.action:
			if not action.type_ == "listActiveVMs":
				raise Exception("Cannot process Monitoring action:"+action.type_)
			try:
				if action.id == "callback":
					print '---------------------->Libvirt Monitoring!!!'
					from vt_manager.controller.monitoring.VMMonitor import VMMonitor
                                        print '------>UUID',action.server.virtual_machines[0].uuid
					print '------>STATUS',action.server.virtual_machines[0].status
					VMMonitor.processUpdateVMsListFromCallback(action.server.virtual_machines[0].uuid,action.server.virtual_machines[0].status,rspec)
					print '---------------------->LibvirtMonitoring Finished!!!'
					return
				else:
					actionModel = Action.getAndCheckActionByUUID(action.id)
			except Exception as e:
				logging.error("No action in DB with the incoming uuid\n%s", e)
				return

			if action.status == "ONGOING":
				print "----------------------->ONGOING"
				#ONGOING
				actionModel.setStatus(Action.ONGOING_STATUS)
				return
			elif action.status == "SUCCESS":
				from vt_manager.controller.monitoring.VMMonitor import VMMonitor
				print "----------------------->SUCCESS"
				server = VTServer.objects.get(uuid=actionModel.getObjectUUID())
				print "----------------------->SUCCESS2"
				VMMonitor.processUpdateVMsList(server,action.server.virtual_machines)	
				actionModel.destroy()
			elif action.status == "FAILED":
				print "----------------------->FAILED!!"
				actionModel.setStatus(Action.FAILED_STATUS)	
Example #3
0
	def __updateAgentStatus(self, server):
		try:
			print "Pinging Agent on server %s" % server.name
			XmlRpcClient.callRPCMethod(server.getAgentURL(),"ping", "hola")
			#Server is up
 			print "Ping Agent on server %s was SUCCESSFUL!" % server.name
			if self.periodicRefresh() or server.available == False:
				#Call it 
				VMMonitor.sendUpdateVMs(server)
			
				if server.available == False:
					server.setAvailable(True)
					server.save()
		except Exception as e:
			#If fails for some reason mark as unreachable
			print "Could not reach server %s. Will be set as unavailable " % str(server.name)
			print e
			server.setAvailable(False)
			server.save()
Example #4
0
    def __updateAgentStatus(self, server):
        try:
            print "Pinging Agent on server %s" % server.name
            XmlRpcClient.callRPCMethod(server.getAgentURL(), "ping", "hola")
            #Server is up
            print "Ping Agent on server %s was SUCCESSFUL!" % server.name
            if self.periodicRefresh() or server.available == False:
                #Call it
                VMMonitor.sendUpdateVMs(server)

                if server.available == False:
                    server.setAvailable(True)
                    server.save()
        except Exception as e:
            #If fails for some reason mark as unreachable
            print "Could not reach server %s. Will be set as unavailable "
            print e
            server.setAvailable(False)
            server.save()