« Back to Microsoft Discussions

Setting VSAN / VLAN on vNIC / vHBA templates with 0.9.0.1

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
All,
With the previous version of UCS PowerShell, you could set the VSAN when creating a vHBA template BUT you couldn't set the template type to updating in the same command.
 
In the new powershell, you can set all of the options in one Add- command EXCEPT for setting the VSAN (which, to me, makes both the Add- and Set- command for vHBA templates completely useless). Don't get me wrong, there have been some MUCH welcome improvements and I have moved alot of my custom XML code to standard cmdlets, but I can't seem to find this same functionality in the new PoSh update.
 
This situation is similar with vNIC Templates, now you can do just about everything with one command EXCEPT add vlan's to the template.
 
Was this by design or I am missing something that might have been exported to another cmdlet?
 
Here is the PoSh Code of what I am trying to do:
 
vHBA Templates
Create a VSAN and Create an updating vHBA Template for that VSAN
Old PowerShell
 Add-Vsan -VSANName "VSAN-$vsanID-A" -ID $vsanID -FCoEID $fcoeID -FI A -DefaultZoning $false

 Add-VhbaTemplate -VhbaTemplateName vHBA-A1 -Vsan "VSAN-$vsanID-A" -Org org-root/org-VMware -Fi A
 Set-VhbaTemplate -VhbaTemplateName vHBA-A1 -Type Updating -DataFieldSize 2048 -WwpnPool sanWwpnPoolNameA1 -Org org-root/org-VMware -FI A -Force
 
New PowerShell
 $fabricA = Get-UcsFabricSanCloud -Id A

 Add-UcsVsan -Name "VSAN-$vsanID-A" -Id $vsanID -FcoeVlan $fcoeID -FabricSanCloud $fabricA -DefaultZoning disabled

 Add-UcsVhbaTemplate -Name vHBA-A1 -IdentPoolName sanWwpnPoolNameA1 -MaxDataFieldSize 2048 -SwitchId A -TemplType updating-template -Org org-root/org-VMware
 I want to create this with the VSAN defined without using an invoke XML as I was before


vNIC Templates
Create an updating vNIC Template, Create a VLAN, and add that VLAN to the template
Old PowerShell
 Add-VnicTemplate -VNICTemplateName $lanVnicTemplateNameA1 -MacPoolName $lanMacNameA1 -FI A -FailOver NO -Org org-root/org-VMware
 Add-Vlan -VLANName "VLAN-$vlanID" -ID $vlanID -FI Dual
 Set-VnicTemplate -VNICTemplateName $lanVnicTemplateNameA1 -VLANName "VLAN-$vlanID" -MacPoolName $lanMacNameA1 -NetcntrlPolicyName $lanNetConPol1 -FI A -Org org-root/org-VMware -Force
 Invoke-XmlCommand -XMLStringList "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicLanConnTempl dn='org-root/org-VMware/lan-conn-templ-$lanVnicTemplateNameA1' status='modified' switchId='A' templType='updating-template'></vnicLanConnTempl></inConfig></configConfMo>"


New PowerShell
 Add-UcsVnicTemplate -Name $lanVnicTemplateNameB2 -IdentPoolName $lanMacNameB2 -NwCtrlPolicyName $lanNetConPol1Name -SwitchId B -TemplType updating-template -Org org-root/org-VMware
 $lanCloud = Get-UcsLanCloud

 Add-UcsVlan -Name "VLAN-$vlanID" -Id $vlanID -LanCloud $lanCloud
 I want to be able to use a Set command to add the VLAN I create to the vNIC template as I was before

Hi Jonathan,

Your only option at this point is the Invoke-XML, now called Invoke-UcsXml. Here is an example of the new cmdlet


PS C:\Program Files\Cisco\Cisco UCS PowerTool> Add-UcsVhbaTemplate -Name vHBA-A-Side -SwitchId A -TemplType updating-template

