Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

Need XML APIs for finding server status details

Hi,

Can any one help me with the XML API format for finding server status details like Admin State,Avail State,Assoc State,etc.

Thanks and Regards

-Prateek

Everyone's tags (3)
2 ACCEPTED SOLUTIONS

Accepted Solutions
New Member

Re: Need XML APIs for finding server status details

It looks like the UCSM uses this call to get the info in the table base of the Servers tab.

    

         

    

That's the Service Profile view. Here's the blade hardware view:

    

Cisco Employee

Re: Need XML APIs for finding server status details

Here is a very basic example.  I pulled out all the extra error trapping / logging.  I have been building a module that simplifies  most of this .. will produce simple Dumper output for what you are generally looking to do.

The below example will connect to a default UCSM emulator ( http://developer.cisco.com/web/unifiedcomputing/start ) .. just change IP to match.  If you want a significantly more detailed information ( hierarchical ) ... change inHierarchical="false" to  inHierarchical="true".

Let me know if you want something more specific.

#!/usr/local/bin/perl


use strict;

use warnings;

use Data::Dumper;

use LWP::UserAgent;

use HTTP::Request::Common;

use XML::Simple;

use POSIX;


$Data::Dumper::Purity = 1;

$Data::Dumper::Useqq = 1;


### Configurables

my $ucsm = "10.#.#.#";

my $user = "config";

my $pass = "config";

my $proto = "http";


my $cookie;

my $xml = XML::Simple->new();

my $xml_blade = XML::Simple->new(ForceArray => ['computeBlade']);


## Setup User Agent

my $ContentType = "application/x-www-form-urlencode";

my $userAgent = LWP::UserAgent->new(agent => 'perl post');

$userAgent->timeout(5);



&connect;

my $blades = &getblade;

print Dumper $blades;

&disconnect;


### Subroutines


sub connect {

   my $message = q();

   print 'http://'.$ucsm.'/nuova\n';

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

   my $xml_ref = $xml->XMLin($response->content);

   $cookie = $xml_ref->{outCookie};

}


sub getblade {

   my $message = q();

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

   my $xml_ref = $xml_blade->XMLin($response->content, keyattr => []);

   return $xml_ref->{outConfigs};

}


sub disconnect {

   my $message = q();

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

}

3 REPLIES
New Member

Re: Need XML APIs for finding server status details

It looks like the UCSM uses this call to get the info in the table base of the Servers tab.

    

         

    

That's the Service Profile view. Here's the blade hardware view:

    

Cisco Employee

Re: Need XML APIs for finding server status details

Here is a very basic example.  I pulled out all the extra error trapping / logging.  I have been building a module that simplifies  most of this .. will produce simple Dumper output for what you are generally looking to do.

The below example will connect to a default UCSM emulator ( http://developer.cisco.com/web/unifiedcomputing/start ) .. just change IP to match.  If you want a significantly more detailed information ( hierarchical ) ... change inHierarchical="false" to  inHierarchical="true".

Let me know if you want something more specific.

#!/usr/local/bin/perl


use strict;

use warnings;

use Data::Dumper;

use LWP::UserAgent;

use HTTP::Request::Common;

use XML::Simple;

use POSIX;


$Data::Dumper::Purity = 1;

$Data::Dumper::Useqq = 1;


### Configurables

my $ucsm = "10.#.#.#";

my $user = "config";

my $pass = "config";

my $proto = "http";


my $cookie;

my $xml = XML::Simple->new();

my $xml_blade = XML::Simple->new(ForceArray => ['computeBlade']);


## Setup User Agent

my $ContentType = "application/x-www-form-urlencode";

my $userAgent = LWP::UserAgent->new(agent => 'perl post');

$userAgent->timeout(5);



&connect;

my $blades = &getblade;

print Dumper $blades;

&disconnect;


### Subroutines


sub connect {

   my $message = q();

   print 'http://'.$ucsm.'/nuova\n';

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

   my $xml_ref = $xml->XMLin($response->content);

   $cookie = $xml_ref->{outCookie};

}


sub getblade {

   my $message = q();

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

   my $xml_ref = $xml_blade->XMLin($response->content, keyattr => []);

   return $xml_ref->{outConfigs};

}


sub disconnect {

   my $message = q();

   my $response = $userAgent->request(POST $proto.'://'.$ucsm.'/nuova', Content_Type => $ContentType, Content => $message);

}

New Member

Re: Need XML APIs for finding server status details

Thanks Guys ..

It worked for me ...

560
Views
0
Helpful
3
Replies
CreatePlease to create content