deama10

Service Catalog Vmware plugin

Blog Post created by deama10 Employee on Jun 12, 2018

Hi guys, this is my two cents on ca service catalog plugins, I'll post a few that I have design. I also have lots of process automation connectors, I'll start sharing them this week.

 

So one thing that almost every offer that do provisioning of virtual machines have is a necessity to list, preferably in real time, the elements of Vmware environment. To do this integration, I did two plugins, one that uses the new Rest API, and another that uses the Vmware Java SDK.

 

This is the plugin description in service catalog

 

The thing that I can't do, or don't know how to, is get a list of the vcenters, as even if I'm connected to a administration vcenter that manage others, I can't seem to get a list of them all. For this part, you are probably going to have a custom table in a auxiliar database with a list of vcenters. You'll probably need a column for their name, another for the ip (the info that we need), and a id at least.

 

To use my plugin, you'll need a vcenter ip to be passed as parameter to each plugin call. 

A plugin call looks like this in browsers console (this is the example in service catalog documentation):

 

function foo() {
  ca_fdInvokePlugin('select',
                    'com.ca.select.plugin',
                    {'buId':_.bu.id, 'userId': _.user.id, 'num':2},
                    fooCallback);
}

function fooCallback(results) {
  var i = 0;
  for (i = 0; i < results.length; i++) {
    console.log(results[i]);
    console.log('option name:' + results[i].name);
    console.log('option value:' + results[i].value);
  }
}

So this is a way to test if your plugin is working without the need to create a form.

 

My first plugin call would be like this:

 

function foo() {
    ca_fdInvokePlugin(
        //so I pass the plugin name
        'select', 'ca.catalog.vmware.sdk.plugin',
        //json with parameters to be passed to the plugin, always in upperCase
        $({
            //the vcenter_ip (I get this value from a input hidden)
            'VM_SERVER': $(ca_fdGetTextFieldValue(ca_fd.formId, 'txtf_vcenter_ip')).selector,
            //And I say that I want to get Cluster objects.

            'OBJ_TYPE': 'CLUSTER'
        }),
        //the callback funcion that will get my results
        fooCallback);
}

function fooCallback(results) {
    var i = 0;
    for (i = 0; i < results.length; i++) {
        console.log(results[i]);
        console.log('option name:' + results[i].name);
        console.log('option value:' + results[i].value);
    }
}
//call the function
foo();

 

 

In a usual form, I would select the vcenter > the cluster > the datastorecluster, for example

I'll upload a export that will have a simple form with this chain selection.

Something like this (the vcenter-ip is a hidden input

 

 

Hope you guys enjoy

 

 

ps. Needs a Service Catalog that uses java 1.7+

Outcomes