def _cli_command(commands,
                 method='cli',
                 **kwargs):
    '''
    Execute a list of CLI commands.
    '''
    if not isinstance(commands, (list, tuple)):
        commands = [commands]
    rpc_responses = rpc(commands,
                        method=method,
                        **kwargs)
    txt_responses = []
    for rpc_reponse in rpc_responses:
        error = rpc_reponse.get('error')
        if error:
            cmd = rpc_reponse.get('command')
            if 'data' in error:
                msg = 'The command "{cmd}" raised the error "{err}".'.format(cmd=cmd, err=error['data']['msg'])
                raise SaltException(msg)
            else:
                msg = 'Invalid command: "{cmd}".'.format(cmd=cmd)
                raise SaltException(msg)
        txt_responses.append(rpc_reponse['result'])
    return txt_responses
def _cli_command ( commands , method = 'cli' , ** kwargs ) : if not isinstance ( commands , ( list , tuple ) ) : commands = [ commands ] rpc_responses = rpc ( commands , method = method , ** kwargs ) txt_responses = [ ] for rpc_reponse in rpc_responses : error = rpc_reponse . get ( 'error' ) if error : cmd = rpc_reponse . get ( 'command' ) if 'data' in error : msg = 'The command "{cmd}" raised the error "{err}".' . format ( cmd = cmd , err = error [ 'data' ] [ 'msg' ] ) raise SaltException ( msg ) else : msg = 'Invalid command: "{cmd}".' . format ( cmd = cmd ) raise SaltException ( msg ) txt_responses . append ( rpc_reponse [ 'result' ] ) return txt_responses
Execute a list of CLI commands.