cancel
Showing results for 
Search instead for 
Did you mean: 

Problem this snippet solves:

This Python client code sample uses Enterprise Manager's device inventory to discover a list of devices managed by the referenced Enterprise Manager.

Code :

#!/usr/bin/python

import sys
import pycontrol.pycontrol as pc

MIN_ARGS = 4
NUM_DEVICE_ARGS = 3
USAGE = "Management_EM_discovery_devices    [  ] ..."

if (len(sys.argv) < (MIN_ARGS + NUM_DEVICE_ARGS)) or (((len(sys.argv) - MIN_ARGS) % NUM_DEVICE_ARGS) != 0):
    print "Usage: %s" % USAGE
    sys.exit()

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

num_devices = (len(sys.argv) - MIN_ARGS) / NUM_DEVICE_ARGS

device_addresses = []
device_usernames = []
device_passwords = []

for i in range(num_devices):
    index = MIN_ARGS + (i * NUM_DEVICE_ARGS)
    device_addresses.append(sys.argv[index])
    device_usernames.append(sys.argv[index + 1])
    device_passwords.append(sys.argv[index + 2])

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

task_id = ic.Management.EM.discover_devices(addresses = device_addresses,
                                            usernames = device_usernames,
                                            passwords = device_passwords)

print "Discovery task started with task ID: %s"% task_id
Version history
Last update:
‎09-Mar-2015 13:26
Updated by:
Contributors