Created
May 12, 2018 01:01
-
-
Save trisharia/090e891fbde1275931c8209632647fe6 to your computer and use it in GitHub Desktop.
Get the network names of a compute resource (IaaS)
This file contains 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 | |
// | |
// Get the network names of a compute resource (IaaS) | |
// | |
// For vRO/VRA 7.0+ | |
// | |
// Action Inputs: | |
// vcacHost - vCAC:VCACHost - vRA IaaS Host | |
// reservationEntity - vCAC:Entity - Compute resource entity | |
// | |
// Return type: Array/string - Network names | |
if (vcacHost == null) return null; | |
if (computeResourceEntity == null) return null; | |
var networkNames = []; | |
var nicEntity; | |
var linkEntities = computeResourceEntity.getLink(vcacHost, "HostNics"); | |
for each (var n in linkEntities) { | |
nicEntity = getNicEntityById(vcacHost.id, n.getProperty("HostNicID")); | |
if (nicEntity) { | |
networkNames.push(nicEntity.getProperty("HostNicName")); | |
} | |
} | |
return networkNames.sort(); | |
function getNicEntityById(hostId, id) { | |
var model = "ManagementModelEntities.svc"; | |
var entitySetName = "HostNics"; | |
var filters = new Properties(); | |
filters.put("HostNicID", id); | |
return vCACEntityManager.readModelEntity(hostId, model, entitySetName, filters, null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment