diff --git a/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js new file mode 100644 index 0000000..a249446 --- /dev/null +++ b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js @@ -0,0 +1,13 @@ +/* JavaScript: vcLogin action + Retrieves a login token to a vCenter REST endpoint. + Inputs: vCenterName (string) + Return type: string +*/ +var host = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", vCenterName).host; +var request = host.createRequest("POST", "/api/session"); +request.setHeader("Content-Type", "application/json"); +var response = request.execute(); +var token = JSON.parse(response.contentAsString); +System.debug("Created vCenter API session: " + token); + +return token;