1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- from common.ext_database import init_db
- from api.riil.utils import save_json
- from api.riil_api import RiilApi
- class Main:
- def __init__(self):
- init_db()
- self.api = RiilApi()
- def get_events(self):
- all_unaccepted_event_list = []
- all_accepted_event_list = []
- res_id_set = set()
- # for i in range(1, 26):
- # unaccepted_event_list = self.api.query_event_list("unaccepted_event_view", pageIndex=i)
- # all_unaccepted_event_list.extend(unaccepted_event_list.get('eventList'))
- # save_json(all_unaccepted_event_list, "result/event/unaccepted_event_list.json")
- for i in range(1, 2):
- unaccepted_event_list = self.api.query_event_list("accepted_event_view", pageIndex=i)
- all_accepted_event_list.extend(unaccepted_event_list.get('eventList'))
- save_json(all_accepted_event_list, "result/rill/event/accepted_event_list.json")
- # event_list = self.api.get_log_alarm_list()
- # save_json(event_list, "result/event/event_list.json")
- for i in all_accepted_event_list:
- res_id_set.add(i.get('resId'))
- all_res_list = []
- for res_id in res_id_set:
- res = self.api.get_res_instance_by_id(res_id)
- all_res_list.append(res)
- save_json(all_res_list, "result/rill/res/res.json")
- def get_resources(self):
- # 获取主资源列表
- page_index = 1
- res_list = []
- while True:
- res_dict = self.api.get_res_list('00')
- if page_index >= res_dict.get('totalPage'):
- break
- page_index += 1
- res = res_dict.get('resList', [])
- res_list.extend(res)
- save_json(res_list, "result/rill/res/res_list.json")
- def get_ip_all_segment(self):
- res = self.api.get_all_subnet_info()
- save_json(res, "result/ip/ip_all_segment.json")
- res_location = self.api.get_ipmac_location_list()
- def get_room(self):
- res = self.api.get_all_room()
- save_json(res, "result/rill/room/room_list.json")
- event_from_room = []
- for room in res.get("roomVOList", []):
- room_id = room.get("id")
- res = self.api.get_element_by_room_id(room_id)
- event_from_room.extend(res.get('elementPojoList', []))
- save_json(event_from_room, "result/rill/room/event_from_room.json")
- def run(self):
- # 运行
- self.get_events()
- # self.get_resources()
- # self.get_ip_all_segment()
- # self.get_room()
- if __name__ == '__main__':
- main = Main()
- main.run()
|