« Back to Microsoft Discussions

Applying changes to Service Profiles in a specific Sub-Organization

Combination View Flat View Tree View
Threads [ Previous | Next ]
I'm trying to figure out how to apply changes to a service profile on a sub-org level. I notice that there is a type of Cisco.Ucs.OrgOrg and that the Get-UcsServiceProfile Cmdlet has a parameter of "-Org". However, I don't know how to use the Cisco.Ucs.OrgOrg type.
Do I need to typecast a string containing the desired sub-org name to type Cisco.Ucs.OrgOrg? If so, how? Any details regarding changes on a sub-org level would be appreciated. I know documentation on PowerTool thus far is scarce as it is, but I can't find ANYTHING about this particular item.
Thanks!

Matt,

OrgOrg is a Managed Object that represents an organization. You need to get a handle to the sub-org.

Say you have an org org-root/org-a/org-b, you should do:

$org = Get-UcsOrg -Level root | Get-UcsOrg -Name a -LimitScope | Get-UcsOrg -Name b -LimitScope

You need the -LimitScope to ensure that you do not pick up an org name "a" anywhere lower in the hierarchy.

Now use $org with the required cmdlets ... like:
Get-UcsServiceProfile -Org $org ... etc.

We support a convenient transforms as can be seen below:
Get-UcsServiceProfile -Org a/b
Get-UcsServiceProfile -Org org-a/org-b
Get-UcsServiceProfile -Org org-root/org-a/org-b

Text transforms are convenient, but it is not the same thing as fetching a real MO, since the MO has the Ucs information embedded in it.

Do let us know if you need any more information.

Thanks,
- bhaskar

Thanks, that helps me understand a little more.
 
I will further clarify my specific needs - there are no nested suborgs, other than what's nested within "root". There are, however, several suborgs at that level and I want to limit my changes to only specific sub-organizations for "layer 8" reasons. As a result, I need my script to not only limit changes to the suborg specified, but allow the user of the script to select it from a list at runtime for ease of use.
 
As a result, I used the following snippet to populate a string array to present these to the user.
 
echo 'Getting organizational units from system...'
foreach ($thisOrg in Get-UcsOrg | Select Name | Out-String)
{
    $UcsOrgs += $thisOrg.ToString()
}


 
I then created a new var to hold the Org object (non-string) and referred to it in my statement to power on service profiles:
 
#This is where I will later build in the ability to choose an org from the list. For now, I'm simply hard coding as string.
$targetedOrgString = 'ORG-A'

echo "Powering on all Service Profiles in $targetedOrgString ..."

$targetedOrg = Get-UcsOrg -Name $targetedOrgString
Get-UcsServiceProfile -Org $targetedOrg | Set-UcsServerPower -State admin-up -Force

 
Any issues with the above segments? Anything I can improve upon?

Hey Matt,

Do you want something like the following,

# Import the UCS PowerTool module
Import-Module CiscoUcsPs

# Connect to the UCS System
$user = "username"
$password = "xxxxx" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object system.Management.Automation.PSCredential($user, $password)
Connect-Ucs ucs-pod01 -Credential $cred

# Get all the available Orgs
$org = Get-UcsOrg -Level root

# Get a list of all the Orgs Present
$orgNameList = $org | Get-UcsOrg -Hierarchy | % {$a = $_.Dn; $b=$a.split("/"); $b[1] } | Get-Unique

# Print the list
Write-Host "Available Orgs:"
Write-Host "=============="
$orgNameList

# Ask user to select one of the Orgs from the above printed list
$selectedOrgName = Read-Host "Select an Org to continue"

# Derive the MO for the selected Org
$selectedOrgMo = Get-UcsOrg -Level root | Get-UcsOrg -Name $selectedOrgName

Write-Host "Powering on all Service Profiles in Org " $selectedOrgName
$selectedOrgMo | Get-UcsServiceProfile | Set-UcsServerPower -State admin-up -Force




