EasyManua.ls Logo

HP P2000

HP P2000
448 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
HP P2000 G3 MSA System CLI Reference Guide 17
{
print("Error: $username user failed to log in. Exiting.\n");
$telnet->close;
exit(0);
}
For scripting support, the following command can be used to access the XML API and to disable the
paging mode that pauses for each full screen of command output.
$telnet->cmd("set cli-parameters api-embed pager disabled");
The following code segment shows how to get the entire configuration information from the CLI and print
the output. The output can easily be redirected to a file for archiving.
@sV = $telnet->cmd("show configuration");
for ($i=0; $i<scalar(@sV); $i++)
{
print ("@sV[ $i ]");
}
Because basic command-line semantics provide prompts for user input and response time is indeterminate,
scripts must use an “expect”-type mechanism to scan output for prompts. It is more efficient to use the HTTP
interface to access the XML API. The following example shows how to construct a Perl script to
communicate with the XML API via HTTP.
use LWP::UserAgent;
use Digest::MD5 qw(md5_hex);
use XML::LibXML;
# generate MD5 hash using default username/password
my $md5_data = "manage_!manage";
my $md5_hash = md5_hex( $md5_data );
print "$md5_hash\n";
# create the URL and send an http GET request
$ua = LWP::UserAgent->new;
$url = 'http://10.0.0.2/api/login/' . $md5_hash;
print ("Sending to $url\n");
$req = HTTP::Request->new(GET => $url);
$res = $ua->request($req);
# Parse the XML content using LibXML to obtain the session key
print $res->content;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_string( $res->content );
my $root = $doc->getDocumentElement;
my @objects = $root->getElementsByTagName('OBJECT');
my @props = $objects[0]->getElementsByTagName('PROPERTY');
my $sessionKey;
foreach my $prop ( @props ) {
my $name = $prop->getAttribute('name');
print "Property = " . $name . "\n";
if( $name eq 'response' ) {

Table of Contents

Other manuals for HP P2000

Related product manuals