Automating Dell EMC PowerEdge Server Management by using iDRAC REST API with DMTF Redfish and Microsoft PowerShell Texas Roemer, Test Principal Engineer Paul Rubin, Sr.
Revisions Date Description August 2017 Initial release The information in this publication is provided “as is.” Dell Inc. makes no representations or warranties of any kind with respect to the information in this publication, and specifically disclaims implied warranties of merchantability or fitness for a particular purpose. Use, copying, and distribution of any software described in this publication requires an applicable software license. Copyright © 2017 Dell Inc. or its subsidiaries.
Contents Revisions.............................................................................................................................................................................2 Executive summary.............................................................................................................................................................4 Introduction ..................................................................................................................................
Executive summary The growing scale of cloud- and web-based data center infrastructure is reshaping the requirements of IT administrators worldwide. New approaches to systems management are required to keep up with the growing and changing market.
The Redfish management standard There are various Out-of-Band (OOB) Systems Management standards available in the industry. 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.
Redfish is supported by iDRAC with Lifecycle Controller REST API in the 12th, 13th, and 14th generation PowerEdge servers. For an overview of Redfish and iDRAC REST API, see the white paper Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers available on the Dell Techcenter website. Microsoft PowerShell Microsoft PowerShell is a task-based CLI shell and scripting language designed for system administration automation.
1 iDRAC REST API with Redfish To support the DMTF Redfish standard, the iDRAC with Lifecycle Controller supports a RESTful API in addition to support for the IPMI, SNMP, and WS-Man standard APIs. The iDRAC REST API builds on the Redfish standard to provide a RESTful interface for the Dell EMC value-add operations including: 7 Information about all the iDRAC with Lifecycle Controller out-of-band services—web server, SNMP, virtual media, SSH, Telnet, IPMI, and KVM.
2 Microsoft PowerShell prerequisites Before running any Microsoft PowerShell cmdlets by using the iDRAC REST API with Redfish, the following prerequisites must be fulfilled: 8 Install PowerShell 5.0 or later. Run Get-Host to verify the PowerShell version. Set ExecutionPolicy to “RemoteSigned”. To check the current setting, run GetExecutionPolicy. To change the setting, run Set-ExecutionPolicy. Ensure that Redfish is enabled on the iDRAC. By default, the Redfish service is enabled on iDRAC.
3 Operating the iDRAC REST API with Redfish by using PowerShell The following PowerShell scripts implement key use cases for the iDRAC REST API with Redfish including server power control, BIOS configuration, firmware update, RESTful server configuration, firmware update, and log export. The scripts have been tested on a PowerEdge R740 server with iDRAC9 firmware version 3.00.00.00. The scripts used in this white paper are available from the GitHub open source repository https://github.
Get-Help with examples on the Set-PowerControlRedfish cmdlet 3.0 Setting power control properties (Set-PowerControlREDFISH) The Set-PowerControlRedfish PowerShell cmdlet can obtain the server’s current power state, view the possible power control options, and change the server power state.
3.1 Configuring BIOS setting (Set-OneBiosAttributeREDFISH) The Set-OneBiosAttribureRedfish cmdlet is used to get the current value of BIOS attributes or to set a single BIOS attribute to a new value: 1. Run cmdlet to get all the BIOS attributes and their current values: Viewing BIOS attribute values with Set-OneBIOSAtrributeRedfish cmdlet 2. To obtain the value of a single attribute, enter the vertical symbol (|) and use the Select built-in command to access the desired attribute.
3. Run Set-OneBIOSAttributeRedfish to set the MemTest attribute to Disabled: Setting a single BIOS attribute with Set-OneBIOSAttributeRedfish 3.2 Setting an iDRAC password (Set-IdracUserPasswordREDFISH) The Set-IdracUserPassword Redfish cmdlet changes an iDRAC user’s password and then runs a GET command by using the new password to verify that the user password was changed. To run the cmdlet, the iDRAC user ID index number is required with the current user name and password.
3.3 Updating server firmware (Set-UpdateOneDeviceREDFISH) The Set-UpdateOneDeviceRedfish cmdlet provides an inventory of the current firmware versions for devices in the server which iDRAC supports for updates. Also supports performing a firmware update on a single device. The firmware update file must be stored on the same system from which the cmdlet is run; the update file content is streamed to the iDRAC within the API.
In the screen shot, a PERC H730P Mini controller is updated from the firmware version 25.5.2.0001 to 25.5.0.0018. The update is applied with an immediate server restart. The Windows Update Package file for version 25.5.0.0018 is saved locally in the C:\Python27 directory before running the cmdlet. Updating PERC firmware using Set-UpdateOneDeviceRedfish cmdlet 3.
The following screen shots describe the flow of importing preview before running the import: Exporting an SCP by using the Set-ExportImportServerConfigurationProfileRedfish cmdlet Importing preview of SCP by using the Set-ExportImportServerConfigurationProfileRedfish cmdlet 15 Automating Dell EMC PowerEdge Server Management by using iDRAC REST API with DMTF Redfish and Microsoft PowerShell
Changing the iDRAC configuration by using an SCP import with the SetExportImportServerConfigurationProfileRedfish cmdlet 16 Automating Dell EMC PowerEdge Server Management by using iDRAC REST API with DMTF Redfish and Microsoft PowerShell
3.5 Getting iDRAC Lifecycle logs (Get-IdracLifecycleLogsREDFISH) The Get-IdracLifecycleLogsRedfish cmdlet exports the Lifecycle Controller logs. The cmdlet outputs the logs to standard output but also captures the logs in a text file (lifecycle_logs.txt) with a timestamp indicating the time of the cmdlet execution.
4 Detailing cmdlet code for iDRAC REST API with Redfish Here, the Set-PowerControlRedfish cmdlet is annotated with highlighted comments for each section of the code. <# # The first part of the cmdlet will always be the comment block explaining description, examples, etc. which can get accessed when you run “Get-Help” on the cmdlet. _author_ = Texas Roemer _version_ = 2.0 Copyright (c) 2017, Dell, Inc.
function Set-PowerControlREDFISH { # Within the function, define the supported parameters, indicating which are mandatory and which are optional. param( [Parameter(Mandatory=$True)] [string]$idrac_ip, [Parameter(Mandatory=$True)] [string]$idrac_username, [Parameter(Mandatory=$True)] [string]$idrac_password, [Parameter(Mandatory=$False)] [string]$power_request_value, [Parameter(Mandatory=$False)] [string]$get_power_state_only ) # Function to ignore SSL certs.
# Below code is needed to set up the credentials correctly for PowerShell to process and accept them. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12 $user = $idrac_username $pass= $idrac_password $secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force $credential = New-Object System.Management.Automation.
} if ($get_power_state_only -eq "n") { return } # POST command to set the new server power state. For POST commands, you must create a hash table which must be converted to JSON format and compressed. This behavior must be duplicated for all POST commands when creating the hash table. $JsonBody = @{ "ResetType" = $power_request_value } | ConvertTo-Json -Compress # Create the URI and POST command to change the server power state. $u4 = "https://$idrac_ip/redfish/v1/Systems/System.Embedded.
Conclusion 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 features that can increase efficiency, lower costs and boost productivity across their organizations.