HP P2000 G3 MSA System CLI Reference Guide
17
if ( !cLogin($ipAddr, $username, $password) == 1 )
{
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";
Содержание P2000 G3
Страница 1: ...HP P2000 G3 MSA System CLI Reference Guide Part number 500912 009 First edition February 2014 ...
Страница 14: ...14 About this guide ...
Страница 30: ...30 Categorical list of commands ...
Страница 96: ...96 Alphabetical list of commands exit Description Log off and exit the CLI session Syntax exit ...
Страница 159: ...HP P2000 G3 MSA System CLI Reference Guide 159 See also set host parameters show iscsi parameters ...
Страница 199: ...HP P2000 G3 MSA System CLI Reference Guide 199 See also set cache parameters show volumes ...
Страница 217: ...HP P2000 G3 MSA System CLI Reference Guide 217 Basetypes drives enclosure list status See also show vdisks ...
Страница 223: ...HP P2000 G3 MSA System CLI Reference Guide 223 Basetypes email parameters status See also set email parameters ...
Страница 230: ...230 Alphabetical list of commands See also clear events set snmp parameters show snmp parameters ...
Страница 288: ...288 Alphabetical list of commands Basetypes snapshots status See also show master volumes show snap pools ...
Страница 292: ...292 Alphabetical list of commands Basetypes system unhealthy component status See also set system ...
Страница 294: ...294 Alphabetical list of commands See also set volume set vdisk ...
Страница 338: ...338 Alphabetical list of commands Basetypes remote links See also show remote systems verify remote link ...
Страница 340: ...340 Alphabetical list of commands Basetypes remote links See also show remote systems verify links ...
Страница 424: ...424 XML API basetype properties PROPERTY name utility priority numeric type string 0 PROPERTY OBJECT ...
Страница 469: ...HP P2000 G3 MSA System CLI Reference Guide 469 PROPERTY name status type string OK PROPERTY OBJECT ...
Страница 494: ...494 XML API basetype properties PROPERTY name sample time numeric type string 1329397200 PROPERTY OBJECT ...
Страница 498: ...498 XML API basetype properties PROPERTY name mrc version type uint8 0 PROPERTY OBJECT ...
Страница 510: ...510 XML API basetype properties PROPERTY name reserve type numeric type string 0 PROPERTY OBJECT ...
Страница 524: ...524 Glossary ...
Страница 532: ...532 Index ...