VMware Cloud Community
schistad
Enthusiast
Enthusiast
Jump to solution

Consuming an XML-RPC API from vCO (Not SOAP/REST)

Has anyone got any examples of consuming an XML-RPC API?

I'm trying to automate an old version of RedHat Satellite, before they implemented a REST-compliant API.

It's quite easy to write python code against it using the xmlrpclib, so one idea I've been playing around with is to wrap Python scripts inside of a vCO action or script task. But I've never seen examples of how to use stdin / stdout /stderr of an external program, so there might be a lot of fiddling involved.

The ideal solution would of course be if there was a Python plugin for vCO but alas, no such beast exists it seems.

Alternatively, an XML-RPC module for JavaScript should be a workable solution, but I guess I'd need to load that library from outside of the vCO sandbox.

1 Solution

Accepted Solutions
jbweber2
Enthusiast
Enthusiast
Jump to solution

I had a similar issue where I was trying to integrate with cobbler and I found some code which did xmlrpc from javascript. I reworked it to use e4x which ended up being the easiest way to deal with it from vCO, and created some actions to represent the available options.

I didn't actually end up using this code, but the limited testing I did with it worked.

I don't have an easy way to export / host a package for you, but this gist includes the pieces required to recreate what I built. Let me know if you have any questions.

https://gist.github.com/jbweber/11401647

View solution in original post

Reply
0 Kudos
10 Replies
jbweber2
Enthusiast
Enthusiast
Jump to solution

I had a similar issue where I was trying to integrate with cobbler and I found some code which did xmlrpc from javascript. I reworked it to use e4x which ended up being the easiest way to deal with it from vCO, and created some actions to represent the available options.

I didn't actually end up using this code, but the limited testing I did with it worked.

I don't have an easy way to export / host a package for you, but this gist includes the pieces required to recreate what I built. Let me know if you have any questions.

https://gist.github.com/jbweber/11401647

Reply
0 Kudos
schistad
Enthusiast
Enthusiast
Jump to solution

Thanks for sharing, looks very close to what I'm  trying to do.

One small question: Where does the cofront.xmlrpc module come from? Do I need to expose a java module to vCO before it loads?

A quick test in the vCO-CLI fling gets me this:

System.getModule("cofront.xmlrpc").createRequest("login", [username, password]);

TypeError: Cannot find function createRequest in object Module:org.mozilla.javascript.Arguments@7c215f75.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

The "cofront.xmlrpc" is simply the name of the Action Module (folder  that holds the actions) that contains the action named "createRequest" ... so if you wish to replicate:

1) Create new module (again, this is simply a folder in the Actions part of vCO Client) named "cofront.xmlrpc"

2) Create new action named "createRequest" in that module and paste in the code provided from the gist

3) Add your relevant input(s) and specify a return

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
AlexAllenExpedi
Enthusiast
Enthusiast
Jump to solution

I am in the same boat as the OP. The GIST is no longer available as its been almost a year.

Can you please repost?

~Alex

Reply
0 Kudos
schistad
Enthusiast
Enthusiast
Jump to solution

Here you go.

AlexAllenExpedi
Enthusiast
Enthusiast
Jump to solution

Thank you for reposting I really appreciate it.

~Alex

Reply
0 Kudos
schistad
Enthusiast
Enthusiast
Jump to solution

Sure, no worries – just paying the original favor forward Smiley Wink

Reply
0 Kudos
smastrorocco
Contributor
Contributor
Jump to solution

were you able to get this to work over HTTPS?  When I try, I get errors indicating the certificate is not trusted in the JVM store like this:

HTTP POST error : sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I've tried importing the certificate in the vCO trusted store, but it doesn't seem to affect the JVM store.  I don't really want to go to the point of modifying the JVM store in the vCO appliance and risk any unsupported config within vCO.

Over HTTP I can tweak all of this and it works great.  Thanks for that, but HTTPS is sort of needed for security in out environment, especially with username/password clear text for session key.

Reply
0 Kudos
smastrorocco
Contributor
Contributor
Jump to solution

well, i couldn't get it to work any other way.  i manually imported the certificate into the java keystore on the vco appliance, restarted the vm, and now it works over https.

Reply
0 Kudos
cjapes
Contributor
Contributor
Jump to solution

You could use the vCO REST plugin anyway. If you just set the REST host's URL to your XML-RPC server address without any path (e.g. http://yourhost.yourdomain.com, https is also possible).

When adding a REST operation you set the URL template to the XML-RPC interface path (e.g. "/rpc/api") and the defaultContentType to "text/xml".

The "Invoke a Rest operation" workflow takes the needed XML-RPC request in the input parameter "content" and returns the XML response in the "contentAsString" output parameter.

Reply
0 Kudos