|
Post by mark3010 on Dec 19, 2022 17:16:13 GMT
Hi, I'm new to redfish, tasked with pulling Server IP's (not Ilo IP's) from Linux servers. I'm using "REST Client" plugin in VS Code, trying to figure how to grab the IP, then translate that method into a Python script. So far no luck isolating the IP.. Here's the call that returns what is in the attachment...when I try to add to the path to target the IP, I get errors. GET https://{{host}}/redfish/v1/Systems/1/NetworkAdapters/1 Content-Type: application/json
X-Auth-Token: {{authToken}}Attached is the redfish output for a server (wanting to maintain indentation levels). Again, I am just trying to isolate the redfish command to display only the server IP address 192.168.1.2. I hope this is proper place in forum for this type of request. Any advice you might have would be much appreciated! Thanks, Mark Attachments:redfish.txt (618 B)
|
|
|
Post by jautor on Dec 19, 2022 22:45:43 GMT
First, note that this is an HPE-specific resource, not a standard Redfish-defined resource, so it will only work on HPE iLO systems.
If your question is how to isolate the "IPv4Addresses" property - you'll have to do that in your script, the Redfish service only provides access at a resource level. So you'll get that whole JSON document, which can easily be converted in your Python script to a dictionary for traversing.
That schema's structure has a root-level property "PhysicalPorts", which contains an array of JSON objects. Inside each array element is a further array of strings called "IPv4Addresses".
So to extract the IP addresses, you'd iterate through the array of PhysicalPorts and grab the array (likely of one element) of IPv4Addresses for each.
Hope that answers your question,
Jeff
|
|
|
Post by mark3010 on Dec 21, 2022 16:49:12 GMT
Thank you Jeff! I was able to get the IP. I put the relevant code below, maybe it will help someone else...the line with "PhysicalPorts" was the kicker for me. # snip try: curr_comms_resp = requests.get(base_url + "/Systems/1/NetworkAdapters/1", headers=headers,verify=False) curr_comms = curr_comms_resp.json() print(curr_comms, "\n") print(curr_comms['PhysicalPorts'][0]['IPv4Addresses'][0]['Address']) except Exception as e: print(str(e)) # snip -Mark
|
|