Get Task Status (Python code sample)

Problem this snippet solves:

This Python 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/python

import sys
import pycontrol.pycontrol as pc

MIN_ARGS = 4
USAGE = "Management_EM_get_task_status  Mem_username> Mem_password> [] ..."

if len(sys.argv) < (MIN_ARGS + 1):
    print "Usage %s" % USAGE
    sys.exit()

em_address = sys.argv[1]
em_username = sys.argv[2]
em_password = sys.argv[3]

task_ids = sys.argv[4:]

ic = pc.BIGIP(
    hostname = em_address,
    username = em_username,
    password = em_password,
    fromurl = True,
    wsdls = ['Management.EM'])

statuses = ic.Management.EM.get_task_status(ids = task_ids)

if len(statuses) != len(task_ids):
    print "Wrong number of status values returned"

for i in range(len(task_ids)):
    print "Task %s: %s" % (task_ids[i], statuses[i])
Published Mar 09, 2015
Version 1.0
No CommentsBe the first to comment