Cisco UCS – Determining ESXi FNIC&ENIC via PowerCLI

The following script allows the user to retrieve a listing of Network (ENIC) & Storage (FNIC) firmware drivers installed on Cisco UCS blades at a per vSphere cluster level. You may download the ‘Cisco_FNIC_ENIC.ps1‘ script here: Cisco_FNIC_ENIC.ps1 (Remove the .doc extension).

The script will begin by prompting you to enter the vCenter IP Address, username and password. A list of all the available clusters residing in vCenter will be returned. Followed by a prompt to enter the vSphere cluster name, from the cluster defined the script will retrieve a per ESXi listing of ENIC&FNIC firmware levels. The script will firstly prompt the user to enable SSH on all the hosts in the cluster:

UCS_FNIC_ENIC1

UCS_FNIC_ENIC2

 

Once you have completed the tasks on the hosts that required SSH Access, you may then return to the running script and type option ‘y’ in order to again disable SSH on all the hosts in the specified cluster:

UCS_FNIC_ENIC3

PowerCLI Script:

#######################################
# Confirm CISCO FNIC & ENIC Drivers
# Date: 2016-07-01
# Created by: David Ring
#######################################

###### vCenter Connectivity Details ######

Write-Host “Please enter the vCenter Host IP Address:” -ForegroundColor Yellow -NoNewline

$VMHost = Read-Host

Write-Host “Please enter the vCenter Username:” -ForegroundColor Yellow -NoNewline

$User = Read-Host

Write-Host “Please enter the vCenter Password:” -ForegroundColor Yellow -NoNewline

$Pass = Read-Host

Connect-VIServer -Server $VMHost -User $User -Password $Pass

###### Please enter the Cluster to check CISCO Versions #######

Write-Host “Clusters Associated with this vCenter:” -ForegroundColor Green

$VMcluster = ‘*’

ForEach ($VMcluster in (Get-Cluster -name $VMcluster)| sort)

{
Write-Host $VMcluster
}

Write-Host “Please enter the Cluster to lookup CISCO FNIC & ENIC Drivers:” -ForegroundColor Yellow -NoNewline

$VMcluster = Read-Host

###### Enabling SSH ######

Write-Host “Do you need to Enable SSH on the Cluster ESXi Hosts? ” -ForegroundColor Yellow -NoNewline

Write-Host ” Y/N:” -ForegroundColor Red -NoNewline

$SSHEnable = Read-Host

if ($SSHEnable -eq “y”) {

Write-Host “Enabling SSH on all hosts in your specified cluster:” -ForegroundColor Green

Get-Cluster $VMcluster | Get-VMHost | ForEach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where {$_.Key -eq “TSM-SSH”})}

}

###### Confirm Driver Versions ######

Write-Host “Confirm CISCO FNIC & ENIC Drivers” -ForegroundColor Green

$hosts = Get-Cluster $VMcluster | Get-VMHost

forEach ($vihost in $hosts)

{

Write-Host -ForegroundColor Magenta “Gathering Driver versions on” $vihost

$esxcli = get-vmhost $vihost | Get-EsxCli

$esxcli.software.vib.list() | Where { $_.Name -like “net-enic”} | Select @{N=”VMHost”;E={$ESXCLI.VMHost}}, Name, Version

$esxcli.software.vib.list() | Where { $_.Name -like “scsi-fnic”} | Select @{N=”VMHost”;E={$ESXCLI.VMHost}}, Name, Version

}

###### Disabling SSH ######

Write-Host “Ready to Disable SSH? ” -ForegroundColor Yellow -NoNewline

Write-Host ” Y/N:” -ForegroundColor Red -NoNewline

$SSHDisable = Read-Host

if ($SSHDisable -eq “y”) {

Write-Host “Disabling SSH” -ForegroundColor Green

Get-Cluster $VMcluster | Get-VMHost | ForEach {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where {$_.Key -eq “TSM-SSH”}) -Confirm:$FALSE}

}

 

Useful References:

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1027206

http://www.cisco.com/c/en/us/support/docs/servers-unified-computing/ucs-b-series-blade-servers/115764-ucs-san-tshoot-00.html

VMware PowerCLI – Enable/Disable SSH Per vSphere Cluster

The following script allows the user to Enable/Disable SSH at a per vSphere cluster level. You may download the ‘SSH.ps1‘ script here: SSH.ps1 (Remove the .doc extension).

The script will begin by prompting you to enter the vCenter Host IP Address, username and password. A list of all the available clusters residing in vCenter will be returned, followed by a prompt to enter the cluster name you wish to Enable/Disable SSH for:

Continue reading

EMC VMAX3 – Adding Gatekeeper RDM Volumes To VMware MGMT VM

This post outlines how to create the VMAX Masking view for Gatekeeper RDM volumes and the Script to Automate Adding RDM Disk’s to a VMware MGMT VM.

First some notes on Gatekeeper volumes:
SE(CLI) and Unisphere(GUI) are the main tools used to manage a VMAX Array, Gatekeeper volumes are required in order to carry these commands from both CLI&GUI and generate low level commands which are sent to the VMAX Array to complete the required instruction such as IG,SG,PG,MV or volume creation. It is good practice to use dedicated Gatekeeper devices and avoid using any devices which contain user or application data which may be impacted by the I/O requirement from the instruction command. For example if the device used as a gatekeeper is also servicing application I/O then a scenario may arise if the VMAX is executing a command which takes some time, as a result of this latency the application may encounter poor performance. These are the reasons why EMC strongly recommends to create and map dedicated devices as Gatekeepers.

