Sunday May 20 , 2012

Cisco UCS vHBA Persistent Binding

Host-based zoning is known as persistent binding in Cisco UCS environments. When running VMware, the SCSI Target ID for a LUN is dictated by the order in which the ESXi host discovers the subsystems at system startup. This can change because of the addition or removal of devices in the host.

Fibre channel targets are assigned their World Wide Node Name (WWNN) at the time of loop initialization. The SCSI Target ID for that target is assigned by the device driver when the device first discovers. It is possible for the WWNN to change between one loop initialization and the next one. Each time that the host boots or a target is added/removed from the FC, the loop will be forced to reinitialize.

Without persistent binding the SCSI Target ID of a LUN may change upon reboot of the host. This is complicated further when multipathing is used.

When persistent binding is configured and the host is rebooted, it consistently maintains the same SCSI Target ID as the last time because the driver software maps the SCSI Target ID to the new WWNN.

The advantage of persistent binding is apparent. Enabling persistent binding is useful when using the same target across multiple hosts and maintaining a constant SCSI Target ID on all the hosts, when the host needs to assign its own SCSI Target ID, or when it is required that device paths do not change.

To enable persistent binding on a Cisco UCS vHBA, perform the following steps:

Step 1: Show vHBAs attached to the desired Service Profile

Panek - Cisco UCS Show vHBAs

Step 2: Enable Persistent Binding on the desired vHBA

Panek - Cisco UCS Enable Persistent Binding

Step 3: Confirm that Persistent Binding was enabled on the desired vHBA

Panek - Cisco UCS Persistent Binding Enabled

To disable persistent binding on a Cisco UCS vHBA, perform the following steps:

Step 1: Show vHBAs attached to the desired Service Profile

Panek - Cisco UCS Show vHBAs

Step 2: Disable Persistent Binding on the desired vHBA

Panek - Cisco UCS Disable Persistent Binding

Step 3: Confirm that Persistent Binding was disabled on the desired vHBA

Panek - Cisco UCS Persistent Binding Disabled

 

Cisco UCS PowerShell Script for Mass VLAN Provisioning

Occasionally there is a need to add a large amount of VLANs to Cisco UCS environments. Depending on the naming scheme and amount of VLANs that can be a time consuming activity if you have to add each one individually. Below is a method of adding them using a PowerShell Script that does not require anything other than a CSV of the desired VLANs and a machine connected to UCS with PowerShell installed on it.

Step 1: Create a CSV in the same format as below and save it

name,id,defaultNet
PANEK_100,100,no
PANEK_101,101,no
PANEK_102,102,no
PANEK_103,103,no
PANEK_104,104,no
PANEK_105,105,no
PANEK_106,106,no
PANEK_107,107,no
PANEK_108,108,no
PANEK_109,109,no

Step 2: Run the following PowerShell script after editing the variables “ucsUrl”, “ucsUser”, “ucsPassword”, and “location”

### Needed variables
$ucsUrl = “10.1.1.1″
$ucsUser = “admin”
$ucsPassword = “adminpw”
$location = “.\panek_vlan_list.csv”

### Function ucs_post
### Required variables: $url = UCS Url $data = XML to send to UCS
### Returns: XML response from UCS
function ucs_post($url,$data) {
$request = [System.Net.HttpWebRequest] [System.Net.HttpWebRequest]::Create(“https://” + $url +”/nuova”)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$request.Method = “POST”
$request.ContentType = “text/xml”
$sendData = new-object System.IO.StreamWriter($request.GetRequestStream())
$sendData.Write($data)
$sendData.Close()
$response = $request.GetResponse()
$sr = new-object System.IO.StreamReader($response.GetResponseStream())
$xml = [xml] $sr.ReadToEnd()
return $xml
}

### Function ucs_login
### Required variables: $inName = UCS username $inPassword = UCS password $url = UCS url
### Returns: Cookie after login
### Todo: Error Checking
function ucs_login($inName, $inPassword, $url) {
$aaaLogin = “
$xml = ucs_post $url $aaaLogin
$outCookie = $xml.aaaLogin.outCookie
return $outCookie
}

### Function ucs_logout
### Required variables: $url = UCS url $inCookie = Cookie for session to logout
### Returns: Status of logout
### Todo: Error Checking
function ucs_logout($url, $inCookie) {
$aaaLogout = “
$xml = ucs_post $url $aaaLogout
$outStatus = $xml.aaaLogout.outStatus
return $outStatus
}

function configure_vlans($url, $inCookie, $vlans) {
$data = “
$data += “
foreach ($vlan in $vlans){
$data += “
$data += “
$data += “

}
$data += “

$data += “

$xml = ucs_post $url $data
return $xml
}

#function retrieve_vlans($url, $inCookie) {
# $data = “
# $xml = ucs_post $url $data
# $vlans = $xml.configResolveClass.outConfigs
# $a = @()
# foreach ($v in $vlans.childnodes) {
# $vlan = New-Object object
# $vlan | Add-Member NoteProperty name $v.name
# $vlan | Add-Member NoteProperty id $v.id
# $a += $vlan
# }
# $a
# Write-host $a.count
#}

$vlans = Import-CSV $location

$cookie = ucs_login $ucsUser $ucsPassword $ucsUrl
configure_vlans $ucsUrl $cookie $vlans
#retrieve_vlans $ucsUrl $cookie
ucs_logout $ucsUrl $cookie

Step 3: Confirm in the Cisco UCS Manager GUI that the proper VLANs were created

Panek - UCS GUI VLAN List

 

Connect