예제 #1
0
    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
예제 #2
0
 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
예제 #3
0
 def delete(self):
     uuid = self.get_argument("uuid")
     result = running_t.query_one(uuid=uuid)
     if result:
         deleter = Deleter(uuid=uuid, obj=self)
         deleter.start()
     else:
         self.send_error(404)
예제 #4
0
 def delete(self):
     uuid = self.get_argument("uuid")
     result = running_t.query_one(uuid=uuid)
     if result:
         deleter = Deleter(uuid=uuid, obj=self)
         deleter.start()
     else:
         self.send_error(404)
예제 #5
0
 def get(self):
     uuid = self.get_argument("uuid")
     result = running_t.query_one(uuid=uuid)
     try:
         os = result['instance_data']['os']
         host = result['host']
         port = result['port']
         self.write({"status": {"uuid": uuid, "host": host,
                                "port": port, "os": os}})
     except:
         self.send_error(404)
예제 #6
0
def del_nginx_host(instance_id=None):
    msg_id = instance_id
    msg_type = "del"
    node_id = "client"
    result = running_t.query_one(uuid=instance_id)
    try:
        port = result["port"]
    except KeyError:
        LOG.info("Error occured in get port.")
        return
    message = dict(msg_type=msg_type, msg_id=msg_id, server=port, node_id=node_id)
    message = str(message)
    sender(message)
    LOG.info("Send to multicast: %s" % message)
예제 #7
0
def del_nginx_host(instance_id=None):
    msg_id = instance_id
    msg_type = "del"
    node_id = "client"
    result = running_t.query_one(uuid=instance_id)
    try:
        port = result['port']
    except KeyError:
        LOG.info("Error occured in get port.")
        return
    message = dict(msg_type=msg_type,
                   msg_id=msg_id,
                   server=port,
                   node_id=node_id)
    message = str(message)
    sender(message)
    LOG.info("Send to multicast: %s" % message)