Ejemplo n.º 1
0
def read_clis(device, transformers=[convert_to_structured_commands, lambda x: x.split('\n')]):
    '''Read running-configuration from ASA device
    @param device: dict
        a device dictionary
    @param transformers: list of function that takes one argument and return an object
        the purpose of a transformer is to transform ASA configuration to a desired format.
        The order of the application of the transformer is the reverse given in the parameter,
        i.e. if the transformers is [a, b], the result will be a(b(config)).
    @return: list of CLI's
    '''
    dispatcher = HttpDispatch(device)
    messenger = dispatcher.make_read_config_messenger()
    result = messenger.read()
    if result and transformers:
        for transformer in reversed(transformers):
            result = transformer(result)
    return result
Ejemplo n.º 2
0
Archivo: util.py Proyecto: 3pings/aci
def read_clis(
        device,
        transformers=[convert_to_structured_commands,
                      lambda x: x.split('\n')]):
    '''Read running-configuration from ASA device
    @param device: dict
        a device dictionary
    @param transformers: list of function that takes one argument and return an object
        the purpose of a transformer is to transform ASA configuration to a desired format.
        The order of the application of the transformer is the reverse given in the parameter,
        i.e. if the transformers is [a, b], the result will be a(b(config)).
    @return: list of CLI's
    '''
    dispatcher = HttpDispatch(device)
    messenger = dispatcher.make_read_config_messenger()
    result = messenger.read()
    if result and transformers:
        for transformer in reversed(transformers):
            result = transformer(result)
    return result