VMware Cloud Community
evizc
Contributor
Contributor

Cloning VMs, select datastores

I've managed to create  any given amount of VMs with a workflow by just entering the number by the user. The thing is they all are created in the datastore that I previously assigned. Is it possible to change the datastore in the script? Say, the first VM (TEST1) is created under the datastore1, but then TEST2 should be created in datastore2. All of this should be within the script without the user having to do anything. Any ideas?

Note:

The object VcDatastore is read only.

Thank you

2 Replies
befreeman
Enthusiast
Enthusiast

If you're doing this with an Action, you could call the VcPlugin.getAllDatastores() method and then try to find a match for the name you want.

Something like this, passing in the name of the datastore you're looking for:

var datastores = VcPlugin.getAllDatastores();

for (var i in datastores) {

    if (datastores[i].name === lookForDatastore) {

        return datastores[i];

    }

}

return null;

evizc
Contributor
Contributor

Thanks! That really worked fine

Reply
0 Kudos