Skip to content

diff_config

nornir_scrapli.tasks.cfg_diff_config

cfg_diff_config(task: Task, source: str = 'running') -> Result

Diff a device candidate config vs a source config with scrapli-cfg

The "device diff" is stored as the result. You can access the side by side or unified scrapli cfg diffs via the "scrapli_response" object stored in the result!

Parameters:

Name Type Description Default
task Task

nornir task object

required
source str

name of the config source to commit against, generally running|startup

'running'

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/diff_config.py
 7
 8
 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
def cfg_diff_config(task: Task, source: str = "running") -> Result:
    """
    Diff a device candidate config vs a source config with scrapli-cfg

    The "device diff" is stored as the result. You can access the side by side or unified scrapli
    cfg diffs via the "scrapli_response" object stored in the result!

    Args:
        task: nornir task object
        source: name of the config source to commit against, generally running|startup

    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.diff_config(source=source)

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

    return result