Example #1
0
def on_msg(client, body, routing_key):
    try:
        entity = Entity.from_json(body)
        assert isinstance(entity, BaseTask)
        worker = TaskThreadWorker(client, entity)
        worker.start()
    except Exception:
        log.error("on msg processing", exc_info=True)
Example #2
0
 def run(self):
     try:
         self.task.perform(self.amqp_client)
         self.publish_report(TaskSuccess)
     except Exception, exc:
         log.error("Error on task perform", exc_info=True)
         self.task.set(progress=100,
                       error=str(exc),
                       status='failed')
         self.publish_report(TaskFailed)
Example #3
0
 def get_vnc_port(self):
     "Return VNC port number"
     import commands
     import re
     out = commands.getoutput(
         'virsh -c qemu:///system vncdisplay %s' % self.vm_uuid)
     match = re.search(':(\d)+', out)
     if not match:
         log.error("Coulg not get vnc port, %s" % out)
         raise HTTPError(404)
     return int(match.group(1))