Execute operational mode command(s).

    This function will send operational mode commands to a Junos
    device. jaide.utils.clean_lines() is used to determine how we are
    receiving commands, and ignore comment lines or blank lines in
    a command file.

    @param ctx: The click context paramter, for receiving the object dictionary
              | being manipulated by other previous functions. Needed by any
              | function with the @click.pass_context decorator.
    @type ctx: click.Context
    @param commands: The op commands to send to the device. Can be one of
                   | four things:
                   |    1. A single op command as a string.
                   |    2. A string of comma separated op commands.
                   |    3. A python list of op commands.
                   |    4. A filepath of a file with op commands on each
                   |         line.
    @type commands: str
    @param format: String specifying what format to request for the
                 | response from the device. Defaults to 'text', but
                 | also accepts 'xml'.
    @type format: str
    @param xpath: An xpath expression on which we should filter the results.
                | This enforces 'xml' for the format of the response.
    @type xpath: str

    @returns: None. Functions part of click relating to the command group
            | 'main' do not return anything. Click handles passing context
            | between the functions and maintaing command order and chaining.

def operational(ctx, commands, format, xpath):
    """ Execute operational mode command(s).

    This function will send operational mode commands to a Junos
    device. jaide.utils.clean_lines() is used to determine how we are
    receiving commands, and ignore comment lines or blank lines in
    a command file.

    @param ctx: The click context paramter, for receiving the object dictionary
              | being manipulated by other previous functions. Needed by any
              | function with the @click.pass_context decorator.
    @type ctx: click.Context
    @param commands: The op commands to send to the device. Can be one of
                   | four things:
                   |    1. A single op command as a string.
                   |    2. A string of comma separated op commands.
                   |    3. A python list of op commands.
                   |    4. A filepath of a file with op commands on each
                   |         line.
    @type commands: str
    @param format: String specifying what format to request for the
                 | response from the device. Defaults to 'text', but
                 | also accepts 'xml'.
    @type format: str
    @param xpath: An xpath expression on which we should filter the results.
                | This enforces 'xml' for the format of the response.
    @type xpath: str

    @returns: None. Functions part of click relating to the command group
            | 'main' do not return anything. Click handles passing context
            | between the functions and maintaing command order and chaining.
    """
    mp_pool = multiprocessing.Pool(multiprocessing.cpu_count() * 2)
    for ip in ctx.obj['hosts']:
        mp_pool.apply_async(wrap.open_connection, args=(ip,
                            ctx.obj['conn']['username'],
                            ctx.obj['conn']['password'],
                            wrap.command, [commands, format, xpath],
                            ctx.obj['out'],
                            ctx.obj['conn']['connect_timeout'],
                            ctx.obj['conn']['session_timeout'],
                            ctx.obj['conn']['port']), callback=write_out)
    mp_pool.close()
    mp_pool.join()