Here are the examples of the python api requests.get taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : RemoveControllerKeyREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def check_lock_VDs():
test_valid_controller_FQDD_string(args["cl"])
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/%s/Volumes' % (idrac_ip, args["cl"]),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
vd_list=[]
if data[u'Members'] == []:
print("\n- WARNING, no volume(s) detected for %s" % args["cl"])
sys.exit()
else:
for i in data[u'Members']:
vd_list.append(i[u'@odata.id'][54:])
print("\n- Volume(s) detected for %s controller -\n" % args["cl"])
for ii in vd_list:
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/%s' % (idrac_ip, ii),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
for i in data.items():
if i[0] == "Encrypted":
print("%s, Encrypted(Lock) Status: %s" % (ii, i[1]))
sys.exit()
3
View Complete Implementation : SetPowerStateREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def set_power_state():
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/' % idrac_ip,verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
print("\n- WARNING, setting new server power state to: %s" % (args["r"]))
url = 'https://%s/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset' % idrac_ip
payload = {'ResetType': args["r"]}
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False, auth=(idrac_username,idrac_pastword))
statusCode = response.status_code
if statusCode == 204:
print("\n- Past, status code %s returned, server power state successfully set to \"%s\"\n" % (statusCode, args["r"]))
else:
print("\n- FAIL, Command failed, status code %s returned\n" % statusCode)
print(response.json())
sys.exit()
3
View Complete Implementation : ImportSystemConfigurationNetworkShareREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_sharetypes():
req = requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1' % (idrac_ip), auth=(idrac_username, idrac_pastword), verify=False)
data = req.json()
print("\n- ImportSystemConfiguration supported share types for iDRAC %s\n" % idrac_ip)
if u'OemManager.v1_0_0#OemManager.ImportSystemConfiguration' in data[u'Actions'][u'Oem']:
share_types = data[u'Actions'][u'Oem'][u'OemManager.v1_0_0#OemManager.ImportSystemConfiguration'][u'ShareParameters'][u'[email protected]']
else:
share_types = data[u'Actions'][u'Oem'][u'OemManager.v1_1_0#OemManager.ImportSystemConfiguration'][u'ShareParameters'][u'[email protected]']
for i in share_types:
if i == "LOCAL":
past
else:
print(i)
3
View Complete Implementation : ReKeyREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_storage_controllers():
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage' % idrac_ip,verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
print("\n- Server controller(s) detected -\n")
controller_list=[]
for i in data[u'Members']:
controller_list.append(i[u'@odata.id'].split("/")[-1])
print(i[u'@odata.id'].split("/")[-1])
if args["c"] == "yy":
for i in controller_list:
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/%s' % (idrac_ip, i),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
print("\n - Detailed controller information for %s -\n" % i)
for i in data.items():
print("%s: %s" % (i[0], i[1]))
else:
past
sys.exit()
3
View Complete Implementation : DeleteJobIdREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_job_queue_job_ids():
req = requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Jobs' % (idrac_ip), auth=(idrac_username, idrac_pastword), verify=False)
statusCode = req.status_code
data = req.json()
data = str(data)
jobid_search=re.findall("JID_.+?'",data)
if jobid_search == []:
print("\n- WARNING, job queue empty, no current job IDs detected for iDRAC %s" % idrac_ip)
sys.exit()
jobstore=[]
for i in jobid_search:
i=i.strip("'")
jobstore.append(i)
print("\n- Current job IDs in the job queue for iDRAC %s:\n" % idrac_ip)
for i in jobstore:
req = requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/%s' % (idrac_ip,i), auth=(idrac_username, idrac_pastword), verify=False)
data = req.json()
print("Job ID: %s, Job Type: %s" % (i,data[u'Name']))
3
View Complete Implementation : ChangeBootOrderBootSourceStateREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_job_status():
while True:
req = requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/%s' % (idrac_ip, job_id), auth=(idrac_username, idrac_pastword), verify=False)
statusCode = req.status_code
if statusCode == 200:
print("- Past, Command pasted to check job status, code 200 returned")
time.sleep(20)
else:
print("\n- FAIL, Command failed to check job status, return code is %s" % statusCode)
print("Extended Info Message: {0}".format(req.json()))
sys.exit()
data = req.json()
if data[u'Message'] == "Task successfully scheduled.":
print("- Past, job id %s successfully scheduled" % job_id)
break
else:
print("- WARNING: JobStatus not scheduled, current status is: %s" % data[u'Message'])
3
View Complete Implementation : ConvertToRAIDREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_virtual_disks():
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/%s/Volumes' % (idrac_ip, args["v"]),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
vd_list=[]
if data[u'Members'] == []:
print("\n- WARNING, no volume(s) detected for %s" % args["v"])
sys.exit()
else:
for i in data[u'Members']:
vd_list.append(i[u'@odata.id'].split("/")[-1])
print("\n- Volume(s) detected for %s controller -\n" % args["v"])
for ii in vd_list:
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/%s' % (idrac_ip, ii),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
for i in data.items():
if i[0] == "VolumeType":
print("%s, Volume type: %s" % (ii, i[1]))
sys.exit()
3
View Complete Implementation : GetStorageInventoryREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_storage_controllers():
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage' % idrac_ip,verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
print("\n- Server controller(s) detected -\n")
controller_list=[]
for i in data[u'Members']:
controller_list.append(i[u'@odata.id'][46:])
print(i[u'@odata.id'][46:])
if args["c"] == "yy":
for i in controller_list:
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/%s' % (idrac_ip, i),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
print("\n - Detailed controller information for %s -\n" % i)
for i in data.items():
print("%s: %s" % (i[0], i[1]))
3
View Complete Implementation : ConvertToNonRAIDREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_virtual_disks():
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/%s/Volumes' % (idrac_ip, args["v"]),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
vd_list=[]
if data[u'Members'] == []:
print("\n- WARNING, no volume(s) detected for %s" % args["v"])
sys.exit()
else:
for i in data[u'Members']:
vd_list.append(i[u'@odata.id'].split("/")[-1])
print("\n- Volume(s) detected for %s controller -\n" % args["v"])
for ii in vd_list:
response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/%s' % (idrac_ip, ii),verify=False,auth=(idrac_username, idrac_pastword))
data = response.json()
for i in data.items():
if i[0] == "VolumeType":
print("%s, Volume type: %s" % (ii, i[1]))
sys.exit()
3
View Complete Implementation : CheckConsistencyVirtualDiskREDFISH.py
Copyright GNU General Public License v2.0
Author : dell
Copyright GNU General Public License v2.0
Author : dell
def get_job_status():
while True:
req = requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/%s' % (idrac_ip, job_id), auth=(idrac_username, idrac_pastword), verify=False)
statusCode = req.status_code
if statusCode == 200:
time.sleep(5)
past
else:
print("\n- FAIL, Command failed to check job status, return code is %s" % statusCode)
print("Extended Info Message: {0}".format(req.json()))
sys.exit()
data = req.json()
if data[u'Message'] == "Task successfully scheduled.":
print("\n- WARNING, staged config job marked as scheduled, rebooting the system\n")
break
else:
print("\n- WARNING: JobStatus not scheduled, current status is: %s\n" % data[u'Message'])