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
System.log("==== Begin: vRA Event Broker Payload Properties ===="); | |
logAllProperties(payload,0); | |
System.log("==== End: vRA Event Broker Payload Properties ===="); | |
function logAllProperties(props,indent) { | |
var keys = (props.keys).sort(); | |
for each (var key in keys) { | |
var prop = props.get(key); | |
var type = System.getObjectType(prop); | |
if (type == "Properties") { |
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
/** | |
* vRO script to update scripts of all actions inside a vRO action module | |
* | |
* @version 1.0.0 | |
* | |
* @param {Module} actionModule | |
* | |
* @outputType string | |
* | |
*/ |
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
// the array of the IP Address | |
// Custom Comparator to sort the | |
// Array in the increasing order | |
function customComparator(a, b){ | |
// Breaking into the octets | |
var octetsA = a.split("."); | |
var octetsB = b.split("."); |
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
if(arguments.callee.name.substr(6)) System.setLogMarker("ACTION: "+arguments.callee.name.substr(6)); | |
var vraRestHost = vraHost.createRestClient(); | |
System.log("vRA hostname: "+vraHost.name); | |
var loginObj = {}; | |
loginObj.domain = domain; | |
loginObj.password = password; | |
loginObj.username = username; | |
var loginBody = JSON.stringify(loginObj); | |
var operationUrl = "/csp/gateway/am/api/login"; |
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
const module = { | |
x: 42, | |
getX: function() { | |
return this.x; | |
} | |
}; | |
const unboundGetX = module.getX; | |
System.log(unboundGetX()); // The function gets invoked at the global scope | |
// expected output: undefined |
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
/* Using arguments.callee in an anonymous recursive function | |
A recursive function must be able to refer to itself. Typically, a function refers to itself by its name. However, an anonymous function (which can be created by a function expression or the Function constructor) does not have a name. Therefore if there is no accessible variable referring to it, the only way the function can refer to itself is by arguments.callee. | |
The following example defines a function, which, in turn, defines and returns a factorial function. This example isn't very practical, and there are nearly no cases where the same result cannot be achieved with named function expressions. */ | |
function create() { | |
return function (n) { | |
if (n <= 1) { | |
return 1; | |
} |
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
// The Y-combinator: a utility function! | |
var Y = function Y(hof) { | |
return function (x) { | |
return x(x); | |
}(function (x) { | |
return hof(function (y) { | |
return x(x)(y); | |
}); | |
}); | |
}; |
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
//Assumimg vRA 8.x plugin is already installed in vRO | |
// typeof host = vRA:Host | |
var restClient = host.createRestClient(); | |
var items = []; | |
var path = "/deployment/api/deployments"; // or any other API path | |
var page = 0; | |
var page_size = 200; // smaller page_size means more pages to parse | |
var base_path = path + "?$top=" + page_size; | |
while (true) { | |
var skipFilter = page * page_size; |
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
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
// How to use | |
// console.log(Base64.encode("username:pa$$w0rd!")); => dXNlcm5hbWU6cGEkJHcwcmQh | |
var Base64 = { |