def run(self): try: self.agent_port = int( self.config.get('network', 'agent-port', '9099')) self.debug_mode = self.config.getboolean('system', 'debug') self.multi_thread = self.config.getboolean('system', 'multi-thread') # 不用注册远程方法了 # self.tell_online_services() # 暂时不用 # self.post_ip() # self.post_host_info() result = post_url('%s/openStack/initRegister' % remote_base_url, payload=get_nfs_disk()) post_url('%s/openStack/nodeRegister' % remote_base_url, payload=get_sytem_info()) print('register result: ', result) self.app.run(host='0.0.0.0', port=self.agent_port, debug=self.debug_mode, use_reloader=self.debug_mode, threaded=self.multi_thread) except Exception as e: print_exception(__name__, e)
def run(self): try: #读取配置文件 self.agent_port = int( self.config.get('network', 'agent-port', '9099')) self.debug_mode = self.config.getboolean('system', 'debug') self.multi_thread = self.config.getboolean('system', 'multi-thread') # Tell switch server about what service is online # self.tell_online_services() # self.post_ip() # 获取磁盘信息保存到全局变量中 self.post_host_info() # vmpath=self.global_wrapper('json@storage:disk') vmpath = { 'disk': [get_vm_disks_for_enc(), getip(), self.agent_port] } post_url('%s/oVirt/initRegister' % remote_base_url, payload=vmpath) post_url('%s/oVirt/nodeRegister' % remote_base_url, payload=get_sytem_info()) print 'value: ', vmpath print 'system: ', get_sytem_info() # vmpath.write() # Run services self.app.run(host='0.0.0.0', port=self.agent_port, debug=self.debug_mode, use_reloader=self.debug_mode, threaded=self.multi_thread) except Exception, e: print_exception(__name__, e)
def post_servtag(serv_name, version, port): try: url = '%s/switch/servtag/%s' % (remote_base_url, serv_name) post_url(url, payload={ 'name': serv_name, 'version': version, 'port': port }, timeout=2) except: pass
def post_report(subtask_id, severity, result, brief, detail, json_data=None): payload = { 'severity': severity, 'result': result, 'brief': brief, 'detail': detail, 'subtask_id': subtask_id, 'timestamp': now() } if json_data: payload['json_data'] = dumps(json_data) post_url('%s/oVirt/reportReturn' % remote_base_url, payload)
def post_host_info(self): from host_info import get_sytem_info print '%s/nodeRegister' % remote_base_url post_url('%s/nodeRegister' % remote_base_url, payload=get_sytem_info())
def post_ip(self): payload = {'ip': getip(), 'port': self.agent_port, 'type': 0} post_url('%s/switch/ip' % remote_base_url, payload)