Introduction to UCS PowerTool Part II Cisco DevNet Learning Labs

Overview

UCS PowerTool is a library of PowerShell Cmdlets that enable the management of UCS environments from Microsoft Operating Systems, via the UCS XML API.

Cisco UCS is an Integrated Compute Infrastructure that has supported an XML API since its introduction. UCS Manager is the service that provides the XML API endpoint along with a graphical interface and a command line. The UCS components both physical and logical are represented as XML objects in a hierarchical Object Model format and can be manipulated via the XML API.

All UCS objects are described in an XML schema, this schema defines the objects their attributes and associated values. The schema is also used to generate more than 98% of the UCS PowerTool Library. Because a UCS component must be part of the Object Model to be part of the UCS system all components of UCS are always available via the XML API.

Objective

This Introduction to UCS PowerTool Learning Lab will guide you through the use of UCS PowerTool to connect to a UCS Manager, perform queries against UCS Manager objects, create new objects, modify objects and disconnect from the UCS Manager. UCS Manager Objects are representations of pools, policies, other logical constructs and physical entities.

Completion time: 30 minutes

Prerequisites

Prior to starting this learning lab it would be helpful to understand UCS Manager and the functionality that it provides to manage UCS compute environments.

An understanding of PowerShell would also be helpful.

UCS PowerTool

UCS PowerTool is a library of Microsoft PowerShell Cmdlets (pronounced command-lets) that enable the retrieval and manipulation of UCS Manager managed objects. UCS Manager API interaction can be categorized into several distinct sections.

  • Sessions
  • Methods
  • Queries and Filters
  • Configurations and Transactions
  • Event Subscription

UCS PowerTool provides services and cmdlets for all the categorizations of UCS Manager API interactions, along with cmdlets that allow for the inspection of object metadata, object hierarchical containment and object cmdlet action capabilities with pipeline object definitions.

UCS PowerTool cmdlets follow the same structure as PowerShell cmdlets (verb-noun) utilizing the defined Microsoft PowerShell Verbs. UCS PowerTool cmdlet nouns are the UCS objects. For example, to retrieve compute blade objects from UCS Manager, utilize the Get-UcsBlade cmdlet. The Get-UcsBlade cmdlet will retrieve all the UCS compute blade objects from all currently connected UCS Managers.

UCS PowerTool Download and Documentation

UCS PowerTool for UCS Manager is a component in the UCS PowerTool Suite. In addition to UCS Manager management capabilities in UCS PowerTool, there is also a cmdlet library for UCS Central and UCS IMC. UCS Central PowerTool library provides cmdlets to manage UCS Central, UCS Central is a manager of UCS Managers. UCS IMC PowerTool is a collection of cmdlets to manage the CIMC (Cisco Integrated Management Controller) component of the UCS C and E Series servers.

To use UCS PowerTool in your environment be sure to download and get the documentation.

Event Infrastructure Utilization

If you are utilizing event provided infrastructure a script has been provided to reset the environment to pre-lab settings.

On the desktop Double-click the Reset-Ucs-LL shortcut, provide the UCS Manager IP address that was assigned to you for the Learning Lab and hit Enter

Repeat this process for each assigned IP address, if you were assigned more than one.

Reset-Ucs-LL Icon:



Reset-Ucs-LL Console:



Exercise 1

There are over 9000 objects in the UCS Object Model, embedded in the UCS Platform Emulator (UCSPE) is the UCS Object XML schema definition, this alone is worth the download of the UCSPE. The XML schema is divided into two files an input and an output. Standard XML toolsets can utilize the schema, e.g. xmllint.

Typically at Cisco Live or other DevNet developer events the UCS Platform Emulator is utilized as it provides the same exact functionality as the actual UCS Manager that is embedded in a Fabric Interconnect. The UCS PE is freely available from the Cisco Communities link above.

The majority of the cmdlets in UCS PowerTool library are generated from the schema. Of the approximately 2,150 cmdlets in the library 2,100 are generated.

