cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1177
Views
0
Helpful
3
Replies

Need XML APIs for finding server status details

girishbist
Level 1
Level 1

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

2 Accepted Solutions

Accepted Solutions

HAROLD MEIER
Level 1
Level 1

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:

    

View solution in original post

Paul Wiltsey
Cisco Employee
Cisco Employee

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);

}

View solution in original post

3 Replies 3

HAROLD MEIER
Level 1
Level 1

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:

    

Paul Wiltsey
Cisco Employee
Cisco Employee

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);

}

girishbist
Level 1
Level 1

Thanks Guys ..

It worked for me ...

Review Cisco Networking products for a $25 gift card