cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

8440
Views
1
Helpful
11
Replies
snoopj123
Enthusiast

Anyone using UCS Central with UCS Director? I have some PowerShell scripts to share, if you do...

Just trying to gauge how many people are using UCS Central with UCS Director right now.  I'm finding the included tasks are very limited in what they can do (especially if you have UCS-enabled C-Series).  I've created some PowerShell (with UCS Central's PowerTool) that may come in handy with associating and disassociating global service profiles, in case anyone is interested.  I've been able to use these to get past the Java errors when dealing with C-Series equipment (Java error seems to indicate that the API call is hardwired for Blade servers only and fails the workflow).

You check out the scripts on my GitHub repo @ snoopj123/UCS-Director · GitHub

I've provided the Associate and Disassociate PowerShell scripts.  I highly recommend using this task:UCSD PowerShell Tasks with Rollback to provide rollback capabilities to the script to clean up the global service profile when rolling back through the overall workflow.

--j

11 REPLIES 11
Matthew Faiello
Cisco Employee

Jon - Thanks!

Would appreciate you advising “Which” tasks you’d like to see get added to the Task Library for UCS Central, that are only currently supported in UCS Manager.

Regards,

Matt

Let me go through some of my other PowerShell scripts that I've developed for use with UCS Director and get those back to you.  Right now, I've done a lot of fixing of existing tasks that just don't go far enough (like the C-Series errors with the associate/disassociate of a global service profile).  Been working with TAC on a script that I'm using to fix an issue with (potentially) a timing problem with the UCS Central task for creating a global service profile from a global service profile template.  In that one, the information returned back to UCS Director for MACs/WWPNs/etc, that should be coming back with global pool information, is all coming back as "derived".

I know I've worked with the UCS Central PowerTool to do things like setting VLAN Org permissions when adding a VLAN to UCS Central.  I've also done a few small scripts related to Power On/Power Off from a UCS Central perspective (instead of using the UCS Manager ones in UCS Director, which I could do, but I'd rather limit my UCS Manager specifics since Central will and should handle those requests).

--j

Hi Jon,

I've written a couple of deployment PS scripts with UCSC and as of the 1.3x release I've noticed that immediately querying a newly created global service profile returns "derived."  I had to add a 10 second sleep into the scripts to return the proper vHBA WWPNs.

-Alex

I noticed the same thing.  I put it up to a 15 seconds sleep command in there before refreshing the service profile I just created from template.  I have an active TAC case on this as well.  Good to see someone else was seeing the same problem in 1.3.

--j

Hello Jon, Alex,

Please share the script where you see issue. We will debug and revert.

Thank you,

Nitin

You should be able to reproduce pretty easily.

##Deploy from Template

Get-UcsCentralServiceProfile -name $profileTemplate | Add-UcsCentralServiceProfileFromTemplate -DestinationOrg (Get-UcsCentralOrg -Level root) -NamePrefix $serverName -Count 1

##Set variables for zoning

    Sleep 10 # This is needed to actually return any information below

    $vNodeName = Get-UcsCentralServiceProfile -name $serverName | Get-UcsCentralVnicFcNode | select addr

    $vHBA1 = Get-UcsCentralServiceProfile -name $serverName | Get-UcsCentralVhba -name vHBA1 | select addr

    $vHBA2 = Get-UcsCentralServiceProfile -name $serverName | Get-UcsCentralVhba -name vHBA2 | select addr

As Alex said, you can reproduce this rather easily.  I got nearly an 80% failure rate using the UCS Director task "Create Global Service Profile from Template" in the UCS Central tasks.  With UCS Central 1.3, something has happened in which the returning service profile information is coming back with nothing but "undefined" for many of the values that task is supposed to provide us (many tied to global pools...like MAC pools, WWPN pools, etc).

We've "solved" the issue by writing custom PowerShell scripts to replicate the same functionality using the UCS Central PowerTool and added simple sleep commands into the code to allow for whatever is now taking extra time to populate the values for the HBAs, NICs, etc.  Alex is using 10 seconds and I'm using 15 seconds (I had one failure with 10 seconds and bumped to 15 and have had zero issues since).

My code is below:

Import-Module CiscoUcsCentralPs
$ucsc_org = ($args[0].Split(";"))[1]   # Passing a UCS Director variable and getting the Central Org DN from it
$ucsc_account = ($args[0].Split(";"))[0]  # Passing a UCS Director variable and getting the UCS Central account (if multiples)
$uscs_gspt = ($args[1].Split(";"))[2]  # Passing a UCS Director variable and getting the Global Service Profile Template DN from it
$customer_id = $args[2]  # Passing a string for usage in creating the name of the service profile
$device_sid = $args[3]  # Passing a string for usage in creating the name of the service profile
$ucsc_username = "<insert UCS Central username>"
$ucsc_password = ConvertTo-SecureString -String "<insert UCS Central account password or variable, if passing through UCS Director" -AsPlainText -Force
$ucsc_credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ucsc_username, $ucsc_password
$ucsc_conn = Connect-UcsCentral -Name <insert UCS Central FQDN or IP address> -Credential $ucsc_credential
$gsp_name = $customer_id + "-" + $device_sid   # Create combined global service profile name
$new_gsp = Get-UcsCentralServiceProfile -Dn $uscs_gspt | Add-UcsCentralServiceProfileFromTemplate -NamePrefix $gsp_name -Count 1 -DestinationOrg (Get-UcsCentralOrg -Dn $ucsc_org) | Rename-UcsCentralServiceProfile -NewName $gsp_name   # Create GSP from template and rename to remove "1" from end of name
Start-Sleep 15   # Sleep for 15 seconds to allow for UCS Central to process global pool values into GSP
$new_gsp = Get-UcsCentralServiceProfile -Name $new_gsp.Name   # Reload the service profile
$ucsd = @{}  # Create our hashtable to store values
# Create the hashtable values for the various parts of the global service profile to be used by later UCS Director tasks
$ucsd["VNIC1_MAC"] = ($new_gsp | Get-UcsCentralVnic -Name ESX_Mgmt_A).Addr  # MAC for Mgmt NIC/PXE Boot NIC, named ESX_Mgmt_A
$ucsd["VNIC2_MAC"] = ($new_gsp | Get-UcsCentralVnic -Name ESX_Mgmt_B).Addr  # Secondary MAC for Mgmt NIC, named ESX_Mgmt_B
$ucsd["VHBA1_WWPN"] = ($new_gsp | Get-UcsCentralvHBA -Name vHBA1).Addr  # WWPN of vHBA1, used for zoning, named vHBA1
$ucsd["VHBA2_WWPN"] = ($new_gsp | Get-UcsCentralvHBA -Name vHBA2).Addr  # WWPN for vHBA2, used for zoning, named vHBA2
$ucsd["VHBA1_WWN"] = ($new_gsp | Get-UcsCentralvHBA -Name vHBA1).NodeAddr + ":" + ($new_gsp | Get-UcsCentralvHBA -Name vHBA1).Addr  # WWN used for EMC initiator creation for vHBA1
$ucsd["VHBA2_WWN"] = ($new_gsp | Get-UcsCentralvHBA -Name vHBA2).NodeAddr + ":" + ($new_gsp | Get-UcsCentralvHBA -Name vHBA2).Addr  # WWN used for EMC initiator creation for vHBA2
$ucsd["ServiceProfileIdentity"] =  $ucsc_account + ";" + $ucsc_org + ";" + $new_gsp.Dn   # UCS Central Service Profile Identity, in UCS Director variable format
return $ucsd   # Return hashtable to UCS Director for processing with custom task

I'll also add things with organzation vNIC templates and adding VLANs to them.  There's very little in UCS Director's UCS Central tasks that can work with vHBA or vNIC templates and adding/removing things from them.

Also, manipulating boot policy specifics.  I can apply a boot policy to a global service profile template, but I can't change things within.  For instance, setting a boot policy for SAN booting.  I've resorted to using the UCS Central PowerTool to perform this operation for me.  Also, the same can be said about creating and deleting a boot policy.

Here's a very rough example of what I do for SAN booting ESX hosts, in terms of UCS Central PowerTool code:

$ucsc_boot_policy_name = $customer_id + "-" + $sid

$boot_policy = Get-UcsCentralBootPolicy -Org (Get-UcsCentralOrg -Dn $ucsc_org) -Name $ucsc_boot_policy_name

$cmd_1 = $boot_policy | Add-UcsCentralLsbootStorage -Order 1

$cmd_2 = $boot_policy | Add-UcsCentralLsbootLan -Order 2

$cmd_3 = $boot_policy | Get-UcsCentralLsbootStorage | Add-UcsCentralLsbootSanImage -Type "primary" -VnicName vHBA1

$cmd_4 = $boot_policy | Get-UcsCentralLsbootStorage | Get-UcsCentralLsbootSanImage -VnicName vHBA1 | Add-UcsCentralLsbootSanImagePath -Type "primary" -Lun 0 -Wwn $emc_vnx_wwpn_FabA_P0

$cmd_5 = $boot_policy | Get-UcsCentralLsbootStorage | Get-UcsCentralLsbootSanImage -VnicName vHBA1 | Add-UcsCentralLsbootSanImagePath -Type "secondary" -Lun 0 -wwn $emc_vnx_wwpn_FabB_P0

$cmd_6 = $boot_policy | Get-UcsCentralLsbootStorage | Add-UcsCentralLsbootSanImage -Type "secondary" -VnicName vHBA2

$cmd_7 = $boot_policy | Get-UcsCentralLsbootStorage | Get-UcsCentralLsbootSanImage -VnicName vHBA2 | Add-UcsCentralLsbootSanImagePath -Type "primary" -Lun 0 -Wwn $emc_vnx_wwpn_FabA_P1

$cmd_8 = $boot_policy | Get-UcsCentralLsbootStorage | Get-UcsCentralLsbootSanImage -VnicName vHBA2 | Add-UcsCentralLsbootSanImagePath -Type "secondary" -Lun 0 -Wwn $emc_vnx_wwpn_FabB_P1

$cmd_9 = $boot_policy | Get-UcsCentralLsbootLAN | Add-UcsCentralLsbootLanImagePath -Type "primary" -VnicName ESX_Mgmt_A

Where I pass into the Execute PowerShell task plenty of variables related to the EMC array that I'm using for this.  Again, a few things that I'm doing on the UCS Central level.  Especially since I let UCS Central control nearly all aspects of UCS Manager.

--j

Jon - Very Valuable Feedback, Thank you…

I’ll directly coordinate same with the UCS Director Product Manager.

Regards,

Matt

thomsonac
Enthusiast

I know it's been about a year but with the latest release of 1.5(1b), I've had to up my sleep to 30 seconds to avoid all issues.  Eventually my original 10 second sleep stopped working, went to 15 which worked for a while but every subsequent UCSC release requires more and more time before results are returned.

Inside the GUI this can be seen on the Global Service Profile page and the little gear icon and "Configuring" in the top right.  I timed a couple of new profile creations in the GUI and got anywhere from ~18 seconds to ~22 seconds so opted for a 30 second sleep.

Not the end of the world, for sure, but annoying since it used to work almost immediately.  If it were up to me, I would not return a success exit code inside powershell until the profile is _actually_ created.

Would agree there (about the exit code).  This all boils down to a broken API call.  You have to figure the XML API call behind the scene isn't exactly validating data, otherwise, we wouldn't have to worry about wrapping sleep commands and refresh commands around it in PoSH.

It is rather disheartening to hear that the sleep command is getting longer and longer to ensure template cloning finishes properly.

I'm half wondering if I need to log a defect on this again.

Content for Community-Ad
This widget could not be displayed.