on 07-Mar-2015 16:35
Problem this snippet solves:
This Perl client code sample uses Enterprise Manager's device inventory to discover a list of devices managed by the referenced Enterprise Manager.
Code :
#!/usr/bin/perl use strict; use SOAP::Lite; use constant MIN_ARGS => 3; use constant NUM_DEVICE_ARGS => 3; use constant USAGE => "Management_EM_discover_devices [] ..."; # # Parse command line arguments. # my $num_args = $#ARGV + 1; if (($num_args < MIN_ARGS) || ((($num_args - MIN_ARGS) % NUM_DEVICE_ARGS) != 0)) { print "Usage: ", USAGE, "\n"; exit(); } my $em_host = $ARGV[0]; my $em_username = $ARGV[1]; my $em_password = $ARGV[2]; my $num_devices = ($num_args - MIN_ARGS) / NUM_DEVICE_ARGS; my @device_address_list; my @device_username_list; my @device_password_list; for (my $i = 0; $i < $num_devices; $i++) { my $offset = MIN_ARGS + ($i * NUM_DEVICE_ARGS); push (@device_address_list, $ARGV[$offset]); push (@device_username_list, $ARGV[$offset + 1]); push (@device_password_list, $ARGV[$offset + 2]); } # # Create SOAP proxy. # my $soap = SOAP::Lite -> uri('urn:iControl:Management/EM') -> proxy("https://$em_username:$em_password\@$em_host/iControl/iControlPortal.cgi"); # # Start the device discovery. # my $soap_response = $soap->discover_devices ( SOAP::Data->name(addresses => [@device_address_list]), SOAP::Data->name(usernames => [@device_username_list]), SOAP::Data->name(passwords => [@device_password_list]) ); if ( $soap_response->fault ) { print $soap_response->faultcode, " ", $soap_response->faultstring, "\n"; exit(); } my $task_id = $soap_response->result; print "Discovery task started with task ID: $task_id\n";