VMAX3: Creating the RDM Volumes and Associated Masking View

This is an example Masking View for a two node ESXi cluster on which the VMAX management virtual machine shall reside:

1. Create a Port Group with the VMAX FA ports that the ESXi hosts have been zoned to:
symaccess -sid 123 -name MGMT_VM_PG -type port create
symaccess -sid 123 -name MGMT_VM_PG -type port -dirport 1d:24,2d:31,3D:28,4d:27 add

2. Create the Initiator Group containing the ESXi hosts WWNS:
symaccess -sid 123 -name MGMT_VM_IG -type initiator create -consistent_lun
symaccess -sid 123 -name MGMT_VM_IG -type initiator -wwn 21000024ff5CXXF8 add
symaccess -sid 123 -name MGMT_VM_IG -type initiator -wwn 21000024ff5CXXF9 add
symaccess -sid 123 -name MGMT_VM_IG -type initiator -wwn 21000024ff55XX4C add
symaccess -sid 123 -name MGMT_VM_IG -type initiator -wwn 21000024ff55XX4D add

3. Create the Storage Group for the Gatekeeper RDM Volumes:
symsg -sid 123 create MGMT_VM_SG -slo optimized -srp SRP_1
Listing the SRP:
symcfg list -srp

4. Create the Gatekeeper volumes (10 Gatekeeper volumes in this example) and add to the MGMT_VM_SG:
symconfigure -sid 123 -cmd “create dev count=10, emulation=FBA, sg=MGMT_VM_SG, size=3 CYL, config=tdev”; preview -nop
symconfigure -sid 123 -cmd “create dev count=10, emulation=FBA, sg=MGMT_VM_SG, size=3 CYL, config=tdev”; prepare -nop
symconfigure -sid 123 -cmd “create dev count=10, emulation=FBA, sg=MGMT_VM_SG, size=3 CYL, config=tdev”; commit -nop

5. Create the Masking View:
symaccess -sid 123 create view -name MGMT_VM_MV -sg MGMT_VM_SG -pg MGMT_VM_PG -ig MGMT_VM_IG

View Configuration Details

Confirm that the HOSTS are logged into the correct VMAX ports:
symaccess -sid 123 list logins -wwn 21000024ff5CXXF8
symaccess -sid 123 list logins -wwn 21000024ff5CXXF9
symaccess -sid 123 list logins -wwn 21000024ff55XX4C
symaccess -sid 123 list logins -wwn 21000024ff55XX4D

Verify that the HBA is a member of the correct Initiator Group:
symaccess -sid 123 list -type initiator -wwn 21000024ff5CXXF8
symaccess -sid 123 list -type initiator -wwn 21000024ff5CXXF9
symaccess -sid 123 list -type initiator -wwn 21000024ff55XX4C
symaccess -sid 123 list -type initiator -wwn 21000024ff55XX4D

Storage Group details:
symaccess -sid 123 list -type storage -name AMP_SG -v
symaccess -sid 123 show AMP_SG -type storage

Port Group details:
symaccess -sid 123 list -type port -name AMP_PG -v
symaccess -sid 123 show AMP_PG -type port

Initiator Group details:
symaccess -sid 123 list -type initiator -name AMP_IG -v
symaccess -sid 123 show AMP_IG -type initiator

Masking View details:
symaccess -sid 123 list view -name AMP_MV
symaccess -sid 123 list view -name AMP_MV -detail

Gatekeeper details:
symdev -sid 340 list -cap 3 -captype cyl
symaccess -sid 123 list assignment -dev 049:052

If you need to remove the devs from the SG:
symaccess -sid 123 -name AMP_SG -type storage remove devs 049:052


####################################################################
Script to Automate Adding RDM Disk’s:

PowerCLI Script: Automate Adding RDM Disk’s
Here is a script which scans for the Host LUN ID and then attributes the $LUN_# parameter
to the ‘ConsoleDeviceName’. This greatly simplifies the process of adding large quantities of RDM Disk’s.

There are 4 parameters used in the script. The following 3 shall be prompted for:
“Your-ESXi-Hostname” $VMhostname
“Your-VM-Name” $VM
“Your-VMFS-DS-Name” $Datastore

Please edit the runtime name as required, the script default is :
“vmhba0:C0:T0:L#”

The following example script will automatically create 10 RDM Disks on a Virtual Machine and place the pointer files
in a VMFS Datastore based on the parameters provided.

#####################################################################

Write-Host “Please edit the runtime name in the script if required before proceeding, the default is:” -ForegroundColor Red
Write-Host “vmhba0:C0:T0:L#” -ForegroundColor Green

Write-Host “Please enter the ESXi/Vcenter Host IP Address:” -ForegroundColor Yellow -NoNewline
$VMHost = Read-Host

Write-Host “Please enter the ESXi/Vcenter Username:” -ForegroundColor Yellow -NoNewline
$User = Read-Host

Write-Host “Please enter the ESXi/Vcenter Password:” -ForegroundColor Yellow -NoNewline
$Pass = Read-Host

Connect-VIServer -Server $VMHost -User $User -Password $Pass

##########################################

$VMhostname = ‘*’

ForEach ($VMhostname in (Get-VMHost -name $VMhostname)| sort)
{

Write-Host $VMhostname

}