Utilizing standard PowerShell cmdlets we can get view the cmdlets in the UCS PowerTool library.

  1. Launch UCS PowerTool by double clicking the UCS PowerTool icon on the Desktop.

    UCS PowerTool Icon:



  2. Utilize the Get-Command PowerShell cmdlet to view the cmdlets in the UCS PowerTool library, at the command prompt type

    Get-Command -Module Cisco.UCSManager | more

    Get-Command:



  3. Spacebar through the cmdlet list and you will notice that there are Aliases, Functions, Add, Gets, Sets, Removes, etc.

  4. To get the actual number of Aliases, Functions and cmdlets in the UCS PowerTool library use the PowerShell Measure-Object cmdlet in conjunction with the Get-Command cmdlet. At the command prompt type

    Get-Command -Module Cisco.UCSManager | Measure-Object

The output will look similar to this

Count    : 2156
Average  :
Sum      :
Maximum  :
Minimum  :
Property :

Depending upon the version of UCS PowerTool the actual count may vary from what is shown here.

  1. As stated earlier in this document the UCS PowerTool cmdlets follow the PowerShell action-object/verb-noun format. To see the verbs utilized in the UCS PowerTool libary is easily done using standard PowerShell cmdlets.

    At the command prompt type

    Get-Command -Module Cisco.UCSManager | ?{$_.Name -match "-"} | %{$_.Name.Substring(0,$_.Name.IndexOf("-"))} | Sort-Object -Unique

    Let's breakdown what this command does.

    1. Get the commands in the Cisco.UCSManager Module
    2. Where the pipeline object attribute Name has a "-" in it, pipeline the object
    3. ForEach pipelined object print the substring of the Name attribute from the beginning of the Name up to the first "-"
    4. Sort each pipelined substring of the Name attribute and create a unique list.

The resulting output is

Acknowledge
Add
Associate
Backup
Clear
Compare
Complete
Confirm
Connect
ConvertTo
Copy
Decommission
Disable
Disassociate
Disconnect
Enable
Export
Get
Import
Invoke
Recommission
Register
Remove
Rename
Reset
Restart
Send
Set
Start
Stop
Sync
Undo
Unregister
Update
Watch

This is the end of exercise 1.

Exercise 2

Connect to a UCS Manager in -NoSsl mode and turn off http to https redirect.

  1. Connect to the UCS Manager in -NoSsl mode

    Connect-Ucs -Name <ip-address-ucs-manager> -NoSsl

    User: admin

    Password: password

    Connect-Ucs credentials dialog:



    Connect-Ucs -NoSsl output:



    Notice that the Uri attribute is http and not https. We connected in this manner to eliminate any certificate issues when launching the UCS Graphical interface.

  2. Since the UCS Platform Emulator ships with redirect of http to https turned on, let's turn it off. At the command prompt type

    Get-UcsHttp

The output will look like this

AdminState    : enabled
Descr         : HTTP Service
Name          : http
OperPort      : 80
PolicyLevel   : 0
PolicyOwner   : local
Port          : 80
Proto         : tcp
RedirectState : enabled
Sacl          :
Ucs           : UCSPE-192-168-65-143
Dn            : sys/svc-ext/http-svc
Rn            : http-svc
Status        :
XtraProperty  : {}

Notice that the attribute RedirectState is set to enabled

It is possible that the RedirectState attribute is already set to disabled

At the command prompt type

Get-UcsHttp | Set-UcsHttp -RedirectState disabled -Force

The output will look like this

AdminState    : enabled
Descr         : HTTP Service
Name          : http
OperPort      : 80
PolicyLevel   : 0
PolicyOwner   : local
Port          : 80
Proto         : tcp
RedirectState : disabled
Sacl          :
Ucs           : UCSPE-192-168-65-143
Dn            : sys/svc-ext/http-svc
Rn            : http-svc
Status        :
XtraProperty  : {}

The attribute RedirectState has been set to disabled

Let's breakdown what this command does

  1. Get-UcsHttp gets from UCS manager the http communication object. The Object ClassId of the http communication object is commHttp the dn is sys/svc-ext/http-svc
  2. Set-UcsHttp has a default pipeline object of commHttp so the object does not need to be spcified. Set-UcsHttp will look in the pipeline for the required object. The -RedirectState parameter is set to disabled
  3. without the -Force parameter you would have been prompted for confirmation.

    As a final step run Get-Help on Get-UcsHttp and Set-UcsHttp at the command prompt type

    Get-Help Get-UcsHttp

    Get-Help Set-UcsHttp

This is the end of exercise 2.