Class CLI


  • public class CLI
    extends Object
    This class is intended to be used with JVM-based scripting languages. It acts as a facade to the CLI public API, providing a single class that can be used to connect, run CLI commands, and disconnect. It also removes the need to catch checked exceptions.
    Author:
    Stan Silvert ssilvert@redhat.com (C) 2012 Red Hat Inc.
    • Method Detail

      • newInstance

        public static CLI newInstance()
        Create a new CLI instance.
        Returns:
        The CLI instance.
      • getCommandContext

        public CommandContext getCommandContext()
        Return the CLI CommandContext. This allows a script developer full access to CLI facilities if needed. CommandContext can mute during CLI lifetime. An unconnected CLI instance has a context that handles offline commands. When connected to a server, the original context is replaced with a context allowing to interact with the remote server.
        Returns:
        The CommandContext.
      • connect

        public void connect()
        Connect to the server using the default host and port.
      • connect

        public void connect​(String username,
                            char[] password)
        Connect to the server using the default host and port.
        Parameters:
        username - The user name for logging in.
        password - The password for logging in.
      • connect

        public void connect​(String controller,
                            String username,
                            char[] password)
        Connect to the server using a specified host and port.
        Parameters:
        controllerHost - The host name.
        controllerPort - The port.
        username - The user name for logging in.
        password - The password for logging in.
      • connect

        public void connect​(String controller,
                            String username,
                            char[] password,
                            String clientBindAddress)
        Connect to the server using a specified host and port.
        Parameters:
        controller -
        username - The user name for logging in.
        clientBindAddress -
        password - The password for logging in.
      • connect

        public void connect​(String controllerHost,
                            int controllerPort,
                            String username,
                            char[] password)
        Connect to the server using a specified host and port.
        Parameters:
        controllerHost - The host name.
        controllerPort - The port.
        username - The user name for logging in.
        password - The password for logging in.
      • connect

        public void connect​(String controllerHost,
                            int controllerPort,
                            String username,
                            char[] password,
                            String clientBindAddress)
        Connect to the server using a specified host and port.
        Parameters:
        controllerHost - The host name.
        controllerPort - The port.
        username - The user name for logging in.
        password - The password for logging in.
        clientBindAddress - the client bind address.
      • connect

        public void connect​(String protocol,
                            String controllerHost,
                            int controllerPort,
                            String username,
                            char[] password)
        Connect to the server using a specified host and port.
        Parameters:
        protocol - The protocol
        controllerHost - The host name.
        controllerPort - The port.
        username - The user name for logging in.
        password - The password for logging in.
      • connect

        public void connect​(String protocol,
                            String controllerHost,
                            int controllerPort,
                            String username,
                            char[] password,
                            String clientBindAddress)
        Connect to the server using a specified host and port.
        Parameters:
        protocol - The protocol
        controllerHost - The host name.
        controllerPort - The port.
        username - The user name for logging in.
        password - The password for logging in.
      • disconnect

        public void disconnect()
        Disconnect from the server. The current CommandContext is terminated.
      • cmd

        public CLI.Result cmd​(String cliCommand)
        Execute a CLI command. This can be any command that you might execute on the CLI command line, including both server-side operations and local commands such as 'cd' or 'cn'.
        Parameters:
        cliCommand - A CLI command.
        Returns:
        A result object that provides all information about the execution of the command.
      • terminate

        public void terminate()
        Terminate the current CommandContext.