Discover Device (Java code sample)
Problem this snippet solves:
This Java client code sample uses Enterprise Manager's device inventory to discover a list of devices managed by the referenced 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 Published Mar 08, 2015
Version 1.0CodeCentral_194
Cirrostratus
Joined May 05, 2019
CodeCentral_194
Cirrostratus
Joined May 05, 2019
No CommentsBe the first to comment