For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Get Task Status (Perl code sample)

Problem this snippet solves:

This Perl client code sample uses Enterprise Manager's device inventory to get the status for a specific task executed by the referenced Enterprise Manager.

Code :

#!/usr/bin/perl

use strict;
use SOAP::Lite;

use constant MIN_ARGS => 3;
use constant USAGE => "Management_EM_get_task_status    [] ...";
    
#
# Parse command line arguments.
#

my $num_args = $#ARGV + 1;

if ($num_args < MIN_ARGS) {
    print "Usage: ", USAGE, "\n";
    exit();
}

my $em_host = $ARGV[0];
my $em_username = $ARGV[1];
my $em_password = $ARGV[2];

my @task_id_list;

for (my $count = 3; $count < $num_args; $count++) {
    push (@task_id_list, $ARGV[$count]);
}

#
# Create SOAP proxy.
#

my $soap = SOAP::Lite
    -> uri('urn:iControl:Management/EM')
-> proxy("https://$em_username:$em_password\@$em_host/iControl/iControlPortal.cgi");

#
# Get task status values.
#

my $soap_response = $soap->get_task_status
    (
        SOAP::Data->name(ids => [@task_id_list])
    );

if ( $soap_response->fault )
{
    print $soap_response->faultcode, " ", $soap_response->faultstring, "\n";
    exit();
}

my @status_list =  @{$soap_response->result};

if ($#status_list != $#task_id_list) {
    print "Wrong number of status values returned\n";
    exit();
}

for (my $count = 0; $count < ($#task_id_list + 1); $count++) {
    print "Task $task_id_list[$count]: $status_list[$count]\n";
}


#
# Deserialize the Management.EM.TaskStatus type.
#
sub SOAP::Deserializer::typecast
{
    my ($self, $value, $name, $attrs, $children, $type) = @_; 

    my $retval = undef; 

    if ( '{urn:iControl}Management.EM.TaskStatus' == $type ) 
    { 
        $retval = $value; 
    } 

    return $retval; 
    
}
Published Mar 09, 2015
Version 1.0
No CommentsBe the first to comment