class RunSend(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.vm_pre = [] self.vm_cur = [] self.hostuuid = '' self.sendmsg = SendMsg(msg_ip,msg_port,msg_user,msg_pwd) def getVMstat(self,record): stat = [] for vm in record: stat.append(vm['power_state']) return stat def updateRecord(self): rc = RecordCollecter(5) self.hostuuid = rc.getHostRecord()['uuid'] tmp = rc.getVMRecords() if 'Paused' not in self.getVMstat(tmp): self.vm_pre = self.vm_cur[0:] self.vm_cur = tmp else: self.vm_pre = self.vm_cur[0:] def run(self): try: while True: self.updateRecord(); msg = Msg(self.hostuuid, self.vm_pre, self.vm_cur).msg if(msg!=-1): self.sendmsg.sendTopicMsg("beyondcloud", "SyncVM", "SyncQueue", msg) log.debug(msg) time.sleep(3) except Exception, exn: log.exception(exn)
def __init__(self): threading.Thread.__init__(self) self.vm_pre = [] self.vm_cur = [] self.hostuuid = '' self.sendmsg = SendMsg(msg_ip,msg_port,msg_user,msg_pwd)