Categories
General

vSphere : Semi-automate Bulk Datastore Creation

vSphere : Semi-automate Bulk Datastore Creation

Use the following command to output new LUNs that are on the EVA8400 (these will not be set to RoundRobin):
Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | ft –autosize

Copy output to text file and then open with Excel as below, adding the CapacityGB, Name and LunID columns. Use the vCenter GUI to obtain LUN IDs that can then be translated into the correct name as per the your sites LUN/Datastore naming convention.

CanonicalName

ConsoleDeviceName

LunType

LunID

Name

CapacityMB

CapacityGB

MultipathPolicy

naa.6001438005deea3c0000900003030000

/vmfs/devices/disks/naa.6001438005deea3c0000900003030000

disk

9

EUVMCL01_8400_DS09

491520

480

MostRecentlyUsed

naa.6001438005deea3c00009000030f0000

/vmfs/devices/disks/naa.6001438005deea3c00009000030f0000

disk

13

EUVMCL01_8400_TEST_DS04

716800

700

MostRecentlyUsed

Save the new CSV file to C:\new_datastores.csv

Now create the script to perform the task, copy the text below into C:\storage_setup.ps1. Modify the text in RED to suit your environment:

$CSVFile = “C:\NewDisk.csv

$vmcluster = “vm cluster name

$vmhost = Get-VMHost “vmhost fqdn

write “Importing CSV: $($CSVFile)”

$CSV = Import-CSV $CSVFile

Foreach ($Item in $CSV){

$HostID = $Item.HostId

$LunID = $Item.LunID

$LunPath = $Item.CanonicalName

$Name = $Item.Name

Write “Creating: $($Name)…Path: $($LunPath) “

$vmhost | New-Datastore -Vmfs -Name “$($Name)” -Path “$($LunPath)” -BlockSizeMB 8

Write “Created, applying RoundRobin multipathing policy… for cluster: $($vmcluster) “

foreach ($vmhost in get-cluster $vmcluster| get-vmhost) {

write node: $($vmhost.Name)

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “$($LunPath)” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”}

}

Open the vSphere PowrCLI and connect to your vCenter; connect-viserver vCentername

Now execute the new script saved above.

Finally, if you are using Enterprise Plus, use the vCenter GUI to set Storage IO Control, this is a drop down box that can be set across all hosts with one change per datastore.

Leave a Reply

Your email address will not be published. Required fields are marked *