cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Problem this snippet solves:

The script you need for this task must:

  1. Identify the Enterprise Manager system on which you want to initiate the device discovery process, specifying username and password as needed.
  2. Initialize the API.
  3. Run the API.

Important: Although you can use this API to discover devices using either the TMM or the management interface, you must discover devices through an internal traffic interface (TMM) if you want to use the iControl Proxy to send messages to managed devices.

How to use this snippet:

To discover devices:

  1. Create a script similar to the code sample shown below.
  2. From a command prompt, run your script.
  3. When the code finishes running, a list of discovered BIG-IP devices is added to the user interface on Enterprise Manager.

Code :

/**
 * A class for testing the Management::EM::discover_devices iControl interface.
 */

public class ManagementEMDiscoverDevices {
    
    private static int MIN_ARGS = 3;
    private static int NUM_DEVICE_ARGS = 3;
    private static String USAGE = 
        "ManagementEMDiscoverDevices    " +
        "[  ] ...";
    private static int EM_PORT = 443;


    /**
     * The main method.
     *
     * @param args command line arguments
     */

    public static void main(String[] args) {

        if ((args.length < MIN_ARGS) ||
            (((args.length - MIN_ARGS) % NUM_DEVICE_ARGS) != 0)) {
            System.err.println("Usage: " + USAGE);
            System.exit(1);
        }

        String emAddress = args[0];
        String emUsername = args[1];
        String emPassword = args[2];

        int numDevices = (args.length - MIN_ARGS) / NUM_DEVICE_ARGS;

        String[] deviceAddresses = new String[numDevices];
        String[] deviceUsernames = new String[numDevices];
        String[] devicePasswords = new String[numDevices];


        for (int i = 0; i < deviceAddresses.length; i++) {
            int index = MIN_ARGS + (i * NUM_DEVICE_ARGS);

            deviceAddresses[i] = args[index];
            deviceUsernames[i] = args[index + 1];
            devicePasswords[i] = args[index + 2];
        }

        String taskId = null;

        try {
            iControl.Interfaces ic = new iControl.Interfaces();
            ic.initialize(emAddress, EM_PORT, emUsername, emPassword);

            taskId = ic.getManagementEM().discover_devices(deviceAddresses,
                                                           deviceUsernames,
                                                           devicePasswords);
        }
        catch (Exception e) {
            System.err.println("Failed to discover devices: " + e.getMessage());
            System.exit(1);
        }

        System.out.println("Discovery task started with task ID: " + taskId);

    } // public static void main

} // public class ManagementEMDiscoverDevices
Version history
Last update:
‎07-Mar-2015 15:07
Updated by:
Contributors