Descr :
IdentPoolName :
MaxDataFieldSize : 2048
Name : vHBA-A-Side
NwCtrlPolicyName :
OperIdentPoolName :
OperQosPolicyName :
OperStatsPolicyName :
PinToGroupName :
QosPolicyName :
StatsPolicyName : default
SwitchId : A
Target : adaptor
TemplType : updating-template
Dn : org-root/san-conn-templ-vHBA-A-Side
Rn : san-conn-templ-vHBA-A-Side
Status : created
Ucs : ucs-as-rtp-6140-01



PS C:\Program Files\Cisco\Cisco UCS PowerTool> invoke-ucsxml -XmlQuery "<configConfMo><inConfig><vnicFcIf dn='org-root/san-conn-templ-vHBA-A-Side/if-default' name='VSAN100' /></inConfig></configConfMo>"

<configConfMo dn="" cookie="1322598760/321871d6-ac69-4bfe-8907-71fac409303d" response="yes"> <outConfig> <vnicFcIf dn="org-root/san-conn-templ-vHBA-A-Side/if-default" initiator="00:00:00:00:00:00:00:00" name="VSAN100" operState="indeterminate" operVnetDn="" operVnetName="" owner="logical" status="created" switchId="A" type="fc" vnet="1"/> </outConfig> </configConfMo>


PS C:\Program Files\Cisco\Cisco UCS PowerTool> Add-UcsVhbaTemplate -Name vHBA-B-Side -SwitchId B -TemplType updating-template

Descr :
IdentPoolName :
MaxDataFieldSize : 2048
Name : vHBA-B-Side
NwCtrlPolicyName :
OperIdentPoolName :
OperQosPolicyName :
OperStatsPolicyName :
PinToGroupName :
QosPolicyName :
StatsPolicyName : default
SwitchId : B
Target : adaptor
TemplType : updating-template
Dn : org-root/san-conn-templ-vHBA-B-Side
Rn : san-conn-templ-vHBA-B-Side
Status : created
Ucs : ucs-as-rtp-6140-01


PS C:\Program Files\Cisco\Cisco UCS PowerTool> invoke-ucsxml -XmlQuery "<configConfMo><inConfig><vnicFcIf dn='org-root/san-conn-templ-vHBA-B-Side/if-default' name='VSAN200' /></inConfig></configConfMo>"

<configConfMo dn="" cookie="1322598760/321871d6-ac69-4bfe-8907-71fac409303d" response="yes"> <outConfig> <vnicFcIf dn="org-root/san-conn-templ-vHBA-B-Side/if-default" initiator="00:00:00:00:00:00:00:00" name="VSAN200" operState="indeterminate" operVnetDn="" operVnetName="" owner="logical" status="created" switchId="A" type="fc" vnet="1"/> </outConfig> </configConfMo>

I had thought perhaps that I would be able to use the AddChild member method of the vHBA Template, so I

- Created the template with Add-UcsVhbaTemplate
- Retrieved the template with Get-UcsVhbaTemplate
- Created a new object of type Cisc.Ucs.vnicFcIf with a properties hashtable that contained the name of the VSAN, using New-Object
- Used the AddChild member method of the vHBA template
- Pushed the updated vHBA template object to the UCS with Set-UcsVhbaTemplate

But that didn't work, so I used Invoke-UcsXml

Hope that helps
John

John,
Thanks for the reply. I ended up doing something similar and it seems to work like a charm.

Any idea when the next revision of the PoSh toolkit will be release and if this will be fixed?

Thanks,
Jonathan

vNIC Templates:

