VMware Cloud Community
OsburnM
Hot Shot
Hot Shot
Jump to solution

How to Execute Bluecat API calls with a Scriptable Task in vRO 6

Throwing this out to the community for some guidance.  I'm still VERY new to javascript & vRO.

I have vRO6 running with the Bluecat IPAM Plugin installed and working with the out-of-the-box actions & plugins.  Great.

What I'm struggling with is that I'm trying to create some custom scriptable tasks that can do "other" things listed in the Bluecat API guide..  Looking at the guide, some things are easy but others make absolutely no sense to me.

An example of what I don't understand is the follow... the API guide will show an example specific to java api coding but it doesn't explain how I do that in a vRO scriptable task.

Update in Java:

APIEntity zone = service.getEntityById( zoneId );

EntityProperties properties = new EntityProperties(zone.getProperties()); //Populate with the existing values and then update the only properties which need to be modified.

properties.addProperty("TextUDF", "testTextValue");

properties.addProperty("IntegerUDF", "1005");

zone.setProperties(properties.getPropertiesString());

service.update(zone);

So that's 6 lines of code but executing a vRO Bluecat api call seems to be expecting a single line something like this:

result = BCNProteusAPI.call( profileName, "method()", args );

Am I making any sense?  Any guidance here? 

Thanks!!!

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

The version of the plug-in available on SolutionExchange seems to expose a single vRO scripting object BCNProteusAPI that acts as a proxy to Proteus service calls. So, the Java method calls that look like service.someMethod(args) should be directly translatable to scripting calls BCNProteusAPI.call(profileName, "someMethod", [args]); For the example you provided, the Java calls

APIEntity zone = service.getEntityById( zoneId );

service.update(zone);

might look in vRO scripting like

var zone = BCNProteusAPI.call(profileName, "getEntityById", [zoneId] );

BCNProteusAPI.call(profileName, "update", [zone]);

Unfortunately, the other Proteus API objects, like APIEntity, EntityProperties, etc. are not exposed as vRO scripting objects, which could cause problems if some service API require such object as an input parameter. You will probably be able to pass such object returned from a service call as an input to another service call (like zone in the above sample), but you may have problems to directly instantiate them (like EntityProperties in the Java code sample).

You may want to contact BlueCat for info why not all objects are exposed as vRO scripting objects and how they recommend to use these objects.

View solution in original post

2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

The version of the plug-in available on SolutionExchange seems to expose a single vRO scripting object BCNProteusAPI that acts as a proxy to Proteus service calls. So, the Java method calls that look like service.someMethod(args) should be directly translatable to scripting calls BCNProteusAPI.call(profileName, "someMethod", [args]); For the example you provided, the Java calls

APIEntity zone = service.getEntityById( zoneId );

service.update(zone);

might look in vRO scripting like

var zone = BCNProteusAPI.call(profileName, "getEntityById", [zoneId] );

BCNProteusAPI.call(profileName, "update", [zone]);

Unfortunately, the other Proteus API objects, like APIEntity, EntityProperties, etc. are not exposed as vRO scripting objects, which could cause problems if some service API require such object as an input parameter. You will probably be able to pass such object returned from a service call as an input to another service call (like zone in the above sample), but you may have problems to directly instantiate them (like EntityProperties in the Java code sample).

You may want to contact BlueCat for info why not all objects are exposed as vRO scripting objects and how they recommend to use these objects.

sbeaver
Leadership
Leadership
Jump to solution

I found the Bluecat plugin a but lacking and below is an example of the code I am using when making calls to Bluecat.  Each soap call to Bluecat will need a logon, the soap call your really after and finally a logout. 

//var username = "username"

//var password = "password"

//var host = Server.findForType("SOAP:Host", "7915b0ce-7481-4104-a645-f7711cee02fb");

if (host == null) throw "Host '7915b0ce-7481-4104-a645-f7711cee02fb' not found!";

var operation = host.getOperation("login");

//var operation = logon

if (operation == null) throw "Operation 'login' not found!";

function formatDate(inDate){

  if (!inDate) {

     return null;

  }

  dateRfc822 = System.formatDate(inDate, "yyyy-MM-dd'T'HH:mm:ssZ")

  return dateRfc822;

}

System.log("creating request...");

var request = operation.createSOAPRequest();

request.setInParameter("username",username);

request.setInParameter("password",password);

System.log("invoking '" + operation.name + "' operation...");

var response = operation.invoke(request);

System.log("operation '" + operation.name + "' successfully invoked.");

System.log("processing response...");

var result1 = new Properties();

System.log(result1);

//*****************

//Next API call

//*****************

//var host = Server.findForType("SOAP:Host", "93880998-31f8-422a-ac16-89cadb65cb8f");

//var host = Server.findForType("SOAP:Host", "7915b0ce-7481-4104-a645-f7711cee02fb");

if (host == null) throw "Host '93880998-31f8-422a-ac16-89cadb65cb8f' not found!";

var operation = host.getOperation("getEntityByName");

if (operation == null) throw "Operation 'getEntityByName' not found!";

function formatDate(inDate){

  if (!inDate) {

     return null;

  }

  dateRfc822 = System.formatDate(inDate, "yyyy-MM-dd'T'HH:mm:ssZ")

  return dateRfc822;

}

System.log("creating request...");

var request = operation.createSOAPRequest();

request.setInParameter("parentId","0");

request.setInParameter("name","internal")

request.setInParameter("type","Configuration")

System.log("invoking '" + operation.name + "' operation...");

var response = operation.invoke(request);

System.log("operation '" + operation.name + "' successfully invoked.");

System.log("processing response...");

var result = new Properties();

System.log("out headers...");

outHeaders = System.getModule("com.vmware.library.soap").processOutHeaders(response);

System.log("out parameters...");

outParameters = System.getModule("com.vmware.library.soap").processOutParameters(response);

var result = outParameters.get("return.properties");

var id = outParameters.get("return.id");

var ipProps = id

var ipString = id.toString()

System.log(id);

//var blah = propStr.split("|");

//for each ( var b in blah ){

//System.log(b)

//}

//var ipAddr = blah[8];

//ipAddr = ipAddr.replace("address=","");

//System.log(ipAddr);

//*****************

//Next API call

//*****************

var operation = host.getOperation("logout");

if (operation == null) throw "Operation 'logout' not found!";

function formatDate(inDate){

  if (!inDate) {

     return null;

  }

  dateRfc822 = System.formatDate(inDate, "yyyy-MM-dd'T'HH:mm:ssZ")

  return dateRfc822;

}

System.log("creating request...");

var request = operation.createSOAPRequest();

//request.setInParameter("username",username);

//request.setInParameter("password",password);

System.log("invoking '" + operation.name + "' operation...");

var response = operation.invoke(request);

System.log("operation '" + operation.name + "' successfully invoked.");

System.log("processing response...");

var result3 = new Properties();

System.log(result3);

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**