Write-Host “Please enter the ESXi Hostname where your target VM resides:” -ForegroundColor Yellow -NoNewline
$VMhostname = Read-Host

######################################

$Datastore = ‘*’

ForEach ($Datastore in (Get-Datastore -name $Datastore)| sort)
{

Write-Host $Datastore

}

Write-Host “From the list provided – Please enter the VMFS datastore where the RDM pointer files will reside:” -ForegroundColor Yellow -NoNewline
$Datastore = Read-Host

######################################

$VM = ‘*’

ForEach ($VM in (Get-VM -name $VM)| sort)
{
Write-Host $VM
}

Write-Host “From the list provided – Please enter the VM Name where the RDM volumes shall be created on:” -ForegroundColor Yellow -NoNewline
$VM = Read-Host

##############
Write-Host “ESXi Hostname you have chosen: ” -ForegroundColor Yellow
Write-Host “$VMhostname” -ForegroundColor Green
Write-Host “VMFS you have chosen: ” -ForegroundColor Yellow
Write-Host “$Datastore” -ForegroundColor Green
Write-Host “Vitual Machine you have chosen: ” -ForegroundColor Yellow
Write-Host “$VM” -ForegroundColor Green

################
## ACLX T0:L0 ##
################
$LUN_0 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L0”} | Select ConsoleDeviceName,runtimename
$LUN_0 = $LUN_0 | Select ConsoleDeviceName
$LUN_0 = $LUN_0 -replace “@{ConsoleDeviceName=”, “”
$LUN_0 = $LUN_0 -replace “}”, “”
$LUN_0
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_0 -DataStore $Datastore

#####################
## Gatekeepers x10 ##
#####################
$LUN_1 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L1”} | Select ConsoleDeviceName,runtimename
$LUN_1 = $LUN_1 | Select ConsoleDeviceName
$LUN_1 = $LUN_1 -replace “@{ConsoleDeviceName=”, “”
$LUN_1 = $LUN_1 -replace “}”, “”
$LUN_1
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_1 -DataStore $Datastore

$LUN_2 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L2”} | Select ConsoleDeviceName,runtimename
$LUN_2 = $LUN_2 | Select ConsoleDeviceName
$LUN_2 = $LUN_2 -replace “@{ConsoleDeviceName=”, “”
$LUN_2 = $LUN_2 -replace “}”, “”
$LUN_2
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_2 -DataStore $Datastore

$LUN_3 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L3”} | Select ConsoleDeviceName,runtimename
$LUN_3 = $LUN_3 | Select ConsoleDeviceName
$LUN_3 = $LUN_3 -replace “@{ConsoleDeviceName=”, “”
$LUN_3 = $LUN_3 -replace “}”, “”
$LUN_3
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_3 -DataStore $Datastore

$LUN_4 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L4”} | Select ConsoleDeviceName,runtimename
$LUN_4 = $LUN_4 | Select ConsoleDeviceName
$LUN_4 = $LUN_4 -replace “@{ConsoleDeviceName=”, “”
$LUN_4 = $LUN_4 -replace “}”, “”
$LUN_4
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_4 -DataStore $Datastore

$LUN_5 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L5”} | Select ConsoleDeviceName,runtimename
$LUN_5 = $LUN_5 | Select ConsoleDeviceName
$LUN_5 = $LUN_5 -replace “@{ConsoleDeviceName=”, “”
$LUN_5 = $LUN_5 -replace “}”, “”
$LUN_5
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_5 -DataStore $Datastore

$LUN_6 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L6”} | Select ConsoleDeviceName,runtimename
$LUN_6 = $LUN_6 | Select ConsoleDeviceName
$LUN_6 = $LUN_6 -replace “@{ConsoleDeviceName=”, “”
$LUN_6 = $LUN_6 -replace “}”, “”
$LUN_6
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_6 -DataStore $Datastore

$LUN_7 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L7”} | Select ConsoleDeviceName,runtimename
$LUN_7 = $LUN_7 | Select ConsoleDeviceName
$LUN_7 = $LUN_7 -replace “@{ConsoleDeviceName=”, “”
$LUN_7 = $LUN_7 -replace “}”, “”
$LUN_7
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_7 -DataStore $Datastore

$LUN_8 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L8”} | Select ConsoleDeviceName,runtimename
$LUN_8 = $LUN_8 | Select ConsoleDeviceName
$LUN_8 = $LUN_8 -replace “@{ConsoleDeviceName=”, “”
$LUN_8 = $LUN_8 -replace “}”, “”
$LUN_8
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_8 -DataStore $Datastore

$LUN_9 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L9”} | Select ConsoleDeviceName,runtimename
$LUN_9 = $LUN_9 | Select ConsoleDeviceName
$LUN_9 = $LUN_9 -replace “@{ConsoleDeviceName=”, “”
$LUN_9 = $LUN_9 -replace “}”, “”
$LUN_9
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_9 -DataStore $Datastore

$LUN_10 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L10”} | Select ConsoleDeviceName,runtimename
$LUN_10 = $LUN_10 | Select ConsoleDeviceName
$LUN_10 = $LUN_10 -replace “@{ConsoleDeviceName=”, “”
$LUN_10 = $LUN_10 -replace “}”, “”
$LUN_10
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_10 -DataStore $Datastore

