VMware Cloud Community
pizzle85
Expert
Expert

Dynamic Types Actions

Im attempting to create a dynamic type for Veeam. I have created a rest host for the Veeam backup server and added two operations

  1. get all jobs
  2. get job by ID

I created a Veeam namespace

I created several actions but the main two are:

findVeeamJobs

var restHost = System.getModule("edu.ufl.custom.veeam").findVeeamRestHost();

var restOperation = System.getModule("edu.ufl.custom.veeam").getVeeamRestOperation(restHost, "/jobs");

System.getModule("edu.ufl.custom.veeam").setVeeamSession(restHost);

var response = restOperation.createRequest().execute();

var jsonString = RESTUtils.xml2json(response.contentAsString);

var jobs = new Array();

var jsonObject = JSON.parse(jsonString);

var refs = jsonObject.EntityReferences.Ref;

var attributes = {id: "UID", name: "Name", type: "Type", href: "Href"};

for each (var ref in refs) {

  var job = new Object();

  for(key in attributes) {

  var attribute = JSON.stringify(ref[attributes[key]]);

  var attribute = attribute.replace(/"/g, "");

  job[key] = attribute;

  }

  jobs.push(job);

}

dynamicJobs = new Array;

for each (job in jobs) {

  var dynamicJob = DynamicTypesManager.makeObject("Veeam", "Job", job.id, job.name, null);

  dynamicJobs.push(dynamicJob);

}

return dynamicJobs;

findVeeamJobById

var restHost = System.getModule("edu.ufl.custom.veeam").findVeeamRestHost();

var restOperation = System.getModule("edu.ufl.custom.veeam").getVeeamRestOperation(restHost, "/jobs/{ID}");

System.getModule("edu.ufl.custom.veeam").setVeeamSession(restHost);

var inParametersValues = [jobId];

var response = restOperation.createRequest(inParametersValues).execute();

var jsonString = RESTUtils.xml2json(response.contentAsString);

var jsonObject = JSON.parse(jsonString);

var ref = jsonObject.EntityRef;

var attributes = {id: "UID", name: "Name", type: "Type", href: "Href"};

var job = new Object();

for(key in attributes) {

  var attribute = JSON.stringify(ref[attributes[key]]);

  var attribute = attribute.replace(/"/g, "");

  job[key] = attribute;

}

dynamicJob = DynamicTypesManager.makeObject("Veeam", "Job", job.id, job.name, null);

return dynamicJob;

Both of these output the expected Veeam objects in the format job.attrib. Im really not sure whether the makeObject() part is working. The workflows finish without error so im assuming they're working fine. Both actions return DynamicTypes:DynamicObject, one is an Array the other is a single object.

Im trying to figure out what i need to write for the hasChildren and hasRelation methods on the object. The Veeam job does have children objects that are the VMs associated with the Job. Would it be appropriate to enumerate that link to get the list of VMs?

What am i missing to have a list of jobs displayed under the Veeam namespace?

Ive read the vCO Team blogs at:

http://www.vcoteam.info/articles/learn-vco/281-enabling-vcloud-automation-center-xaas-with-vco-dynam...

Dynamic Types tutorial : Implement your own Twitter plug-in without any scripting

I walked through the Dynamic Types plug-in generator and was able to successfully generate the Veeam dynamic object but it seems like plugins generated from that package have alot of dependencies on its workflows and actions and makes it difficult to export to the community. Any comments on that? Id like to make something that i could easily share and my thought creating the actions and dynamic objects manually would be the best way.

0 Kudos
1 Reply
cdecanini_
VMware Employee
VMware Employee

To show up in the inventory you need a type (typically folder) and a child type having a relation.

Using the plug-in generator V2 allows to export the plug-in as a package so you can distribute it to end user that can install it easily.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos