VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso

vCOPS - vCenter Operations Manager API via the REST plugin. Anyone doing this?

I would like to make some calls to the vCenter Operations Manager API (since VMware has no plugin for this).  I am not interested in receiving the messages via snmp and reacting to them.  I want to actually interact with the product.  Be able to make queries, configure it, etc.  Has anyone successfully connected the REST plugin to the vCOPS api?  If not does anyone have examples of working curl commands?  I can't seem to get either method to work and things seem to be failing around authentication.  We currently have the 6.0 beta deployed and that is what I am trying to interact with.  I can access the unprotected documentation here via curl just fine http://ipaddress/HttpPostAdapter/OpenAPIServlet .

0 Kudos
2 Replies
amresh2k
Contributor
Contributor

I am trying to get this to work with work getMetricDataAndDT. I will reply to you once I get somewhere positive. I can give you a basic code for this:

#!/usr/bin/perl

use strict;

use warnings;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "http://yourhostname.com/HttpPostAdapter/OpenAPIServlet";

# set custom HTTP request header fields

my $req = HTTP::Request->new(POST => $server_endpoint);

$req->header('content-type' => 'application/x-www-form-urlencoded');

$req->authorization_basic("admin", "Passw0rd!");

# add POST data to HTTP request body

my $post_data = '{ "create you own post request based on method you invoke);

my $resp = $ua->request($req);

if ($resp->is_success) {

    my $message = $resp->decoded_content;

    print "Received reply: $message\n";

}

else {

    print "HTTP POST error code: ", $resp->code, "\n";

    print "HTTP POST error message: ", $resp->message, "\n";

}

0 Kudos
Paul_Knight1
Contributor
Contributor

I have successfully managed to make calls to vCOps' HttpPostAdapter using vCO's HTTP-REST plugin (v 1.0.3.337).  I am preparing a package that will allow you to add/remove a vCOps host, then provides a workflow for each HttpPostAdapter function.  Since the HPA is a very simple REST interface, I do not bother defining a REST operation.  Rather, I send the appropriate request string by directly invoking the vCOps REST host.  The package will require that the HTTP-REST plugin already be installed.

I have attached the initial version of the package.  Consider this in Beta.  Contents provided as-is, no warranty or guarantee expressed or implied.  No one assumes any liability for your use of it.

Message was edited by: Paul.Knight

0 Kudos