VMware Cloud Community
aamodei01
Enthusiast
Enthusiast

New-Datastore on ESXi 6.0 Not working?

Got a strange one, I've been using this script for quite some time, not sure whats different on Esxi 6 U2:

I feed in a CSV for mass datastore creation:

CSV looks like:

DeviceNAA,DatastoreName

Script is:

$deviced = import-Csv "$path\FarmNAAID.csv"

$farmhosts = get-cluster $ESXFarmName | Get-VMHost | Select -First 1

Foreach ($dev in $deviced){

         Write-host "Creating Datastore" $dev.DatastoreName "on Primary Host -" $farmhosts ", device labeled " $dev.DeviceNAA

       $farmhosts | New-Datastore -Name $dev.DatastoreName -Path $dev.DeviceNAA -Vmfs -FileSystemVersion 5 -Confirm:$false

    }

Currently it kicks back " New-Datastore        Could not find the specified disk or the disk is already in use:<DeviceNAA ID Here>

No idea what has changed in the way of powercli on ESXi 6, but hopefully someone can shed some light? I have a ton of Datastores to add.

I'm runing Powercli 6.3 R1, and just for kicks I've tried on a slightly older version of PowerCLI 6, but no dice.

thanks!

14 Replies
LucD
Leadership
Leadership

New-Datastore works for me in PowerCLI 6.3R1.

Are you sure that $farmhosts doesn't contain the same ESXi node twice?
Check $Global:defaultviservers for multiple connections.

And a stupid question, did you check if that device is actually used (Get-ScsiLun) on that specific ESXi node?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
aamodei01
Enthusiast
Enthusiast

Hey LucD,

Thanks for the quick response!

Yes, I have hand verified that there is only 1 live vCenter connection and only 1 single host loaded to $farmhosts (despite the plural variable name... I was lazy) 🙂

and Yes, I have confirmed that get-scsi lun shows all the devices present and accounted for to the host in question, as well as the others in the cluster, but thats the strange part.

Get-scsi gets and shows the devices, and I've again hand verified the NAA id's, but New-Datastore's error makes me think that it can't see those devices for some reason, which would mean that Get-SCSILun and New-Datastore look at different parts of the data model?

These are all brand new devices, just attached from the storage team.

0 Kudos
LucD
Leadership
Leadership

Do you see that LUN perhaps in the detached list?

$esxcli = Get-EsxCli -VMHost $farmhosts

$esxcli.storage.core.device.detached.list()

Ultimately you have a look in the vpxd log.
Perhaps it shows more info why the New-Datastore fails


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

Did anybody figure out what was going on with New-Datastore in this thread?  I'm seeing the same things.

vSphere 5.5 (vCenter 4180647/ESXi 4179633)

PowerCLI 6.3 3737840 & PowerCLI 6.0 2548067

Looping through a CSV that has the datastore names and canonical names of the devices when connect to vCenter in PowerCLI. Here is the code:

$LUNs = Import-Csv -Path <file>

foreach ($lun in $LUNs) {New-Datastore -VMHost <esxhost> -Name $lun.Name -Path $lun.UID2 -Vmfs}

The following is the errors that I get when running this:

New-Datastore : 1/27/2017 4:57:16 PM    New-Datastore        Could not find the specified disk or the disk is already

in use: 'naa.xxxxxxxxxxxxxxx'

At line:1 char:26

+ foreach ($lun in $LUNs) {New-Datastore -VMHost <esxhost> -Name $lun.Na ...

+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (naa.xxxxxxxxxxxxxxx:String) [New-Datastore], VimExcept

   ion

    + FullyQualifiedErrorId : Core_StorageServiceImpl_GetHostScsiDiskByCanonicalName_DiskNotFound,VMware.VimAutomation

   .ViCore.Cmdlets.Commands.Host.NewDatastore

I believe that when I ran the command manually in PowerCLI 6.0 it succeeded but now when I run the commmand (New-Datastore) it does not create the datastore and give the same error messages.  I have verified that the LUN exists using the following

Get-ScsiLun -VmHost <esxhost> | Where-Object {$_.CanonicalName -eq "naa.xxxxxxxxxxxxxxx"}

This return the device.   I'm not sure what is happening and I do not seem to find anything in the logs of the ESXi host or vCenter.    Any help would be greatly appreciated.

Scott

0 Kudos
LucD
Leadership
Leadership

In the mean time we're at PowerCLI 6.5R1, does that make a difference?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

I have upgrade to PowerCLI 6.5 Release 1 build 4624819 and seeing the same issue with New-Datastore when looping throught the array crated for importing a csv file:

New-Datastore : 1/28/2017 2:23:46 PM    New-Datastore        Could not find

the specified disk or the disk is already in use:

'naa.60002AC000000000000000230001C90D'

At line:1 char:27

+  foreach ($lun in $LUNs) {New-Datastore -VMHost esxpoc04.stjude.org -Name

$lun.N ...

+

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (naa.60002AC00000000000000023000

   1C90D:String) [New-Datastore], VimException

    + FullyQualifiedErrorId : Core_StorageServiceImpl_GetHostScsiDiskByCanonic

   alName_DiskNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewD

  atastore

I also recieve the same error when I run New-Datastore manually without using variables as imputs:

New-Datastore -VMHost <esxhost> -Name test -Path naa.xxxxxxxxxx -Vmfs

The LUN is still found when I run the following:

Get-ScsiLun -VmHost <esxhost> | Where-Object {$_.CanonicalName -eq "naa.xxxxxxxxxx"}


CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathP

ame                                                                  olicy

---------- -----------------              -------         ---------- ----------

naa.xxx... /vmfs/devices/disks/naa.xxx... disk             1,024.000 MostRec...

Not sure what is happening here....

0 Kudos
LucD
Leadership
Leadership

From the error message, tt looks like the vSphere server is thinking that this LUN is already in use.
Can you add a datastore on that LUN via the Web CLient?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

No issues creating the datatore from the Web Client.

0 Kudos
LucD
Leadership
Leadership

Did you already do a stop/start of your PowerShell/PowerCLI session?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

I have terminated all PowerCLI and Powershell terminals and still get the same result.

0 Kudos
LucD
Leadership
Leadership

The only way I can reproduce that error, is by providing a non-existing CanonicalName.

lun-error.png

Can you check if your CSV file is OK, and that the CanonicalNames are all correct.

Try running this

$LUNs = Import-Csv -Path <file>

foreach ($lun in $LUNs){

    Get-ScsiLun -CanonicalName $lun.UID2 -VmHost <esxhost>

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

I ran the code segment that you replied with and it return all of the LUNs that are in the CSV.  

0 Kudos
LucD
Leadership
Leadership

Then I'm afraid I'm out of ideas.

I suggest you open an SR for this issue.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
samalone
Contributor
Contributor

Finally found the issue with the script.  It ended up being a case-sensitive issue.   The UID we got from the storage team had capital letters but ESXi sees them as lower case.   Easy fix and now everything is working when adding new datastores!  Thanks!