$lanCloud = Get-UcsLanCloud
foreach ($vlan in $lanVLANsGlobal)
{
$vlanID = "{0emoticon4}" -f $vlan
$vlanName = "VLAN-$vlanID"
WriteLog "Creating $vlanName"
Add-UcsVlan -Name $vlanName -Id $vlanID -LanCloud $lanCloud

WriteLog "Assign Global $vlanName to Fabric A vNIC Templates"
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicLanConnTempl dn='org-root/org-VMware/lan-conn-templ-$lanVnicTemplateNameA1' status='created,modified'><vnicEtherIf defaultNet='no' rn='if-$vlanName'></vnicEtherIf></vnicLanConnTempl></inConfig></configConfMo>"
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicLanConnTempl dn='org-root/org-VMware/lan-conn-templ-$lanVnicTemplateNameA2' status='created,modified'><vnicEtherIf defaultNet='no' rn='if-$vlanName'></vnicEtherIf></vnicLanConnTempl></inConfig></configConfMo>"

WriteLog "Assign Global $vlanName to Fabric B vNIC Templates"
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicLanConnTempl dn='org-root/org-VMware/lan-conn-templ-$lanVnicTemplateNameB1' status='created,modified'><vnicEtherIf defaultNet='no' rn='if-$vlanName'></vnicEtherIf></vnicLanConnTempl></inConfig></configConfMo>"
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicLanConnTempl dn='org-root/org-VMware/lan-conn-templ-$lanVnicTemplateNameB2' status='created,modified'><vnicEtherIf defaultNet='no' rn='if-$vlanName'></vnicEtherIf></vnicLanConnTempl></inConfig></configConfMo>"
}

vHBA Template:

$fabricA = Get-UcsFabricSanCloud -Id A
foreach ($vsan in $sanVSANsA)
{
$vsanID = "{0emoticon4}" -f $vsan
$A1vHBA = $sanVhbaTemplateNameA1 + "-" + $vsanID
$A2vHBA = $sanVhbaTemplateNameA2 + "-" + $vsanID
$fcoeID = $vsan + 2000
$vsanName = "VSAN-$vsanID-A"

# Add VSAN
Add-UcsVsan -Name $vsanName -Id $vsanID -FcoeVlan $fcoeID -FabricSanCloud $fabricA -DefaultZoning disabled

# Create New vHBA Templates
Add-UcsVhbaTemplate -Name $A1vHBA -IdentPoolName $sanWwpnPoolNameA1 -MaxDataFieldSize 2048 -SwitchId A -TemplType updating-template -Org org-root/org-VMware -Descr "VMware vHBA Template for Site $internalSiteID / Pod $internalPodID / Fabric A / Adapter 1"
Add-UcsVhbaTemplate -Name $A2vHBA -IdentPoolName $sanWwpnPoolNameA2 -MaxDataFieldSize 2048 -SwitchId A -TemplType updating-template -Org org-root/org-VMware -Descr "VMware vHBA Template for Site $internalSiteID / Pod $internalPodID / Fabric A / Adapter 2"

# Set VSAN on new vHBA Templates
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicSanConnTempl dn='org-root/org-VMware/san-conn-templ-$A1vHBA' status='modified'><vnicFcIf name='$vsanName' rn='if-default'></vnicFcIf></vnicSanConnTempl></inConfig></configConfMo>"
Invoke-UcsXml -XmlQuery "<configConfMo cookie='$curConUCS.cookie'><inConfig><vnicSanConnTempl dn='org-root/org-VMware/san-conn-templ-$A2vHBA' status='modified'><vnicFcIf name='$vsanName' rn='if-default'></vnicFcIf></vnicSanConnTempl></inConfig></configConfMo>"
}

Hi Jonathan,

With the new version of the Powershell DLLs, you can add Vlan to VnicTemplate using the cmdlet Add-UcsVnicInterface.

Add-UcsVnicInterface -VnicTemplate <VnicLanConnTempl> [-Name] <string> [-DefaultNet <string>] [<CommonParameters>]

Retrieve the Vnic Template using the Get-UcsVnicTemplate cmdlet and pass that template as the parameter to Add-UcsVnicInterface cmdlet.

$vnicTemplate = Get-UcsVnicTemplate -Name $vnicTemplateName
Add-UcsVnicInterface -VnicTemplate $vnicTemplate -Name $vlanName

Regards
Vani