VMware Cloud Community
Mike2k14
Contributor
Contributor
Jump to solution

Mount existing NFS datastore

Hi all,

im trying to automate the installation of physical esxi servers..
Progress is quite good, but i´m stuck on mounting exisiting NFS datastores.

While searching i only found createNasDatastore within esxhost.configManager
But this command just creates a new datastore with a (1) appended at the end.

Anyone has an idea how to solve this ?

Best regards,
Michael

Reply
0 Kudos
1 Solution

Accepted Solutions
aslk5
Enthusiast
Enthusiast
Jump to solution

Maybe I'm not understanding correctly but that function will mount a nfs datastore to a host with whatever name you want. This little piece of code should mount a datastore called mynfsdatastore to a host called myhost (myhost is a Vc:HostSystem).

var spec = new VcHostNasVolumeSpec();

spec.remotePath = "/path/to/share/on/server";

spec.remoteHost = "nfsserver.mydomain.local"

spec.localPath = "mynfsdatastore"

spec.accessMode = "readWrite";

spec.type = "NFS";

myhost.configManager.datastoreSystem.createNasDatastore(spec);

If that doesn't work you can always try installing the HTML5 fling and then simply recording your actions. You can choose to output vRO Javascript and I find it quite handy as a starting point to get the code I need when I'm stuck.

View solution in original post

2 Replies
aslk5
Enthusiast
Enthusiast
Jump to solution

Maybe I'm not understanding correctly but that function will mount a nfs datastore to a host with whatever name you want. This little piece of code should mount a datastore called mynfsdatastore to a host called myhost (myhost is a Vc:HostSystem).

var spec = new VcHostNasVolumeSpec();

spec.remotePath = "/path/to/share/on/server";

spec.remoteHost = "nfsserver.mydomain.local"

spec.localPath = "mynfsdatastore"

spec.accessMode = "readWrite";

spec.type = "NFS";

myhost.configManager.datastoreSystem.createNasDatastore(spec);

If that doesn't work you can always try installing the HTML5 fling and then simply recording your actions. You can choose to output vRO Javascript and I find it quite handy as a starting point to get the code I need when I'm stuck.

Mike2k14
Contributor
Contributor
Jump to solution

Thanks for the idea, that helped a lot.

The NFS store is mounted read-only on my other ESXi servers. As i tried to mount it read-write it created a different store with the same name plus (1)....

Reply
0 Kudos