mirror of
https://github.com/jbowdre/vRealize.git
synced 2024-11-21 09:22:18 +00:00
Create vraGetNetworksUnsorted.js
This commit is contained in:
parent
958daa08f6
commit
1b80e993d9
1 changed files with 46 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
/* JavaScript: vraGetNetworksUnsorted action
|
||||
Retrieves an (unsorted) list of network names and corresponding constraint tags available for deployment in a given zone.
|
||||
Inputs: zoneName (string)
|
||||
Return type: Properties
|
||||
*/
|
||||
if (!(zoneName == "" || zoneName == null)) {
|
||||
var regionUri = null;
|
||||
var token = System.getModule("com.virtuallypotato.utility").vraLogin();
|
||||
var zones = JSON.parse(System.getModule("com.virtuallypotato.utility").vraExecute(token, "GET", "/iaas/api/zones", null)).content;
|
||||
System.debug("Zones: " + JSON.stringify(zones));
|
||||
for each (zone in zones) {
|
||||
if (zone.name === zoneName) {
|
||||
System.debug("Matching zone: " + zone.name);
|
||||
regionUri = zone._links.region.href;
|
||||
}
|
||||
if (regionUri != null) { break; };
|
||||
}
|
||||
System.debug("Matching region URI: " + regionUri);
|
||||
|
||||
var networkProfiles = JSON.parse(System.getModule("com.virtuallypotato.utility").vraExecute(token, "GET", "/iaas/api/network-profiles", null)).content;
|
||||
System.debug("Network profiles: " + JSON.stringify(networkProfiles));
|
||||
networks = new Properties();
|
||||
networkProfiles.forEach(
|
||||
function (networkProfile) {
|
||||
if (networkProfile._links.region.href === regionUri) {
|
||||
for each (uri in networkProfile._links["fabric-networks"].hrefs) {
|
||||
var networkProps = JSON.parse(System.getModule("com.virtuallypotato.utility").vraExecute(token, "GET", uri, null));
|
||||
System.debug(JSON.stringify(networkProps));
|
||||
var networkTag = null;
|
||||
for each (tag in networkProps.tags) {
|
||||
if (tag.key === "network") {
|
||||
networkTag = "network:" + tag.value;
|
||||
}
|
||||
if (networkTag != null) { break; };
|
||||
}
|
||||
networks.put(networkTag, networkProps.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
System.getModule("com.virtuallypotato.utility").vraLogout(token);
|
||||
return networks;
|
||||
} else {
|
||||
return [""];
|
||||
}
|
Loading…
Reference in a new issue