Service Profiles and Service Profile Templates in Cisco UCS PowerTool

June 10, 2013 in Systems3 minutes

I had a few scripts that were written WAY before PowerTool was out of beta, and the only way I knew how to generate a Service Profile Template was to use manual XML calls. For instance:

  1$cmd = "<configConfMos inHierarchical='true'> 
  2      <inConfigs>
  3          <pair key='org-root/org-" + $orgName + "/ls-" + $serviceProfileName + "' >    
  4              <lsServer
  5                  agentPolicyName=''
  6                  biosProfileName=''
  7                  bootPolicyName='" + $bootPolicyName + "'
  8                  descr='' 
  9                  dn='org-root/org-" + $orgName + "/ls-" + $serviceProfileName + "' 
 10                  dynamicConPolicyName=''
 11                  extIPState='none'
 12                  hostFwPolicyName=''
 13                  identPoolName='" + $UUID_POOL_NAME + "'
 14                	localDiskPolicyName='default'
 15                	maintPolicyName='default'
 16                	mgmtAccessPolicyName=''
 17                	mgmtFwPolicyName=''
 18                	name='" + $serviceProfileName + "'
 19                	powerPolicyName='default'
 20                	scrubPolicyName=''
 21                	srcTemplName=''
 22                	statsPolicyName='default'
 23                	status='created'
 24                	type='initial-template'
 25                	usrLbl=''
 26                	uuid='0'
 27                	vconProfileName=''>
 28                	<vnicEther
 29                		adaptorProfileName='VMWare'
 30                		addr='derived'
 31                		adminVcon='any'
 32                		identPoolName=''
 33                		mtu='1500'
 34                		name='" + $VNIC_A_NAME + "'
 35                		nwCtrlPolicyName=''
 36                		nwTemplName='" + $VNIC_TEMPLATE_A_NAME + "'
 37                		order='3'
 38                		pinToGroupName=''
 39                		qosPolicyName=''
 40                		rn='ether-" + $VNIC_A_NAME + "'
 41                		statsPolicyName='default'
 42                		status='created'
 43                		switchId='" + $switchId + "'>
 44                		</vnicEther>
 45                		<vnicEther
 46                			adaptorProfileName='VMWare'
 47                			addr='derived'
 48                			adminVcon='any'
 49                			identPoolName=''
 50                			mtu='1500'
 51                			name='" + $VNIC_B_NAME + "'
 52                			nwCtrlPolicyName=''
 53                			nwTemplName='" + $VNIC_TEMPLATE_B_NAME + "'
 54                			order='4'
 55                			pinToGroupName=''
 56                			qosPolicyName=''
 57                			rn='ether-" + $VNIC_B_NAME + "'
 58                			statsPolicyName='default'
 59                			status='created'
 60                			switchId='" + $switchId + "'>
 61                		</vnicEther>
 62                		<vnicFcNode
 63                			addr='pool-derived'
 64                			identPoolName='" + $WWNN_POOL_NAME + "'
 65                			rn='fc-node' >
 66                		</vnicFcNode>
 67                		<vnicFc
 68                			adaptorProfileName='VMWare'
 69                			addr='derived'
 70                			adminVcon='any'
 71                			identPoolName=''
 72                			maxDataFieldSize='2048'
 73                			name='" + $VHBA_A_NAME + "'
 74                			nwTemplName='" + $VHBA_TEMPLATE_A_NAME + "'
 75                			order='1'
 76                			persBind='disabled'
 77                			persBindClear='no'
 78                			pinToGroupName=''
 79                			qosPolicyName=''
 80                			rn='fc-" + $VHBA_A_NAME + "'
 81                			statsPolicyName='default'
 82                			status='created'
 83                			switchId='" + $switchId + "'>
 84                		</vnicFc>
 85                		<vnicFc
 86                			adaptorProfileName='VMWare'
 87                			addr='derived'
 88                			adminVcon='any'
 89                			identPoolName=''
 90                			maxDataFieldSize='2048'
 91                			name='" + $VHBA_B_NAME + "'
 92                			nwTemplName='" + $VHBA_TEMPLATE_B_NAME + "'
 93                			order='2'
 94                			persBind='disabled'
 95                			persBindClear='no'
 96                			pinToGroupName=''
 97                			qosPolicyName=''
 98                			rn='fc-" + $VHBA_B_NAME+ "'
 99                			statsPolicyName='default'
100                			status='created'
101                			switchId='" + $switchId + "'>
102                		</vnicFc>
103                		<lsRequirement
104                			name='" + $SERVER_POOL_NAME + "'
105                			qualifier=''
106                			restrictMigration='no'
107                			rn='pn-req' >
108                		</lsRequirement>
109                		<lsPower
110                			rn='power'
111                			state='down' >
112                		</lsPower>
113                	</lsServer>
114              </pair>
115          </inConfigs>
116      </configConfMos>"
117
118Invoke-UcsXml -XmlQuery $cmd

If most of your script is composed of normal cmdlets, this looks pretty absurd - so if you can avoid calling direct XML, you should. Same thing if you’re trying to create your own PowerTool-esque library (say, with Python instead of bleh PowerShell), you would take these XML calls and hide them away in modular functions so that you can call them with a single command and a few arguments.

Most other templates (like vNIC and vHBA) have a dedicated cmdlet for creating those constructs. For instance:

1    Add-UcsVhbaTemplate -Org $organization -Name "BARE-NONP-B" -Descr "Non-Prod Baremetal Fabric B" -IdentPoolName "WWPN-BARE-NONP-B" -SwitchId A -TemplType "updating-template"

As I tab through the cmdlets that start with “Add-UcsServiceProfile” I noticed there was no “Add-UcsServiceProfileTemplate” as one would expect.

Poking around in the release notes for v1.0 of the PowerTool library, I noticed that one of the new features was the ability to filter Service Profiles based on type (aimed at being able to get all the Service Profiles in the system:

1    # Get all Service Profile Templates.
2    
3    Get-UcsServiceProfile -Filter 'Type -clike *-template' | select Ucs,Dn,Name

So I ran a Get-Help for this cmdlet:

1    -Type <string>
2        Specifies if service profile or service profile template needs to be created. Valid values are: initial-template, instance, updating-template
3    
4        Required?                    true
5        Position?                    named
6        Default value
7        Accept pipeline input?
8        Accept wildcard characters?

So….at least in this version of PowerTool, the same cmdlet is used to create SPs and SPTs, just need to set this “flag” to one of those three options.

Matt Oswalt avatar
Matt Oswalt

Principal Systems Engineer at Cloudflare focused on traffic engineering, Rust, and highly available distributed systems.

Writes primarily about systems programming, Linux networking, machine learning, and lessons learned from building and operating large-scale production systems.