Skip to content

load_config

nornir_scrapli.tasks.cfg_load_config

cfg_load_config(task: Task, config: str, replace: bool = False, **kwargs: Any) -> Result

Load device config with scrapli-cfg

Note that changed will still be False because this is just loading a candidate config!

Parameters:

Name Type Description Default
task Task

nornir task object

required
config str

string of the configuration to load

required
replace bool

replace the configuration or not, if false configuration will be loaded as a merge operation

False
kwargs

additional kwargs that the implementing classes may need for their platform, see your specific platform for details

required

Returns:

Name Type Description
Result Result

nornir result object with Result.result value set the string result of the load_config operation

Source code in tasks/cfg/load_config.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def cfg_load_config(task: Task, config: str, replace: bool = False, **kwargs: Any) -> Result:
    """
    Load device config with scrapli-cfg

    Note that `changed` will still be `False` because this is just loading a candidate config!

    Args:
        task: nornir task object
        config: string of the configuration to load
        replace: replace the configuration or not, if false configuration will be loaded as a
            merge operation
        kwargs: additional kwargs that the implementing classes may need for their platform,
            see your specific platform for details

    Returns:
        Result: nornir result object with Result.result value set the string result of the
            load_config operation

    Raises:
        N/A

    """
    scrapli_cfg_conn = ScrapliConfig.get_connection(task=task)

    scrapli_response = scrapli_cfg_conn.load_config(config=config, replace=replace, **kwargs)

    result = ScrapliResult(
        host=task.host,
        result=scrapli_response.result,
        scrapli_response=scrapli_response,
        changed=False,
    )

    return result