HPE Synergy Automation - Creating Server Profiles

In my previous post on HPE Synergy, I went over the introduction to automating infrastructure using HPE Synergy as well as some of the initial gotchas to be on the look out for when delving into this world for the first time.

Before continuing, some terminology needs to be covered which may be new when talking about Synergy and OneView. First, OneView has templates which can be configured inside of OneView which contain all the settings which can be deployed to a server profile. Template configurable settings include networking, storage, bios settings, boot order, firmware versions, hardware type, and how the profiles are targeted for deployment (enclosure, hardware, etc). Second, server profiles are deployed from a template to a compute/storage/network node. It is possible to create a server profile without using a template, but using the template enables OneView to monitor the settings in the profile and if they ever differ from the template a warning is displayed in OneView allowing you to update the settings in the profile to match the settings in the template.

With that out of the way, let’s look at how to deploy profiles quickly and consistently.

The below assumes a connection to HPE OneView has already been established by Connect-HPOVMgmt with the correction version of HPOneView cmdlet.

To quickly deploy multiple server profiles from a template, you will need a few things. A CSV file with all of the information for creating the profile which includes the physical hardware serial number, the server profile name, the template name, and a list of all servers which do not have a profile assigned to them yet. To generate this list, run the following line of code:

$ServerList = get-hpovserver -noprofile

This will return a list of all servers with no assigned profile to the variable ServerList. Once this data is stored in memory, the next thing to do is go through a loop to process all of the data in the CSV file and create the server profiles.

The entire code segment is below with an explanation of how it works below that.

Walking through the script step by step breaks this down.

  1. Once inside the loop the first thing to do is get the physical server that has the serial number defined in the CSV file. Getting the serial numbers into the CSV file initially can be done manually, or through the get-hpovserver command.

  2. The next thing to do is select the template to use. Since each profile can potentially use a different template, this is important to specify. Once the template is specified and verified to exist on the appliance connection, the actual creation of the server profile is started.

  3. A new server profile is created using the specified template. As noted in the script, most of the settings come from the CSV file. Running new-hpovserverprofile in async mode allows for multiple profile creation jobs to be started. If the async flag is omitted then the command will only process one profile at a time, waiting for the previous one to complete. Another option that is available (but runs slower) is to pipe new-hpovserverprofile to wait-hpovtaskcomplete to wait for the new profile process to wait for completion before moving on. The magic though, is in the next part.

  4. The do/while loop which is after the new-hpovserverprofile command continually loops until the job for the item in the loop starts. This was put in due to an issue found with too many jobs attempting to be started at once with the OneView cmdlets 4.0 erroring out. Adding in the do/while loop to wait for the process to start prevents the script from attempting to start a new server profile deployment when the previous server deployment process is still setting up.

  5. After the foreach loop finishes going through each item and starting the new profile jobs, the next do/while loop continually loops until all of the setup jobs are completed. The process checks for job completion every 30 seconds. The way that get-hpovtask works is that if there are no jobs matching the criteria (in this case name of create with a state of running) then a non-terminating error is thrown. To make this work with a try/catch block this non-terminating error is turned into a terminating error via -erroraction stop.

Creating the server profiles is the first step to full deployment of a server in HPE OneView. The next post in this series, I will explore how we can validate data in a CSV file to make sure its in compliance with what the script requires.