Skip to content

Instantly share code, notes, and snippets.

@dlinsley
Created October 25, 2018 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlinsley/f0101a1f9ed4dbda584b7ede91adf850 to your computer and use it in GitHub Desktop.
Save dlinsley/f0101a1f9ed4dbda584b7ede91adf850 to your computer and use it in GitHub Desktop.
Get vSphere StoragePod by name
// VMware vRealize Orchestrator action sample
// Searches a vCenter or all known vCenters for a StoragePod (Datastore Cluster)
//
// ensures the search only matches one StoragePod
//
//Action Inputs:
// vCenter - VC:SdkConnection (Optional)
// storagePodName - String
//
//Return type: VC:StoragePod
var found;
if (vCenter) {
found = vCenter.getAllVimManagedObjects('StoragePod', null, "xpath:name[matches(.,'" + storagePodName + "')]");
} else {
found = VcPlugin.getAllVimManagedObjects('StoragePod',null, "xpath:name[matches(.,'" + storagePodName + "')]");
}
if (found.length > 1) {
throw(storagePodName+" matched more than one StoragePod");
}
if (found.length == 0) {
throw(storagePodName+" StoragePod does not exist");
}
return found[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment