VMware {code} Community
ZackZhang
Contributor
Contributor

How to mount a datastore to a host using VIJava API?

Hi,

     This should be pretty straightforward as what I'm asking for is a very basic operation : mount a datastore to a host.  But somehow after I looked through the classes in vSphere SDK I just can't seem to find a method that does it, maybe I looked at the wrong place? Really appreciate all the help I can get.

    So in my recent project I have an use case to “change hosts for vmfs datastore storage”, so I figure in order to do it, I’ll need to :

    1)    remove the datastore from the current host

    2)    mount it to another host.

    I checked the SDK and thought that in order to do 1), I can write code like:

          HostDatastoreSystem hds = hostSystem.getHostDatastoreSystem();

          hds.removeDatastore(datastoreToRemove);            

    But I didn’t see any API that does 2) (I was expecting that HostDatastoreSystem would have a method like mountDatastore...), so can any one please educate me on how to do 2) ?

    Thanks in advance!

Reply
0 Kudos
0 Replies