##############
### VERIFY ###
##############
##Finding RDMs Using PowerCLI:##
# Detailed #
# Get-VM | Get-HardDisk -DiskType “RawPhysical” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,CapacityGB | fl
# Brief #
# Get-ScsiLun -VMHost $VMhostname -LunType disk
# NAA #
# Get-ScsiLun -VMHost $VMhostname -LunType disk | select CanonicalName

### Get IP Address for ViClient to check GUI ###
# Get-VMHost -Name $VMhostname | Get-VMHostNetworkAdapter

VMware PowerCLI – MS Windows Guest VM ‘IP&DNS’ Modification

The following script allows the user to modify an MS Windows Guest VM IP and DNS configuration. You may download the ‘IP&DNS_Modification.ps1‘ script HERE (Remove the .doc extension).

Begin by entering the ESXi/Vcenter Host IP Address, username and password:
PCLI_IP&DNS_Mod1

A list of all VM’s residing in ESXi/Vcenter will be returned, followed by a prompt to enter the VM name you wish to modify. Once the VM name is entered a list of all the MS Windows Ethernet interfaces and their respective configurations shall be returned:
PCLI_IP&DNS_Mod3

Provide the required IP configuration updates for the interface specified (‘Ethernet 2’ in this example):
PCLI_IP&DNS_Mod5

Specify whether you wish to modify the DNS entries:
PCLI_IP&DNS_Mod7

The script utilizes the Invoke-VMScript option to run Windows ‘Netsh’ commands on the network interface (Modify the script with your Windows username and password). These are the results as per the example given, along with the option to repeat the same process for another Windows Guest VM:
PCLI_IP&DNS_Mod9

SCRIPT IN FULL:


##########################################################
#
# Reference: MS Windows Guest IP Modification
# Script: PowerCLI IP&DNS Modification
#
# Date: 2015-04-21
#
# Version 1.0
#
##########################################################

Write-Host "Please enter the ESXi/Vcenter Host IP Address:" -ForegroundColor Yellow -NoNewline
$VMHost = Read-Host

Write-Host "Please enter the ESXi/Vcenter Username:" -ForegroundColor Yellow -NoNewline
$User = Read-Host

Write-Host "Please enter the ESXi/Vcenter Password:" -ForegroundColor Yellow -NoNewline
$Pass = Read-Host

Connect-VIServer -Server $VMHost -User $User -Password $Pass

do {
#Return list of VM's
Get-VM | select name

#Prompt for VM name
Write-Host "Please enter the VM Name that requires IP modification:" -ForegroundColor Yellow -NoNewline
$VM = Read-Host

Write-Host "The current VM Network Configuration:" -ForegroundColor Yellow
#Display Existing NIC Configuration
$shownet = "netsh interface ip show config"
Invoke-VMScript -ScriptText $shownet -VM $vm -GuestUser administrator -GuestPassword MSPassword -ScriptType Bat

################################
# Modify IP Configuration? y/n #
################################

Write-Host "Modify IP Details? " -ForegroundColor Yellow -NoNewline
Write-Host " Y/N:" -ForegroundColor Red -NoNewline
$IPChange = Read-Host

if ($IPChange -eq "y") {
Write-Host "Please provide the following IP details:" -ForegroundColor Yellow
#Prompt for IP Updates:
Write-Host "Interface Name:" -ForegroundColor Green -NoNewline
$NIC = Read-Host
Write-Host "New IP address:" -ForegroundColor Green -NoNewline
$IP = Read-Host
Write-Host "New Netmask:" -ForegroundColor Green -NoNewline
$NETMASK = Read-Host
Write-Host "New Gateway:" -ForegroundColor Green -NoNewline
$Gateway = Read-Host

#Invoke Windows netsh Script
$script = "netsh interface ip set address ""$NIC"" static $IP $NETMASK $Gateway"
Invoke-VMScript -ScriptText $script -VM $vm -GuestUser administrator -GuestPassword MSPassword -ScriptType Bat
}

#################################
# Modify DNS Configuration? y/n #
#################################
Write-Host "Modify DNS Details? " -ForegroundColor Yellow -NoNewline
Write-Host " Y/N:" -ForegroundColor Red -NoNewline
$DNSChange = Read-Host

if ($DNSChange -eq "y") {
#Prompt for Primary DNS IP:
Write-Host "Enter Primary DNS IP:" -ForegroundColor Green -NoNewline
$DNS1 = Read-Host
Write-Host "Enter Secondary DNS IP:" -ForegroundColor Green -NoNewline
$DNS2 = Read-Host

$DNSPrimary = "netsh interface ip set dnsservers name=""$NIC"" static $DNS1"
Invoke-VMScript -ScriptText $DNSPrimary -VM $vm -GuestUser administrator -GuestPassword MSPassword -ScriptType Bat

$DNSSecondary = "netsh interface ip add dnsservers name=""$NIC"" $DNS2 index=2"
Invoke-VMScript -ScriptText $DNSSecondary -VM $vm -GuestUser administrator -GuestPassword MSPassword -ScriptType Bat

}

# Display Network Configuration #
Invoke-VMScript -ScriptText $shownet -VM $vm -GuestUser administrator -GuestPassword MSPassword -ScriptType Bat

Write-Host "Change IP Configuration for another WINDOWS Guest VM? " -ForegroundColor Yellow -NoNewline
Write-Host " Y/N:" -ForegroundColor Red -NoNewline
$response = Read-Host
}
while ($response -eq "Y")

