def getMetadata(idrac, port, file_collection_path, file_collection_time): meta_dict = {} response = requests.get(f"https://{user}:{passwd}@{idrac}/redfish/v1/", verify=False) json_response = response.json() service_data = Service(**json_response) serviceMeta = service_data.getMetadata() filename = getFileDescriptor(serviceMeta, idrac) try: fd = open(f"{file_collection_path}/output/{filename}", "a+") except FileNotFoundError as ex: if not os.path.exists(f"{file_collection_path}"): os.makedirs(file_collection_path) fd = open(f"{file_collection_path}/output/{filename}", "a+") # meta_dict[idrac] = getFile return [serviceMeta[0], serviceMeta[1], fd, file_collection_path, file_collection_time ]
def fetchMetadata(idrac, port, file_collection_path, file_collection_time): meta_dict = {} url = f"https://{user}:{passwd}@{idrac}/redfish/v1/" response_code, json_response = apiGetCall(url, 'Root API', idrac) if response_code == 200: service_data = Service(**json_response) serviceMeta = service_data.getMetadata() filename = serviceMeta[0] + '_' + serviceMeta[1]+ '_' + idrac + '_' + getTimestamp() +".jsonl" # try: # fd = open(f"{file_collection_path}/output/{filename}", "a+") # except FileNotFoundError as ex: # if not os.path.exists(f"{file_collection_path}"): # os.makedirs(file_collection_path) # fd = open(f"{file_collection_path}/output/{filename}", "a+") # meta_dict[idrac] = getFile return [serviceMeta[0], serviceMeta[1], filename, file_collection_path, file_collection_time] elif response_code == 408: print(json_response) else: print(f"{url} Failed with status code {response_code} and error Message {json_response}")
def fetchMetadata(idrac, port, file_collection_path, file_collection_time, q): meta_dict = {} url = f"https://{user}:{passwd}@{idrac}/redfish/v1/" response_code, json_response = apiGetCall(url, 'Root API', idrac) if response_code == 200: # q.put_nowait(makeLogMessage("INFO", idrac, "Fetch Successfully")) service_data = Service(**json_response) serviceMeta = service_data.getMetadata() filename = serviceMeta[0] + '_' + serviceMeta[ 1] + '_' + idrac + '_' + getTimestamp() + ".jsonl" return [ serviceMeta[0], serviceMeta[1], filename, file_collection_path, file_collection_time ] elif response_code == 408: q.put_nowait(makeLogMessage("ERROR", idrac, json_response)) else: q.put_nowait( makeLogMessage( "ERROR", idrac, json_response['error']['@Message.ExtendedInfo'][0]['Message']))