vRA 8 Dump VM Properties

By | 10 February 2022

Create a workflow using this and call it during Machine Provisioned Post in vRA 8.x to dump all the properties of the VM being deployed. Can be helpful troubleshooting builds.

function dumpProperties(props,lvl){
         var keys = props.keys;
         var prefix = ""
     for (var i=0; i<lvl; i++){
                   prefix = prefix + "";
          }
          for (k in keys){
                 var key = keys[k];
                 var value = props.get(keys[k])
                 if ("Properties" == System.getObjectType(value)){
                  System.log(prefix + key + "[")
                  dumpProperties(value,(lvl+2));
                  System.log(prefix+ "]")
                 } else{
                   System.log( prefix + key + ":" + value)
                 }
                 }
}

dumpProperties(inputProperties, 0);

var customProps = inputProperties.get("customProperties");
var resourceNames = inputProperties.get('resourceNames');
var tag_data = inputProperties.get("tags");

var vmname = resourceNames[0];
System.log ("VM Name is: " + vmname);
var addresses = inputProperties.get('addresses')
var IPaddress = addresses[0][0];

System.log("IPaddress is: " + IPaddress);
System.log("Custom Properties length is: " + customProps.length);

for(var i in customProps){
    System.log("Custom Property Key: " + i + ". Value is " + customProps[i]);
}

System.log("Input Properties length is: " + inputProperties.length);

for(var i in inputProperties){
    System.log("Input Property Key: " + i + ". Value is " + inputProperties[i]);
}

for(var i in tag_data){
    System.log("Tag is: " + i + ". Value is " + tag_data[i]);
}

System.log("Network ID is: " + inputProperties["subnetIds"]);

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.