on 07-Mar-2015 15:07
Problem this snippet solves:
The script you need for this task must:
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:
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