Thanks @CliffCahill and ‘Mike Leahy’ for your input, as always greatly appreciated!

VMware PowerCLI – Adding RDM Disk’s

See also: VMware PowerCLI – Adding VMFS Datastore’s

After creating the required LUN’s on your storage array and mapped the LUN’s to your ESXi hosts then you may use PowerCLI to add these new LUNs as RDM Disk’s to a Virtual Machine.

The first four steps outline how to use PowerCLI to add an individual RDM to a Virtual Machine and the second section provides the script to add multiple RDM volumes to a Virtual Machine(s).

1. Connect to vCenter:
Connect-VIServer -Server “vCenter_IP” -User UserName -Password Password

If you need to retreive the Cluster and Host names:
look up the Cluster Name:
Get-Cluster
look up the Host names in the cluster:
Get-Cluster ‘Cluster Name’ | Get-VMHost | Select Name

2. Retrieve the ConsoleDeviceName(s):
In order to use the New-HardDisk cmdlet we require the ‘ConsoleDeviceName’ parameter associated with each LUN. In this example we will use the Get-SCSILun cmd to return the ‘ConsoleDeviceName’, Capacity and Runtime name in order for us to match the unique naa with the correct LUN#.

Get-SCSILun -VMhost “Your-ESXi-Hostname” -LunType Disk | Select ConsoleDeviceName,CapacityGB,runtimename

cli_rdm1

I was able to sort the SCSI LUN’s by RuntimeName including the double digit’s ‘vmhba0:C0:T0:L##’ using the following script provided by Luc:

Get-ScsiLun -VMHost “Your-ESXi-Hostname” -LunType disk |
Select RuntimeName,ConsoleDeviceName,CapacityGB |
Sort-Object -Property {$_.RuntimeName.Split(‘:’)[0],
[int]($_.RuntimeName.Split(‘:’)[1].TrimStart(‘C’))},
{[int]($_.RuntimeName.Split(‘:’)[2].TrimStart(‘T’))},
{[int]($_.RuntimeName.Split(‘:’)[3].TrimStart(‘L’))}

cli_rdm2

3. Adding the New RDM Disk’s:
If you need to reference the name of the Virtual machine you will be using to add the RDM disk:
Get-VM | Select-Object Name

vSphere PowerCLI provides the New-HardDisk cmd to create an RDM Disk on a virtual machine:
New-HardDisk -VM “Your-VM-Name” -DiskType RawPhysical -DeviceName /vmfs/devices/disks/naa.6000etc

If you wish to specify the VMFS datastore to use for your RDM pointer files then add the -DataStore parameter:
New-HardDisk -VM “Your-VM-Name” -DiskType RawPhysical -DeviceName /vmfs/devices/disks/naa.6000etc -Datastore “Datastore-Name”

If you need to list the available Datastore’s:
Get-Datastore
Get-Cluster -name “ClusterName” | Get-VMhost | Get-Datastore

4. List all the Newly Created RDM Disk’s:
Get-VM | Get-HardDisk -DiskType “RawPhysical” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,CapacityGB | fl

cli_rdm3

******************************************************************************************

Script to Automate Adding RDM Disk’s

####################################################################
PowerCLI Script: Automate Adding RDM Disk’s
Here is a script which scans for the Host LUN ID and then attributes the $LUN_# parameter
to the ‘ConsoleDeviceName’. This greatly simplifies the process of adding large quantities of RDM Disk’s.

There are 4 parameters used in the script. The following 3 shall be prompted for:
“Your-ESXi-Hostname” $VMhostname
“Your-VM-Name” $VM
“Your-VMFS-DS-Name” $Datastore

Please edit the runtime name as required, the script default is :
“vmhba0:C0:T0:L#”

The following example script will automatically create 10 RDM Disks on a Virtual Machine and place the pointer files
in a VMFS Datastore based on the parameters provided.

#####################################################################

Write-Host “Please edit the runtime name in the script if required before proceeding, the default is:” -ForegroundColor Red
Write-Host “vmhba0:C0:T0:L#” -ForegroundColor Green

Write-Host “Please enter the ESXi/Vcenter Host IP Address:” -ForegroundColor Yellow -NoNewline
$VMHost = Read-Host

Write-Host “Please enter the ESXi/Vcenter Username:” -ForegroundColor Yellow -NoNewline
$User = Read-Host

Write-Host “Please enter the ESXi/Vcenter Password:” -ForegroundColor Yellow -NoNewline
$Pass = Read-Host

Connect-VIServer -Server $VMHost -User $User -Password $Pass

##########################################

$VMhostname = ‘*’

ForEach ($VMhostname in (Get-VMHost -name $VMhostname)| sort)
{

Write-Host $VMhostname

}

Write-Host “Please enter the ESXi Hostname where your target VM resides:” -ForegroundColor Yellow -NoNewline
$VMhostname = Read-Host

######################################

$Datastore = ‘*’

ForEach ($Datastore in (Get-Datastore -name $Datastore)| sort)
{

Write-Host $Datastore

}

Write-Host “From the list provided – Please enter the VMFS datastore where the RDM pointer files will reside:” -ForegroundColor Yellow -NoNewline
$Datastore = Read-Host

######################################

$VM = ‘*’

ForEach ($VM in (Get-VM -name $VM)| sort)
{
Write-Host $VM
}

