VCF Automation Blog

from Stefan Schnell

List all Actions and Workflows


function getAllActions() {
  // com.vmware.library.action.getAllActions
  var actions = new Array();
  var modules = System.getAllModules();
  for (i in modules) {
    var actionDescriptions = modules[i].actionDescriptions;
    for (j in actionDescriptions){
      actions.push(actionDescriptions[j]);
    }
  }
  return actions;
}

function getAllWorkflows() {
  // com.vmware.library.workflow.getAllWorkflows
  function getWorkflowsOfCategory(cat) {
    workflows = workflows.concat(cat.workflows);
    var cats = cat.subCategories;
    if (cats != null) {
      for (index in cats) {
        if (cats[index] != null) {
          getWorkflowsOfCategory(cats[index]);
        }
      }
    }
  }
  var workflows = new Array();
  var categories = Server.getAllWorkflowCategories();
  for (i in categories) {
    getWorkflowsOfCategory(categories[i]);
  }
  return workflows;
}

function main() {

  System.log(">>>Actions<<<");
  // var allActions =
  //   System.getModule("com.vmware.library.action").getAllActions();
  var allActions = getAllActions();
  allActions.forEach( function(action) {
    System.log(action.module.name + "." + action.name + "_" +
      action.version);
  });

  System.log(">>>Workflows<<<");
  // var allWorkflows =
  //   System.getModule("com.vmware.library.workflow").getAllWorkflows();
  var allWorkflows = getAllWorkflows();
  allWorkflows.forEach( function(workflow) {
    System.log(workflow.workflowCategory.path + "/" + workflow.name + "_" +
      workflow.version);
  });

}

main();

Hint: See also the posts