Created
October 25, 2018 15:22
-
-
Save dlinsley/f0101a1f9ed4dbda584b7ede91adf850 to your computer and use it in GitHub Desktop.
Get vSphere StoragePod by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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