def _check_manage(self): # print '_check_manage' # 着是监测管理节点的状态 for manager in openstack_models.NovaManagerServiceStatus.objects.all(): status_dic = [ manager.nova_api_status, manager.nova_consoleauth_status, manager.nova_scheduler_status, manager.nova_conductor_status, manager.nova_cert_status, ] if status_dic.count('up') == 5: if manager.status != 'up': manager.status = 'up' manager.save() event_nova.up(manager.host.hostname, 'node_status') elif 5 < status_dic.count('up') > 0: if manager.status != 'warning': manager.status = 'warning' manager.save() event_nova.warning(manager.host.hostname, 'node_status') else: if manager.status != 'down': manager.status = 'down' manager.save() event_nova.down(manager.host.hostname, 'node_status')
def _check_mgmt_api(self): # 监测每个管理节点的API相应 # print '_check_mgmt_api' mg_db_list = openstack_models.NovaManagerServiceStatus.objects.all() # print mg_db_list for mgmt in mg_db_list: host_db_obj = asset_models.Host.objects.get(id=mgmt.host_id) host_mg_ip = host_db_obj.ip_manager data = nova.mgmt_api_status(host_mg_ip) # print 'data', data if data: # print data if mgmt.nova_api_status != 'up': mgmt.nova_api_status = 'up' event_nova.up(host_db_obj.hostname, 'nova-api') mgmt.save() else: if mgmt.nova_api_status != 'down': mgmt.nova_api_status = 'down' event_nova.down(host_db_obj.hostname, 'nova-api') mgmt.save()