def run(self):
     '''
     暂停指定的时间,到时间后执行一些列动作
     '''
     time.sleep(self.seconds)
     result = running_t.query_one(uuid=self.uuid)
     if result:
         if cond.acquire():
             # 从running_dict中删除用户
             try:
                 del_vm_in_mem(self.uuid)
                 # nginx负载均衡中删除主机
                 del_nginx_host(self.uuid)
             except Exception, e:
                 LOG.exception(e)
             # 从running_t中删除用户
             running_t.delete(uuid=self.uuid)
             # 调用openstack删除主机
             nova_api.delete_vm(self.uuid)
             
             # 更新backup_t中的deleted_time
             deleted_time = time.time()
             backup_t.update(dict(uuid=self.uuid), deleted_time=deleted_time)
             
             # 通知排队线程
             cond.notify()
             cond.release()
             return
 def run(self):
     if cond.acquire():
         del_vm_in_mem(self.uuid)
         # 当调用cloudopen接口处理失败时,调用tornado返回500
         try:
             nova_api.delete_vm(self.uuid)
         except Exception, e:
             LOG.exception(e)
             running_t.delete(uuid=self.uuid)
             
             # 更新backup_t中的deleted_time
             deleted_time = time.time()
             backup_t.update(dict(uuid=self.uuid), deleted_time=deleted_time)
             
             self.obj.send_error(500)
             return
         else:
             try:
                 del_nginx_host(self.uuid)
             except Exception, e:
                 LOG.exception(e)
 def run(self):
     if cond.acquire():
         del_vm_in_mem(self.uuid)
         # 当调用cloudopen接口处理失败时,调用tornado返回404
         try:
             del_nginx_host(self.uuid)
             nova_api.delete_vm(self.uuid)
         except Exception, e:
             LOG.exception(e)
             self.obj.send_error(500)
         running_t.delete(uuid=self.uuid)
         
         # 更新backup_t中的deleted_time
         deleted_time = time.time()
         backup_t.update(dict(uuid=self.uuid), deleted_time=deleted_time)
         
         # 当全部处理成功后,调用tornado返回成功状态
         self.obj.write({"status": 0})
         tornado.ioloop.IOLoop.instance().add_callback(self.obj.on_write)
         
         cond.notify()
         cond.release()
         return