Skip to main content
Pure1 Support Portal

System Center Orchestrator 2012 R2 - SCO

Overview

Microsoft System Center Orchestrator is a workflow management solution for the data center. Orchestrator (SCO) lets you automate the creation, monitoring, and deployment of resources in your environment. With the Pure Storage PowerShell SDK it is possible to leverage the workflow capabilities with SCO. In this article a simple example of how to leverage the PowerShell SDK with Microsoft System Center 2012 Orchestrator will be discussed. Using Orchestrator along with the Pure Storage PowerShell SDK could provide some interesting scenarios to automate Dev/Test operations for example.Microsoft System Center Orchestrator (SCO) allows for the automations of tasks in a variety of different applications, services and tools. Read the following Orchestrator information for more details.

Below is a screenshot of the Microsoft System Center Orchestrator Runbook Designer. A Runbook is a set of steps or instructions to complete. See Runbooks Concepts from Microsoft for more details.

Orchestrator InitData

 

Configuration

There are a number of different Activities that come out of the box with Orchestrator which we will leverage to create this simple Runbook. The two Activities we will use are Initialize Data and Run .Net Script. Initiate Data is required for all Run Book’s which as it indicates, initiates the orchestration. 

In the Initiate Data step there are five parameters:

  1. Username — User name to login into the FlashArray.
  2. Password — Password for Username.
  3. Volume — Volume to create a snapshot.
  4. Suffix – Suffix of the snapshot.
  5. FlashArray — DNS or IP Address of the Pure Storage FlashArray

To setup the Runbook perform the following steps.

 

Step 1 - Create New Runbook

Open the Runbook Control Activities tile and drag-n-drop the Initialize Data activity onto the Runbook design canvas. When a new Runbook is created and an activity is placed on the design canvas it will ask to checkout the Runbook, choose Yes.

 

Step 2 - Initialize Data

Double-click the Initialize Data activity to customize the properties of the activity. Start with setting up the General properties. Customize the Name and Description. 

 

Step 3 - Configure Parameters

Next add the different parameters described earlier. Notice all of the data types are of type String

Leave the Run Behavior options to their default settings. This completes setting up the Initialize Data activity and now the Run .Net Script activity will be configured.

 

Step 4 - Create .Net Script Object

Just as with the Initialize Data activity, open up the System activities tile and select the Run .Net Script. Drag and drop this activity onto the design canvas. It does not matter where, but it is best to place near the Initialize Data step as the two activities will be connected in a few additional steps.

 

Step 5 - Configure the .Net Script Object

The Initialize Data activity has the parameters defined that will be published to the newly added Run .Net Script activity. First is to configure the activity by double-clicking to open up the properties dialog. First enter a custom Name and Description (Optional).

 

Step 6 - Add Customer PowerShell SDK Script

Click the Details tab to begin entering the custom Windows PowerShell script. The Run .Net Script activity allows for C#, Javascript, VB.NET and PowerShell scripts to be executed. Be sure to select PowerShell as the scripting option. 

In the Script field enter in the following Windows PowerShell script:

$Session = New-PSSession -ComputerName localhost
$ReturnArray = Invoke-Command -Session $Session -ScriptBlock
{
  $username = 'pureuser'
  $pwd = ConvertTo-SecureString -String 'pureuser' -AsPlainText -Force
  $Creds = New-Object System.Management.Automation.PSCredential ($username, $pwd)
  $FlashArray = New-PfaArray -EndPoint 10.1.1.10 -Credentials $Creds –IgnoreCertificateError
  New-Item -Path 'C:\Temp\Orchestrator-Log.txt' -ItemType 'File'
  New-PfaVolumeSnapshots -Array $FlashArray -Sources “Volume1" -Suffix “Suffix1" | Add-Content -Path 'C:\Temp\Orchestrator-Log.txt'
}

 

By default, the Run .Net Script activity runs scripts with Windows PowerShell 2.0; this lacks many of the new features found in PowerShell 3.0, 4.0 and 5.0. So in order to workaround this limitation a New-PSSession is created on the server which hosts the Runbook and will execute with the latest version of PowerShell installed on the host. 

Step 7 - Connect Activities

Before consuming Published Data the Run .Net Script activity needs to be connected or subscribed to the Initialize Data activity. On the Runbook design canvas select the Initialize Data activity. When the mouse hovers over the activity there is a small arrow on the right side of the activity. Using the mouse start dragging that arrow to the Run .Net Script activity to create a connection between both of the activities. See the screenshot below for an example connecting both activities.

 

Step 8 - Bind the Data

With the Initialize Data and Run .Net Script connected the script can consume the Published Data from the Initialize Data activity. Double-click the Run .Net Script to open up the activity and then click on the Details to view the PowerShell script inserted in Step 6. This can be a little tricky as it requires the cursor to be placed between the quotation marks (“ “) and then right-click to insert Published Data.

 

  1. Right-click to insert between the quotation marks (eg. $username = “<PLACE CURSOR>”)
  2. Click Subscribe
  3. Click Published Data
  4. Select the appropriate Published Data item, for example choose the Username for the $username variable. Repeat this step for all of the other four VARIABLE-PLACEHOLDER spots in the PowerShell script. Each Published Data name corresponds to a variable placeholder.


     
  5. After all of the Published Data variables have been added to the script you should see the following:

 

Step 9 - Runbook Debugging

The next step is to test the newly created Runbook using the Runbook Tester tool provided by Orchestrator.

 

The Runbook Tester can be used to view the individual activity variables or associated scripts. Think of the Runbook Tester as a debugger to help identify issues before running in production. The screenshots below shows the two activities and the properties that can be viewed.

 

 

Step 10 - Test Run

Run on the toolbar to execute the Runbook. The first action of the Runbook is to collect the variables defined in the Initialize Data activity. Enter the variable information as appropriate for the environment.

 

After entering the variables click OK to execute the activities.

 

As seen in the Log section both activities completed successfully! Checking the Pure Storage FlashArray we can see that for the TEST-VOLUME a snapshot named TEST-VOLUME.SCO has been created.

This is a very simple example of what can be achieved using the Pure Storage PowerShell SDK and System Center 2012 Orchestrator.