Write-Host “From the list provided – Please enter the VM Name where the RDM volumes shall be created on:” -ForegroundColor Yellow -NoNewline
$VM = Read-Host

##############
Write-Host “ESXi Hostname you have chosen: ” -ForegroundColor Yellow
Write-Host “$VMhostname” -ForegroundColor Green
Write-Host “VMFS you have chosen: ” -ForegroundColor Yellow
Write-Host “$Datastore” -ForegroundColor Green
Write-Host “Vitual Machine you have chosen: ” -ForegroundColor Yellow
Write-Host “$VM” -ForegroundColor Green

################
## ACLX T0:L0 ##
################
$LUN_0 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L0”} | Select ConsoleDeviceName,runtimename
$LUN_0 = $LUN_0 | Select ConsoleDeviceName
$LUN_0 = $LUN_0 -replace “@{ConsoleDeviceName=”, “”
$LUN_0 = $LUN_0 -replace “}”, “”
$LUN_0
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_0 -DataStore $Datastore

#####################
## Gatekeepers x10 ##
#####################
$LUN_1 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L1”} | Select ConsoleDeviceName,runtimename
$LUN_1 = $LUN_1 | Select ConsoleDeviceName
$LUN_1 = $LUN_1 -replace “@{ConsoleDeviceName=”, “”
$LUN_1 = $LUN_1 -replace “}”, “”
$LUN_1
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_1 -DataStore $Datastore

$LUN_2 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L2”} | Select ConsoleDeviceName,runtimename
$LUN_2 = $LUN_2 | Select ConsoleDeviceName
$LUN_2 = $LUN_2 -replace “@{ConsoleDeviceName=”, “”
$LUN_2 = $LUN_2 -replace “}”, “”
$LUN_2
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_2 -DataStore $Datastore

$LUN_3 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L3”} | Select ConsoleDeviceName,runtimename
$LUN_3 = $LUN_3 | Select ConsoleDeviceName
$LUN_3 = $LUN_3 -replace “@{ConsoleDeviceName=”, “”
$LUN_3 = $LUN_3 -replace “}”, “”
$LUN_3
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_3 -DataStore $Datastore

$LUN_4 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L4”} | Select ConsoleDeviceName,runtimename
$LUN_4 = $LUN_4 | Select ConsoleDeviceName
$LUN_4 = $LUN_4 -replace “@{ConsoleDeviceName=”, “”
$LUN_4 = $LUN_4 -replace “}”, “”
$LUN_4
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_4 -DataStore $Datastore

$LUN_5 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L5”} | Select ConsoleDeviceName,runtimename
$LUN_5 = $LUN_5 | Select ConsoleDeviceName
$LUN_5 = $LUN_5 -replace “@{ConsoleDeviceName=”, “”
$LUN_5 = $LUN_5 -replace “}”, “”
$LUN_5
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_5 -DataStore $Datastore

$LUN_6 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L6”} | Select ConsoleDeviceName,runtimename
$LUN_6 = $LUN_6 | Select ConsoleDeviceName
$LUN_6 = $LUN_6 -replace “@{ConsoleDeviceName=”, “”
$LUN_6 = $LUN_6 -replace “}”, “”
$LUN_6
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_6 -DataStore $Datastore

$LUN_7 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L7”} | Select ConsoleDeviceName,runtimename
$LUN_7 = $LUN_7 | Select ConsoleDeviceName
$LUN_7 = $LUN_7 -replace “@{ConsoleDeviceName=”, “”
$LUN_7 = $LUN_7 -replace “}”, “”
$LUN_7
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_7 -DataStore $Datastore

$LUN_8 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L8”} | Select ConsoleDeviceName,runtimename
$LUN_8 = $LUN_8 | Select ConsoleDeviceName
$LUN_8 = $LUN_8 -replace “@{ConsoleDeviceName=”, “”
$LUN_8 = $LUN_8 -replace “}”, “”
$LUN_8
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_8 -DataStore $Datastore

$LUN_9 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L9”} | Select ConsoleDeviceName,runtimename
$LUN_9 = $LUN_9 | Select ConsoleDeviceName
$LUN_9 = $LUN_9 -replace “@{ConsoleDeviceName=”, “”
$LUN_9 = $LUN_9 -replace “}”, “”
$LUN_9
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_9 -DataStore $Datastore

$LUN_10 = Get-SCSILun -VMhost $VMhostname -LunType Disk | Where-Object {$_.runtimename -like “vmhba0:C0:T0:L10”} | Select ConsoleDeviceName,runtimename
$LUN_10 = $LUN_10 | Select ConsoleDeviceName
$LUN_10 = $LUN_10 -replace “@{ConsoleDeviceName=”, “”
$LUN_10 = $LUN_10 -replace “}”, “”
$LUN_10
New-HardDisk -VM $VM -DiskType RawPhysical -DeviceName $LUN_10 -DataStore $Datastore

##############
### VERIFY ###
##############
##Finding RDMs Using PowerCLI:##
# Detailed #
# Get-VM | Get-HardDisk -DiskType “RawPhysical” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,CapacityGB | fl
# Brief #
# Get-ScsiLun -VMHost $VMhostname -LunType disk
# NAA #
# Get-ScsiLun -VMHost $VMhostname -LunType disk | select CanonicalName

### Get IP Address for ViClient to check GUI ###
# Get-VMHost -Name $VMhostname | Get-VMHostNetworkAdapter

EMC XtremIO – Setting Disk.SchedNumReqOutstanding On vSphere 5.5 & 6.0 (PowerCLI)

PowerCLI Download

Disk.SchedNumReqOutstanding (DSNRO) – Determines the maximum number of active storage commands (I/Os) allowed at any given time at the VMkernel. The default value is 32 and the maximum value is 256. For XtremIO storage with VMware vSphere it is recommended to set the DSNRO parameter to the maximum value of 256.

When using vSphere 5.5 the Disk.SchedNumReqOutstanding parameter needs to be set at the individual Host LUN level (Per Device Setting). Prior to vSphere 5.5 the DSNRO value was globally set for all volumes presented to the ESX host (Per Host Setting). vSphere 5.5 has made the DSNRO parameter change more granular for a good reason; rather than setting the parameter at the Host level which would affect all connected storage (regardless of array specific guidelines) you can now set the value on a per LUN basis.

Note: For this Per LUN/Device configuration (Disk.SchedNumReqOutstanding) change to be effective then it is important to align the maximum queue depth of the FC HBA with the LUN queue depth. In other words the lowest queue depth value will be the effective queue depth if there is a difference between both.

I will provide two examples of how to use PowerCLI in order to set the DSNRO parameter to the maximum value of 256 (the recommended XtremIO value). The first example changes the parameter for a single Device on a specific ESX Host. The second example details setting the DSNRO parameter for all XtremIO specific Devices presented to all ESX Hosts connected to vCenter.

Example 1: Setting the DSNRO Parameter for a Single Device on a specific ESX Host:

1. Connect to vCenter:
Connect-VIServer -Server ‘vCenter_IP’ -User ‘administrator@vsphere.local’ -Password ‘Password’

2. Retrieve Cluster name and Host name:
Get-Cluster
Get-Cluster ‘Cluster_Name’ | Get-VMHost | Select Name

3. Using your ESX Hostname you can list the presented devices in order to gather the naa.* value associated with the XtremIO LUN:
$esxcli=get-esxcli -VMHost ‘ESX_Host_Name’
$esxcli.storage.core.device.list()

DSN1

4. Set the DSNRO parameter to the max value of 256 for the XtremIO device ‘naa.514f0c58b3600023’:
$esxcli.storage.core.device.set($null, “naa.514f0c58b3600023”, $null, $null, $null, $null, $null, 256, $null)

5. List the details of the Device after the parameter change is made:
$esxcli.storage.core.device.list(“naa.514f0c58b3600023”)

DSN2

Example 2: Setting the DSNRO parameter for all XtremIO Devices presented to all ESX Hosts:
The following script changes the DSNRO parameter for all XtremIO devices on all hosts connected to vCenter Server. Thanks @CliffCahill for providing this very useful script.

1. Connect to vCenter:
Connect-VIServer -Server ‘vCenter_IP’ -User ‘administrator@vsphere.local’ -Password ‘Password’

2. Return the XtremIO Model Name as per vSphere:
$esxcli=get-esxcli -VMHost ‘ESX_Host_Name’
$esxcli.storage.core.device.list() | Select Model

DSN3

3. Change the DSNRO parameter for all XtremIO devices presented to all ESX Hosts:

Script for vSphere 5.5:
$EsxHosts = get-vmhost
foreach ($esx in $EsxHosts)
{
$esxcli = Get-EsxCli -VMHost $esx
$devices = $esxcli.storage.core.device.list()
foreach ($device in $devices)
{
if ($device.Model -like "XtremApp")
{
$esxcli.storage.core.device.set($null, $device.Device, $null, $null, $null, $null, $null, 256, $null)
}
}
}

Script for vSphere 6.0:
$EsxHosts = get-vmhost
foreach ($esx in $EsxHosts)
{
$esxcli = Get-EsxCli -VMHost $esx
$devices = $esxcli.storage.core.device.list()
foreach ($device in $devices)
{
if ($device.Model -like “XtremApp”)
{
$esxcli.storage.core.device.set($false, $null, $device.Device, $null, $null, $null, $null, $null, $null, $null, $null, ‘256’,$null,$null)
$esxcli.storage.core.device.list()
}
}
}

4. List all XtremIO devices and outputs results to ‘xio.txt’ in order to confirm the changes were made successfully:

$EsxHosts = get-vmhost
foreach ($esx in $EsxHosts)
{
$esxcli = Get-EsxCli -VMHost $esx
$esxcli.system.hostname.get() | ft Hostname | Out-file -Append -Noclobber "c:\XtremIO\xio.txt"
$esxcli.storage.core.device.list() | Where-Object {$_.Model -like "XtremApp"} | ft Vendor,Device,Size, NoofoutstandingIOswithcompetingworlds | Out-file -Append -Noclobber "c:\XtremIO\xio.txt"

}

VMware PowerCLI – Adding VMFS Datastore’s

Thank you Cliff, Steve and Luc for helping me out with this task.

After you have created the required LUN’s on your storage array and mapped the LUN’s to your ESXi hosts, at this stage you may use PowerCLI to add these new LUNs as VMFS datastore’s.

1. Connect to vCenter:
Connect-VIServer -Server “vcenter_IP” -User UserName -Password Password

If you need to retreive the Cluster and Host names:
look up the Cluster Name:
Get-Cluster
look up the Host names in the cluster:
Get-Cluster ‘Cluster Name’ | Get-VMHost | Select Name

