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

What's the command to assign a Service Profile to a Blade?

67
Views
0
Helpful
0
Comments
Advisor
This document was generated from CDN thread

Created by: John Kennedy on 31-05-2011 07:56:18 PM
For some reason, I can't determine exacly how to take the service profiles I have and attach/assign them to blades or server pools. Documentation isn't guiding me, and I can't seem to guess. 

Subject: RE: What's the command to assign a Service Profile to a Blade?
Replied by: Joshua Heller on 31-05-2011 09:16:19 PM
Hey John -

Thanks for the post.  We've scoped a cmdlet called set-spassociation but it didn't make this release.  In the meantime, you can use the invoke-xmlcommand cmdlet.  That will essentially let you do anything in UCSM via PowerShell - even if we haven't written a specific cmdlet for it.  Here's an example of how to do what you're asking:

Assuming you're already connected to a UCS cluster via PowerShell (connect-ucsm), the command would look like this:

PS>invoke-xmlcommand -xmlstringlist "<configConfMo inHierarchical="no"><inConfig><lsServer dn="org-root/ls-HyperV-Host2"><lsBinding pnDn="sys/chassis-1/blade-5" rn="pn" /></lsServer></inConfig></configConfMo>"

You'll obviously want to substitute the service profile name (ls-HyperV-Host2 in my example --- remember to keep the ls- as a prefix to your 'english' SP name) and destination server DN (I used sys/chassis-1/blade-5).

If that's too ugly (which I'd understand), you can try plopping the XML into a text file and calling it via PoSh -- same cmdlet, just use the '-filename' parameter and specify the path to the XML content.

Hope that helps!!

Josh

Subject: RE: What's the command to assign a Service Profile to a Blade?
Replied by: Kevin Murphy on 01-06-2011 11:16:06 AM
Most of my UCS powershell scripts relies on custom functions that would be too much and haven't been tested enough to post here. I am in the process of trying to reformat them to utilize the UCS cmdlets. Here is a section of code that I have used and works. It inputs from a CSV that has headers; Servers,ChassisID,BladeID. Servers is the name of the service profile, the other two are self explanatory...I hope. I utilize the Get-Org cmdlet to save having to input the DN myself incase it was a sub-sub-organization.  Note here, I tried using Get-Org with just an org name and the -recursive option and it didn't return anything. Not sure why so I still have to play with but I have only had these for a couple days.

A comment on Joshua's code. I don't think that will work because he doesn't have all the extra quotations escaped with another set of quotes. So to take just a bit of that line the first quote starts the string but then to the cmdlet that string stops after the first equal sign and no is a separate item and so on. Again this is an assumption and I haven't tested it but from my understanding that line won't work as you would think. I would suggest something like my line below where each quote inside the XML is escaped with another quote. Just food for thought as we begin to explore the use of Invoke-Xmlcommand.

 1
 2###### INPUT files  ######
 3#  $Servers CSV should have headers for Server,ChassisID,BladeID
 4$Servers = Import-Csv -Path "./inputs/STC21717UCS201.csv"
 5$org = Get-Org -Org "root/ORGNAME"
 6foreach ($server in $Servers)
 7{
 8    $xmlcmd = "<configConfMos cookie=""$($CurrentUCSMInstance.Cookie)"" inHierarchical=""false""><inConfigs><pair key=""$($org.dn)/""><lsServer dn=""$($org.dn)/ls-$($server.server)""><lsBinding pnDn=""sys/chassis-$($server.chassisID)/blade-$($server.BladeID)"" /></lsServer></pair></inConfigs></configConfMos>"
 9    Invoke-XmlCommand -XMLStringList $xmlcmd
10}


Subject: RE: What's the command to assign a Service Profile to a Blade?
Replied by: Joshua Heller on 01-06-2011 11:29:12 AM
Kevin -

Good point - the text I pasted was from my text file (where the quotes won't escape).  I should have replaced those with single quotes within the overall XML string.  That works well.

Also - I noticed that you included the cookie in your string - once you've established the connection to UCS, that connection object (and the cookie it holds) gets referenced in subsequent calls from the toolkit.  So you don't need to reference the hand....

Thanks!
Josh

Subject: RE: What's the command to assign a Service Profile to a Blade?
Replied by: Kevin Murphy on 01-06-2011 12:45:45 PM
Thanks for the info Josh. I was wondering if that would be handled or not but I figured better safe than sorry. That is good to know going forward.

Thanks
CreatePlease to create content
This widget could not be displayed.