Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers Dell EMC Customer Solution Centers Jonas Werner, Sr. Solution Architect Dell EMC Server Solutions P. Raveendra Reddy, Platform Software Staff Engineer Texas Roemer, Test Principal Engineer Paul Rubin, Sr.
Revisions Date Description March 2016 Initial release June 2017 Updated for 14th generation of PowerEdge release October 2017 Updated for the release of iDRAC7 and iDRAC8 2.50.50.50 June 2018 Updated for iDRAC9 versions 3.18.18.18, and iDRAC7 and iDRAC8 2.60.60.60 version releases The information in this publication is provided “as is.” Dell Inc.
Contents Revisions.............................................................................................................................................................................2 Executive summary.............................................................................................................................................................5 1 Introduction ...............................................................................................................................
3.3.8 Update general System Information with PATCH operation ............................................................................21 3.3.9 Change boot device temporarily .......................................................................................................................22 4 3.3.10 Update / modify iDRAC user account ..........................................................................................................23 3.3.
Executive summary The growing scale of cloud- and web-based data center infrastructure is reshaping the requirements of IT administrators world-wide. New approaches to systems management are needed to keep up with the growing and changing market.
1 Introduction Since the inception of the x86 server in the late 1980’s, IT administrators have sought the means to efficiently manage a growing number of distributed resources. Industry suppliers have responded by developing management interface standards to support common methods of monitoring and controlling heterogeneous systems.
2 The Redfish management standard There are various Out-of-Band (OOB) systems management standards available in the industry today. However, there is no single standard that can be easily used within emerging programming standards, can be readily implemented within embedded systems, and can meet the demands of today’s evolving IT solution models.
2.1 Next-generation server management The DMTF white paper on Redfish, DSP2044, describes the need to move away from managing servers as individual “pets”. Rather, administrators should begin to treat their servers more as “cattle” and manage them as “herds”. While in the past, IT staff could spend time to adapt their management methods to match a smaller number of servers, they now have many more servers and much less time.
2.4.1 HTTPS communication The Hypertext Transfer Protocol or HTTP is an application protocol for distributed, collaborative, hypermedia information systems and forms the foundation of data communication for the World Wide Web. Secure HTTP or HTTPS is a secure version of HTTP that enables secure communications by operating HTTP within a network connection encrypted by TLS or SSL.
Redfish events are delivered only over HTTPS transport. In the initial iDRAC Redfish implementation, HTTPS certificates are disabled; this requires the event listener to support receiving event notifications without certificate validation. Eventing with certificate support is planned for a future release. 2.5 Redfish operational model Redfish operations are initiated by a client using HTTPS for GET, POST, PATCH and DELETE operations and capable of interpreting the JSON responses from the managed server.
“/redfish/”. In the case of a PowerEdge server, the root is accessed through the URI https:///redfish/v1/ - the “v1” at the end of the URI denotes the version of the API. The URI is the primary unique identifier of resources. Redfish URIs consist of three parts as described in RFC3986: Part one defines the scheme and authority of the URI, part two specifies the root service and version and part three defines a unique resource identifier. For example, in the following URI: https://mgmt.vendor.
Or, more graphically represented as: Note that the API is best navigated starting from the root as some portions of an API path can vary depending upon the server hardware configuration. For example, the “RAID.Integrated.1-1” Sub-item in the preceding example may be different when another type of RAID controller is installed in the managed server. 2.6.2 Redfish operations In Redfish, HTTP methods implement the operations of a RESTful API. This allows the user to specify the type of request being made.
iDRAC Redfish authentication and authorization requirements Redfish Actions Authentication Authorization Required Required Read operation on any instrumentation data Write operation on any instrumentation data Execute operation on any instrumentation data View Service root View Metadata document View OData Service Document View Message Registry Yes Yes Yes No No No No Yes Yes Yes No No No No Unlike certain management interfaces that restrict authentication to a single command, the Redfish Service provide
3 Using the Redfish API on PowerEdge systems The following tests were carried out using a PowerEdge R740 server loaded with firmware version 3.00.00.00. If a Redfish conformant server is not available, a simulated server Redfish interface is available at the DMTF website: http://redfish.dmtf.org/redfish/v1. 3.1 Web browser access Because REST is a web-based API, a typical web browser such as Microsoft Internet Explorer or Google Chrome can be used for access.
iDRAC Redfish authenticated server details access 3.2 Accessing Redfish by using the cURL application Interacting with Redfish using scripting tools can be extremely powerful. The following examples use a Dell Latitude E7440 running Ubuntu to access the Redfish API from the command line using the cURL application. cURL is a powerful open source command line tool for interacting with various web-based services. It supports both HTTP and HTTPS in addition to other protocols.
{"@odata.context":"/redfish/v1/$metadata#ServiceRoot","@odata.id":"/redfish/v1", "@odata.type":"#ServiceRoot.1.0.0.ServiceRoot","AccountService":{"@odata.id":"/r edfish/v1/Managers/iDRAC.Embedded.1/AccountService"},"Chassis":{"@odata.id":"/re dfish/v1/Chassis"},"Description":"Root Service","EventService":{"@odata.id":"/redfish/v1/EventService"},"Id":"RootServi ce","JsonSchemas":{"@odata.id":"/redfish/v1/JSONSchemas"},"Links":{"Sessions":{" @odata.id":"/redfish/v1/Sessions"}},"Managers":{"@odata.
curl -X POST –k “https:///redfish/v1/Sessions” –H “ContentType:application/json” -d '{"UserName":"root","Password":"calvin"}' –v Note: when using this command in the Windows command shell, backslashes (‘\’) must be used to ensure proper handling of the quote marks – for example: curl -X POST –k “https:///redfish/v1/Sessions” –H “ContentType:application/json” -d '{\"UserName\":\"root\",\"Password\":\"calvin\"}' –v Once logged in, subsequent commands can be sent using X-Auth-Token as shown
systemData = system.json() storageData = storage.json() print print print print print print print print "Model: "Manufacturer: "Service tag "Serial number: "Hostname: "Power state: "Asset tag: "Memory size: print print print print "CPU type: "Number of CPUs: "System status: "RAID health: {}".format(systemData[u'Model']) {}".format(systemData[u'Manufacturer']) {}".format(systemData[u'SKU']) {}".format(systemData[u'SerialNumber']) {}".format(systemData[u'HostName']) {}".
print "System {}: Health status: {}".format(reqJson[u'SKU'],reqJson[u'Status'][u'Health']) 3.3.3 View system event log import requests import json system = requests.get('https:///redfish/v1/Managers/iDRAC.Embedded.1/Logs/Sel',verify=False, auth=('root','calvin')) systemData = system.json() for logEntry in systemData[u'Members']: print "{}: {}".format(logEntry[u'Name'],logEntry[u'Created']) print " {}\n".
3.3.5 Turn on a system Server power is controlled by using a POST operation to the ComputerSystem.Reset URI to request the desired action. import requests import json url = 'https:///redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset' payload = {'ResetType': 'On'} headers = {'content-type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False, auth=('root','calvin')) 3.3.
print "Min reading: {}".format(systemData[u'PowerMetrics'][u'MinConsumedWatts']) Output: Consumed power: Average reading: Max reading: Min reading: 3.3.8 149 155 169 144 Update general System Information with PATCH operation This example demonstrates how to update the System read/write properties as defined in the Redfish specification. Users can provide information about the properties in the System and can update single or multiple properties.
Output: Status Code: 400 Extended Info Message: {u'error': {u'code': u'Base.1.0.GeneralError', u'message': u'A general error has occurred. See ExtendedInfo for more information', u'@Message.ExtendedInfo': [{u'Severity': u'Warning', u'MessageId': u'Base.1.0.PropertyValueTypeError', u'RelatedProperties': [u'HostName'], u'Message': u'The value integer or boolean for the property HostName is of a different type than the property can accept.
3.3.10 Update / modify iDRAC user account The iDRAC has pre-defined slots for internal user accounts. To modify an account, a PATCH action is used rather than a POST. “RoleId” is used to specify the type of access permissions to be granted to the user; in this case, the Operator role is used. import requests import json url = 'https:///redfish/v1/Managers/iDRAC.Embedded.
Firmware update by using a networked repository while importing an SCP Auto Config, RACADM, WS-Man, and Redfish SCP operations by using HTTP/HTTPS in addition to CIFS and NFS (HTTP/S support iDRAC9 only) SCP operations by using local file streaming SCP JSON format for export/import in addition to an XML format For more information about RESTful server configuration, see the Dell EMC technical white paper Zero-Touch Bare Metal Server Provisioning using Dell EMC iDRAC with Lifecycle Controller Auto
f=open("bios_attributes.txt","a") global current_value global pending_value response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Bios' % idrac_ip,verify=False,auth=(idrac_username,idrac_password)) data = response.json() a="\n--- BIOS Attributes ---\n\n%-30s%-30s\n\n" % ("Attribute", "Value") print a f.writelines(a) for i in data[u'Attributes'].items(): attribute_name = "%-30s" % (i[0]) #print attribute_name f.writelines(attribute_name) attribute_value = "%-30s\n" % (i[1]) #print attribut
… # # redfish_set_One_bios_attribute.py # Set a single BIOS attributes to a new value # Synopsis: # redfish_set_one_bios_attribute.py # # import requests, json, sys, re, time from datetime import datetime try: idrac_ip = sys.argv[1] idrac_username = sys.argv[2] idrac_password = sys.argv[3] attribute_name = sys.argv[4] pending_value = sys.
time.sleep(2) url = 'https://%s/redfish/v1/Systems/System.Embedded.1/Bios/Settings' % idrac_ip payload = {"Attributes":{attribute_name:pending_value}} headers = {'content-type': 'application/json'} response = requests.patch(url, data=json.dumps(payload), headers=headers, verify=False,auth=(idrac_username, idrac_password)) statusCode = response.status_code if statusCode == 200: print "\n- PASS: Command passed to set BIOS attribute %s pending value to %s\n" % (attribute_name, pending_value) else: print "\n- F
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_password), verify=False) statusCode = req.status_code if statusCode == 200: print "\n- PASS, Command passed to check job status, code 200 returned\n" 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.
headers = {'content-type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False, auth=('root','calvin')) statusCode = response.status_code if statusCode == 204: print "\n- PASS, Command passed to power ON server, code return is %s\n" % statusCode else: print "\n- FAIL, Command failed to power ON server, status code is: %s\n" % statusCode print "Extended Info Message: {0}".format(response.json()) sys.
print "- WARNING, JobStatus not completed, current status is: \"%s\", current job polling time is: %s\n" % (data[u'Message'],str(current_time)[0:7]) time.sleep(30) ### Function to check attribute new current value def get_new_current_value(): response = requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Bios' % idrac_ip,verify=False,auth=(idrac_username, idrac_password)) data = response.json() current_value_new = data[u'Attributes'][attribute_name] if current_value_new == pending_value: print "\n
Message = Task successfully scheduled. PercentComplete = 0 - PASS, Command passed to power OFF server, code return is 204 - PASS, Command passed to power ON server, code return is 204 - PASS, Command passed to check job status, code 200 returned - WARNING, JobStatus not completed, current status is: "Task successfully scheduled.
idrac_password = sys.argv[3] except: print "\n- FAIL, you must pass in script name along with iDRAC IP / iDRAC username / iDRAC password. Example: \"script_name.py 192.168.0.120 root calvin\"" sys.exit() print "\n- Getting current firmware version(s) for all devices in the system iDRAC supports\n" time.sleep(3) req = requests.get('https://%s/redfish/v1/UpdateService/FirmwareInventory/' % (idrac_ip), auth=(idrac_username, idrac_password), verify=False) statusCode = req.status_code data = req.
Output: C:\Python26>redfish_get_FW_inventory.py 100.65.99.66 root calvin - Getting current firmware version(s) for all devices in the system iDRAC supports --- Firmware Inventory ----------------------------------------------------------------------------Name: PERC H330 Mini Firmware Version: 25.5.2.0001 Updateable: True --------------------------------------------------------------------------Name: OS COLLECTOR, 3.0, A00 Firmware Version: 3.
Updateable: True --------------------------------------------------------------------------Name: Dell OS Driver Pack, 17.05.21, A00 Firmware Version: 17.05.21 Updateable: True --------------------------------------------------------------------------Name: Integrated Dell Remote Access Controller Firmware Version: 3.00.00.00 Updateable: True --------------------------------------------------------------------------Name: Dell 64 Bit uEFI Diagnostics, version 4301, 4301X07, 4301.
from datetime import datetime # Validate all correct parameters are passed in try: idrac_ip = sys.argv[1] idrac_username = sys.argv[2] idrac_password = sys.argv[3] firmware_image_location = sys.argv[4] file_image_name= sys.argv[5] Install_Option = sys.argv[6] except: print "\n- FAIL, you must pass in script name along with iDRAC IP / iDRAC username / iDRAC password / Image Path / Filename / Install Option. Example: \" script_name.py 192.168.0.120 root calvin c:\Python26 bios.exe NowAndReboot\"" sys.
response = requests.post(url, files=files, auth = (idrac_username, idrac_password), verify=False, headers=headers) d = response.__dict__ if response.status_code == 201: print "\n- PASS: Command passed, 201 status code returned\n" z=re.search("\"Message\":.+?,",d['_content']).group().rstrip(",") z=re.sub('"',"",z) print "- %s" % z else: print "\n- FAIL: Post command failed to download, error is %s" % response print "\nMore details on status code error: %s " % d['_content'] sys.exit() d = response.
print "\n- WARNING, checking new firmware version installed for updated device\n" req = requests.get('https://%s/redfish/v1/UpdateService/FirmwareInventory/%s' % (idrac_ip, new_FW_version), auth=(idrac_username, idrac_password), verify=False) #print req statusCode = req.status_code data = req.json() if dup_version == data[u'Version']: print "\n- PASS, New installed FW version is: %s" % data[u'Version'] else: print "\n- FAIL, New installed FW incorrect, error is: %s" % data sys.
print "\n- %s completed in: %s" % (job_id, str(current_time)[0:7]) break elif data[u"TaskState"] == "Completed with Errors" or data[u"TaskState"] == "Failed": print "\n- Job ID = "+data[u"Id"] print "- Name = "+data[u"Name"] try: print "- Message = "+message_string[0][u"Message"] except: print "- "+data[u"Messages"][0][u"Message"] print "- JobStatus = "+data[u"TaskState"] print "\n- %s completed in: %s" % (job_id, str(current_time)[0:7]) sys.
- Query job ID command passed - Job ID = JID_956512038576 Name = Firmware Update: Diagnostics Message = Job completed successfully. JobStatus = Completed - JID_956512038576 completed in: 0:00:15 - WARNING, checking new firmware version installed for updated device - PASS, New installed FW version is: 4301X06 C:\Python26> 3.3.15 Extended information When errors occur during operations, Redfish provides Extended Information detailing the error.
Output: Status Code: 200 Extended Error Message:{u'Success': {u'Message': u'Successfully Completed Request', u'Resolution': u'None', u'Severity': u'Ok', u'MessageId': u'Base.1.0.Success'}} If the script is modified to attempt an update with an unsupported value, an error will occur and Extended Information will be returned: payload = {'BitRate':1900} Output: Status Code: 400 Extended Error Message: {u'error': {u'code': u'Base.1.0.GeneralError', u'message': u'A general error has occurred.
4 Summary The DMTF Redfish standard is emerging as a key new tool for efficient, scalable, and secure server management. Utilizing an industry-standard interface and data format, Redfish supports rapid development of automation for one-to-many server management. System administrators and IT developers will appreciate Redfish’s features that can increase efficiency, lower costs and boost productivity across their organizations.
5 Additional Information DMTF white papers, Redfish Schemas, specifications, webinars and work-in-progress documents https://www.dmtf.org/standards/redfish The Redfish standard specification is available from the DMTF website http://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.0.1.pdf Open source iDRAC RESTful API with Redfish Python and PowerShell examples https://github.
5.2 Definitions 43 cURL: an open source command line tool and library for transferring data with URL Syntax DMTF: Distributed Management Task Force, defines management standards supported by numerous hardware, software and service vendors.(www.dmtf.org ) Redfish Client: Name for the functionality that communicates with a Redfish Service and accesses one or more resources or functions of the Service. Event: A record that corresponds to an individual alert.