11-15-2010 05:13 AM - edited 03-01-2019 09:44 AM
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
Solved! Go to Solution.
11-15-2010 07:36 AM
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:
11-15-2010 10:04 AM
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);
}
11-15-2010 07:36 AM
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:
11-15-2010 10:04 AM
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);
}
11-18-2010 09:47 PM
Thanks Guys ..
It worked for me ...
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide