Deleting BIG-IP devices

Problem this snippet solves:

The script you need for this task must:

  1. Identify the Enterprise Manager system on which you wish to initiate the delete devices process, specifying username and password as needed.
  2. Specify the device address(es) that you wish to delete.
  3. Initialize the API.
  4. Run the API.

How to use this snippet:

To delete 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, all associated configuration information for the specified devices (such as alerts, certificate information, and device archives) are removed from the Enterprise Manager database.

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
Published Mar 07, 2015
Version 1.0
No CommentsBe the first to comment