VMware Cloud Community
gpduck
Contributor
Contributor

Get-Datastore inconsistently returns RemoteHost for NFS datastores

When we run the following:

Get-Datastore | Where-Object { $_.Type -eq "NFS" } | Select Name,RemoteHost

We're only getting data in the RemoteHost property for some of our datastores.  We're only seeing this on some versions of PowerCLI:

PowerCLI VersionStatus
VMware vSphere PowerCLI 6.0 Release 3 build 3205540Broken
VMware vSphere PowerCLI 6.0 Release 1 build 2548067Works
VMware vSphere PowerCLI 5.5 (not sure about release)Works

On the broken version of PowerCLI, the RemoteHost property is listed as String[], while on the working versions it is just String.  We used Fiddler to watch the API calls to our Virtual Center server and notice that the broken datastores do not report a RemoteHostNames property in the NasDatastoreInfo data, but the working ones do.  Here is a snip of both responses, the broken one is on the left:

DatastoreCapture.png

Our Virtual Center is running 6.0.0 Build 2656760.  I'm not sure what else to include here, I have no idea why Virtual Center is sending back different property sets for datastores in the separate datacenters, but it seems like PowerCLI should be falling back to the "remoteHost" property when "remoteHostNames" is not present.

0 Kudos
4 Replies
likeahoss
Enthusiast
Enthusiast

Check (get-datastore).ExtensionData.Info.Nas.RemoteHostNames

# This is slow but gets the job done.

get-datastore | select name, @{N="RemoteHostName";E={$_.ExtensionData.info.nas.remotehostnames}}

# this is faster!

$rhn = get-view -viewtype datastore

$rhn | select Name, @{N="RemoteHostName";E={$rhn.info.nas.remotehostnames[0]}} | fl

0 Kudos
av81
Contributor
Contributor

I'm experiencing a similar issue too, but only on one of our VCSAs (running the same version).

VCSA versions:          6.0.0.10200

PowerCLI version:     6.3 R1

The following returns nothing for remotehost.

get-datastore | ?{$_.type -eq "nfs"} | fl name,remote*

However, the data is there when I use get-view.

0 Kudos
gpduck
Contributor
Contributor

We got around the issue by using the values in the extension data (which always seems to be populated) as suggested here, but it would be nice if the objects coming off of Get-Datastore would have their values populated correctly without having to dig around the internals.

It looks like the NasDatastoreImpl constructor is using "RemoteHostNames" if the connection is using the v6.0 API and falling back to "RemoteHost" otherwise, but the v6 API doesn't always seem to set that value.  Maybe it should check to see if "RemoteHostNames" has a value and if not fall back to "RemoteHost"?

Right now neither of my NAS datastores are showing a value for RemoteHost.  I assume it is changing based on which host the data is being gathered through (we currently have mixed 5.5 and 6 hosts).  It doesn't seem like the vSphere API version is a reliable way to test for these values.

0 Kudos
MarcSmid
Contributor
Contributor

Does anybody has an answer for the porignal question ?

I want to use get-datastore to do an easy nfs config on several host by referencing 1 production host.

http://blogs.dootdoot.com/mike/2012/03/23/powercli-copy-esxi-nfs-layout/

But half the time $datastore.RemoteHost does not return an ip, so half my nfs stores aren't mounted.

0 Kudos