HPE Synergy Automation - Mounting Virtual Media and Override Boot Order

In deploying the servers at work, the next step after creating all of the server profiles is to mount the ISOs to install the operating system from and set the boot order temporarily to boot to CD instead of the boot order defined in the server profile.

Thankfully HPE provides methods to be able to mount ISOs on a virtual DVD drive for their physical servers through ILO. This allows for installation of operating systems straight from ISO file which allows not only base Windows/Linux installs to occur but also SCCM Offline Task Sequences to be used. Thankfully HPE provides examples on their github pages to mount ISOs on the virtual media drives for you to use as a template to accelerate your script creation. The links to each of the examples from HPE Github page is below:

HPERedfish Examples

HPRest Examples

These examples are great templates to start working with Ilo through Rest or Redfish but when using Synergy and OneView together with HPE servers something great happens - you are able to use OneView’s SSO capabilities to sign into Ilo on each of the servers easily without having to provide credentials to each server.

The code to establish a SSO session key which can be used in HPE’s example code instead of their line to generate, connect, and disconnect to the various ILO sessions is below. It is an early version of the code that I used, and I am working on a newer version which is able to switch automatically depending on what capabilities each server has.

$selectedServer = $listServer | where-object{ $_.serialnumber -eq $($item.serialnumber) }
$RemoteConsole = "$($selectedServer.uri)/remoteConsoleUrl"
$resp = send-hpovrequest $RemoteConsole
$URL, $session = $resp.remoteConsoleUrl.Split("&")
$http, $iLOIP = $URL.split("=")
$sName, $sessionkey = $session.split("=")
if ($selectedServer.model -like "*Gen10*")
    $rootUri = "https://$iloip/redfish/v1"
    $rootUri = "https://$iloip/rest/v1"

In the above example, $ListServer contains a list of all the servers on the OneView appliance returned by the command Get-HPOVServer. In order for this to work correctly, the selected server needs to have a server profile deployed to the physical server selected. If there is no server profile deployed to the server the property URI will return null. The above code also assumes that all gen 9 servers are only using Rest - which is the case in my environment. As noted above - eventually a version of this will be able to automatically probe the capabilities of the server to determine if Rest or Redfish is the appropriate technology to use.

Once the SSO Ilo session has been created, you can pass this session into the example code allowing you to perform actions against Ilo without having to provide credentials for each single connection. Because your SSO session is already created, you can remove the Connect-HPERedfish and Disconnect-HPERedfish commands from the code as well as simplify the parameter block to pass the SSO Ilosession directoy to the function. An example of the start of the updated Redfish mount media function is provided below

function Set-VirtualMediaGen10
    [CmdletBinding(SupportsShouldProcess = $true)]
    $ISOurl = $null,
    [Parameter(Mandatory = $true)]
    [System.Object]$BootOnNextReset = $null
$managers = Get-HPERedfishDataRaw -odataid '/redfish/v1/Managers/' -Session $Ilosession

Taking this a step further, it is possible to set a one time boot override for the server. By setting this the server will follow the boot override for one boot and then return back to what is set in the server profile in OneView. What is interesting about this is that when working with a server using UEFI to boot up - CD/DVD rom is not an option in the HPE server profile settings - but using Rest/Redfish you are able to set CD/DVD as a one time boot option. This code is also present in HPEs github page and just like the code to set-virtualmedia the parameter set and function can be modified to take the SSO OneView session as well.

Now there are a few things to remember when using HPE’s Rest/Redfish to set ISOs on a server.

  1. HPERedfish requires you to remove an ISO before attempting to mount another ISO to the same server. If you try to mount another ISO to the same server without un-mounting the previous one, you will receive an error. This is not required when using the Rest method.

  2. If you try to un-mount an ISO from a server using HPERedfish and one is not mounted an error is thrown. You should wrap the command inside a try/catch block with erroraction stop appended to the command.

  3. Mounting and un-mounting ISOs using rest does not throw errors like Redfish does. You can wrap these commands in try/catch blocks to keep things consistent but currently not needed.

  4. ISO files will need to reside on a web server and the Mime type settings of ISO files will need to be adjusted on the web server. The mime type settings that will need to be set are: .iso application/octet-stream. The forums which recommends that can be found here. If this setting is not set on the web server you may encounter an issue where the server is unable to boot to the ISO from the website. IIS/Apache web servers both work for this type of deployment.

Now that ISOs have been mounted to the servers, the next step will be to modify network settings if necessary. This is going to fun!