Execute an arbitrary RPC request via the Nexus API.

    commands
        The commands to be executed.

    method: ``cli``
        The type of the response, i.e., raw text (``cli_ascii``) or structured
        document (``cli``). Defaults to ``cli`` (structured data).

    transport: ``https``
        Specifies the type of connection transport to use. Valid values for the
        connection are ``http``, and  ``https``.

    host: ``localhost``
        The IP address or DNS host name of the connection device.

    username: ``admin``
        The username to pass to the device to authenticate the NX-API connection.

    password
        The password to pass to the device to authenticate the NX-API connection.

    port
        The TCP port of the endpoint for the NX-API connection. If this keyword is
        not specified, the default value is automatically determined by the
        transport type (``80`` for ``http``, or ``443`` for ``https``).

    timeout: ``60``
        Time in seconds to wait for the device to respond. Default: 60 seconds.

    verify: ``True``
        Either a boolean, in which case it controls whether we verify the NX-API
        TLS certificate, or a string, in which case it must be a path to a CA bundle
        to use. Defaults to ``True``.

def rpc(commands,
        method='cli',
        **kwargs):
    '''
    Execute an arbitrary RPC request via the Nexus API.

    commands
        The commands to be executed.

    method: ``cli``
        The type of the response, i.e., raw text (``cli_ascii``) or structured
        document (``cli``). Defaults to ``cli`` (structured data).

    transport: ``https``
        Specifies the type of connection transport to use. Valid values for the
        connection are ``http``, and  ``https``.

    host: ``localhost``
        The IP address or DNS host name of the connection device.

    username: ``admin``
        The username to pass to the device to authenticate the NX-API connection.

    password
        The password to pass to the device to authenticate the NX-API connection.

    port
        The TCP port of the endpoint for the NX-API connection. If this keyword is
        not specified, the default value is automatically determined by the
        transport type (``80`` for ``http``, or ``443`` for ``https``).

    timeout: ``60``
        Time in seconds to wait for the device to respond. Default: 60 seconds.

    verify: ``True``
        Either a boolean, in which case it controls whether we verify the NX-API
        TLS certificate, or a string, in which case it must be a path to a CA bundle
        to use. Defaults to ``True``.
    '''
    init_args = _prepare_connection(**kwargs)
    log.error('These are the init args:')
    log.error(init_args)
    url = '{transport}://{host}:{port}/ins'.format(
        transport=init_args['transport'],
        host=init_args['host'],
        port=init_args['port']
    )
    headers = {
        'content-type': 'application/json-rpc'
    }
    payload = []
    if not isinstance(commands, (list, tuple)):
        commands = [commands]
    for index, command in enumerate(commands):
        payload.append({
            'jsonrpc': init_args['rpc_version'],
            'method': method,
            'params': {
                'cmd': command,
                'version': 1
            },
            'id': index + 1
        })
    opts = {
        'http_request_timeout': init_args['timeout']
    }
    response = salt.utils.http.query(url,
                                     method='POST',
                                     opts=opts,
                                     data=json.dumps(payload),
                                     header_dict=headers,
                                     decode=True,
                                     decode_type='json',
                                     **init_args)
    if 'error' in response:
        raise SaltException(response['error'])
    response_list = response['dict']
    if isinstance(response_list, dict):
        response_list = [response_list]
    for index, command in enumerate(commands):
        response_list[index]['command'] = command
    return response_list