def handle_message_deprecated( pkg, message): """callback function. deprecated """ print("Received message: %r" % (pkg, )) # kombu.transport.virtual.Message.ack(): # Acknowledge this message as being processed. This will remove the message from the queue. message.ack() params = simplejson.loads( pkg ) # start migration instance = params["instance"] host = params["host"] nova_cmd.live_migrate(instance,host) # check progress wait_limit = 600 # in seconds end_time = time.time() #+ wait_time # interval = 2 checking = True while checking and time.time() < end_time: vms = nova_cmd.vm_list(host) for vm in vms: if(instance == vm["instance"] ): vm_state = vm["state"] if(vm_state == "running"): # TODO client.send( {"type": "cmd", "mesg": "success","memo":"","instance":instance} ) checking = False elif(vm_state == "error"): #TODO client.send( {"type": "cmd", "mesg": "ongoing","memo":"","instance":instance} ) checking = False else: pass time.sleep(interval) # end_time = time.time() + 10 return
def _get_vm_use_vm_list(instance): # deprecated. backup vms = nova_cmd.vm_list() for vm in vms: if(instance == vm["instance"] ): return vm return None