Sample Output:
============


Available Orgs:
==============
org-A
org-B
org-destOrg
org-Finance

Select an Org to continue: A

Powering on all Service Profiles in Org A
State : admin-up
Dn : org-root/org-A/ls-Asp/power
Rn : power
Status : modified
Ucs : ucs-pod01

Wow....that's great! Thank you!
 
I was initially pretty discouraged when I discovered the relative lack of practical documentation, but if the forum is or will be anything like this, I'll do my best to contribute so we can get some mean PowerTool scripts going!

Matt,

Just wanted to mention that it was a quick one that i posted.

But you should note that It does not take care of orgs within orgs. And so It also does not take care of same org name appearing at multiple level.

The below should take care of displaying Orgs from all levels.. But Get-Unique will eliminate multiple entries of the same name, even when they are at different Org levels.
$orgNameList = $org | Get-UcsOrg -Hierarchy | % {$a = $_.Rn; if(::IsMatch($a,"org-*")){ $a }} | Get-Unique


Thanks,
Vijay Vikrant Balyan

Matt,

Just wanted to mention that it was a quick one that i posted.

But you should note that It does not take care of orgs within orgs. And so It also does not take care of same org name appearing at multiple level.

The below should take care of displaying Orgs from all levels.. But Get-Unique will eliminate multiple entries of the same name, even when they are at different Org levels.
$orgNameList = $org | Get-UcsOrg -Hierarchy | % {$a = $_.Rn; if(::IsMatch($a,"org-*")){ $a }} | Get-Unique


Thanks,
Vijay Vikrant Balyan

 
Fortunately, although my environment is large, it is not very complex. There are only a few sub-orgs off of the root (so far) so this script is more than sufficient. I did modify it a little to improve usability.

I noticed you're using the following to "import" the UCS PowerTool module:

    # Import the UCS PowerTool module
    Import-Module CiscoUcsPs

 
When I run that I get this:


    Import-Module : The specified module 'CiscoUcsPs' was not loaded because no valid module file was found in any module directory.
 
So instead of running that I have to use this:
 
    cd 'C:\Program Files (x86)\Cisco\Cisco UCS PowerTool'
    .\StartUcsPS.ps1

 
Any idea how I can get that to import the way you are?

Matt:



If you upgrade to version 0.9.8.0 (available on CDN) we have added pathing support for powershell library locations to add the path to the Cisco UCS PowerTool psd1 (CiscoUcsPS.psd1) which is now located in C:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules\CiscoUcsPS. After upgrade if you are still having issues, please let me know.



Thanks,

Eric



From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Wednesday, May 02, 2012 7:56 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Matt Oswalt in Unified Computing UCS Manager - Microsoft Discussions: RE: Applying changes to Service Profiles in a specific Sub-Organization



Matt Oswalt has created a new message in the forum "Microsoft Discussions":

--------------------------------------------------------------
I noticed you're using the following to "import" the UCS PowerTool module:

# Import the UCS PowerTool module
Import-Module CiscoUcsPs

When I run that I get this:


Import-Module : The specified module 'CiscoUcsPs' was not loaded because no valid module file was found in any module directory.

So instead of running that I have to use this:

cd 'C:\Program Files (x86)\Cisco\Cisco UCS PowerTool'
.\StartUcsPS.ps1

Any idea how I can get that to import the way you are?
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/unifiedcomputing/forums/-/message_boards/view_message/5547644>

or simply reply to this email.

Matt:



If you upgrade to version 0.9.8.0 (available on CDN) we have added pathing support for powershell library locations to add the path to the Cisco UCS PowerTool psd1 (CiscoUcsPS.psd1) which is now located in C:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules\CiscoUcsPS. After upgrade if you are still having issues, please let me know.



Thanks,

Eric



 
Thanks, Eric! That did the trick! I have been meaning to apply the new update since it came out just didn't get around to it.