mirror of
https://github.com/jbowdre/vRealize.git
synced 2024-11-21 09:22:18 +00:00
Create vraLogin.js
This commit is contained in:
parent
84338c5b30
commit
c16c6a54f2
1 changed files with 19 additions and 0 deletions
19
Orchestrator/Actions/com.virtuallypotato.utility/vraLogin.js
Normal file
19
Orchestrator/Actions/com.virtuallypotato.utility/vraLogin.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* JavaScript: vraLogin action
|
||||
Retrieves a login token to a vRA REST endpoint.
|
||||
Inputs: none
|
||||
Return type: string
|
||||
*/
|
||||
var restHost = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", "vRAHost");
|
||||
var host = restHost.host;
|
||||
var loginObj = {
|
||||
domain: restHost.domain,
|
||||
password: restHost.password,
|
||||
username: restHost.username
|
||||
};
|
||||
var loginJson = JSON.stringify(loginObj);
|
||||
var request = host.createRequest("POST", "/csp/gateway/am/api/login", loginJson);
|
||||
request.setHeader("Content-Type", "application/json");
|
||||
var response = request.execute();
|
||||
var token = JSON.parse(response.contentAsString).cspAuthToken;
|
||||
System.debug("Created vRA API session: " + token);
|
||||
return token;
|
Loading…
Reference in a new issue