In this python script i am making a REST call to a server and pulling information out in JSON files. With the following code, I am outputting 4 JSON files into a folder. I would like to output only 1 json file with all the information I need, how would I do this? If that's not possible then I would think merging the 4 JSON files would be my only option? Any help would be appreciated.
from subprocess import call
import os
import json
from glob import glob
fileName = "IP.txt"
file = open(fileName, "r")
for str in file:
login_info = str.split(':')
ip = login_info[0]
username = login_info[1]
password = login_info[2]
os.mkdir(ip)
call(["ilorest", "login", ip, '-u',
username, '-p', password])
call(["ilorest", "save", '--
selector=ComputerSystem', '--json', '-f',
ip+"\\"+ip+".json"])
call(["ilorest", "save", '--
selector=Memory', '--json', '-f',
ip+"\\"+ip+"_memory"+".json"])
call(["ilorest", "save", '--
selector=Processor', '--json', '-f',
ip+"\\"+ip+"_processor"+".json"])
call(["ilorest", "save", '--
selector=HPESmartStorageDiskDrive', '--
json', '-f',
ip+"\\"+ip+"_drives"+".json"])
call(["ilorest", "logout"])
paths = glob('*/')
for d in paths:
print(os.dir(d))
subprocess.check_output