CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem this snippet solves:

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

Code :

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

public class ManagementEMDeleteDevices {
    
    private static int MIN_ARGS = 3;
    private static String USAGE = 
        "ManagementEMDeleteDevices    " +
        "[] ...";
    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) {
            System.err.println("Usage: " + USAGE);
            System.exit(1);
        }

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

        String[] deviceAddresses = new String[args.length - MIN_ARGS];

        for (int i = 0; i < deviceAddresses.length; i++) {
            deviceAddresses[i] = args[i + MIN_ARGS];
        }

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

            ic.getManagementEM().delete_devices(deviceAddresses);
        }
        catch (Exception e) {
            System.err.println("Failed to delete devices: " + e.getMessage());
            System.exit(1);
        }

        System.out.println("Device(s) deleted");

    } // public static void main

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