2. Retrieve the Canonical Name(s):
In order to use the New-Datastore cmdlet we require the ‘Canonical Name’ parameter associated with each LUN. In this example we will use the Get-SCSILun cmd to return the ‘Canonical Name’, Capacity and Runtime name in order for us to match the unique naa with the correct LUN#.

Get-SCSILun -VMhost “YourESXiHostname” -LunType Disk | Select CanonicalName,CapacityGB,runtimename

Runtime

The naa’s and runtime names are returned, but we want to order the output by the runtime names ‘LUN ID’ ‘vmhba1:C0:T0:L#’. Uning the | sort-object runtimename parameter the LUNs are ordered, but the double digit’s are not recognised:

sort-object

I was able to sort the SCSI LUN’s by RuntimeName including the double digit’s ‘vmhba1:C0:T0:L##’ using the following script provided by Luc:

Get-ScsiLun -VMHost “YourESXiHostname” -LunType disk |
Select RuntimeName,CanonicalName,CapacityGB |
Sort-Object -Property {$_.RuntimeName.Split(‘:’)[0],
[int]($_.RuntimeName.Split(‘:’)[1].TrimStart(‘C’))},
{[int]($_.RuntimeName.Split(‘:’)[2].TrimStart(‘T’))},
{[int]($_.RuntimeName.Split(‘:’)[3].TrimStart(‘L’))}

sort-object1

3. Adding the New VMFS Datatore’s:
vSphere PowerCLI provides the New-Datastore cmd to create the VMFS Datastore(s):

New-Datastore -VMHost “YourESXiHostname” -Name ‘VMFS_Datastore_1’ -Path naa.60000xxxxxxxxxxxxxxxxx36 -vmfs
New-Datastore -VMHost “YourESXiHostname” -Name ‘VMFS_Datastore_2’ -Path naa.60000xxxxxxxxxxxxxxxxx42 -vmfs

4. Rescanning the Cluster for the New VMFS Datastores:
To rescan the entire cluster of ESXi host’s for the VMFS volumes added, issue the following PowerCLI cmd to rescan all the ESXi hosts HBA’s:

Get-Cluster -name “YourClusterName” | Get-VMhost | Get-VMHostStorage –RescanAllHBA

5. List all the Newly Created VMFS Datastore’s:
Get-Datastore -VMhost “YourESXiHostname”
Get-Cluster -name “ClusterName” | Get-VMhost | Get-Datastore

******************************************************************************************

Script to Automate Adding VMFS Volumes
Here is a script which Steve Keating kindly helped put together which scans for the Host LUN ID and then attributes the $LUN_ parameter to the ‘Canonical Name’. This greatly simplifies the process of adding large quantities of VMFS datastore’s.

For example if we know the following:
Host LUN ID ‘1’ will equal ‘VMFS_Datastore_1’
Host LUN ID ‘2’ will equal ‘VMFS_Datastore_2’
etc…
The following example script will automatically create four VMFS datastore’s and scan the Hosts HBA’s:

###VMFS_Datastore_1###
$LUN_1 = Get-SCSILun -VMhost YourESXiHostname -LunType Disk | Where-Object {$_.runtimename -like "*L1"} | Select CanonicalName,runtimename
$LUN_1 = $LUN_1 | Select CanonicalName
$LUN_1 = $LUN_1 -replace "@{CanonicalName=", ""
$LUN_1 = $LUN_1 -replace "}", ""
$LUN_1
New-Datastore -VMHost YourESXiHostname -Name VMFS_Datastore_1 -Path $LUN_1 -Vmfs

###VMFS_Datastore_2###
$LUN_2 = Get-SCSILun -VMhost YourESXiHostname -LunType Disk | Where-Object {$_.runtimename -like "*L2"} | Select CanonicalName,runtimename
$LUN_2 = $LUN_2 | Select CanonicalName
$LUN_2 = $LUN_2 -replace "@{CanonicalName=", ""
$LUN_2 = $LUN_2 -replace "}", ""
$LUN_2
New-Datastore -VMHost YourESXiHostname -Name VMFS_Datastore_2 -Path $LUN_2 -Vmfs

###VMFS_Datastore_3###
$LUN_3 = Get-SCSILun -VMhost YourESXiHostname -LunType Disk | Where-Object {$_.runtimename -like "*L3"} | Select CanonicalName,runtimename
$LUN_3 = $LUN_3 | Select CanonicalName
$LUN_3 = $LUN_3 -replace "@{CanonicalName=", ""
$LUN_3 = $LUN_3 -replace "}", ""
$LUN_3
New-Datastore -VMHost YourESXiHostname -Name VMFS_Datastore_3 -Path $LUN_3 -Vmfs

###VMFS_Datastore_4###
$LUN_4 = Get-SCSILun -VMhost YourESXiHostname -LunType Disk | Where-Object {$_.runtimename -like "*L4"} | Select CanonicalName,runtimename
$LUN_4 = $LUN_4 | Select CanonicalName
$LUN_4 = $LUN_4 -replace "@{CanonicalName=", ""
$LUN_4 = $LUN_4 -replace "}", ""
$LUN_4
New-Datastore -VMHost YourESXiHostname -Name VMFS_Datastore_4 -Path $LUN_4 -Vmfs

###Scan Cluster Hosts HBA’s###
Get-Cluster -name "YourClusterName" | Get-VMhost | Get-VMHostStorage –RescanAllHBA