Get commands that are actually send to router

Hi there,

I’m still getting familiar with nornir and found it quite usefull and easy so far. I am using nornir together with napalm to connect to our IOS-XE and IOS-XR hosts via ssh.

Currently I’m building a script that shows the difference between the current interface config and a new ‘target’ interface configuration. I know, nothing fancy. This target interface configuration is the output from another python tool we are already using. I’ve build the new interface configuration via the task template_string and deploy this new configuration via napalm_configure and DryFlag=True on the device. If I do a print_result the script gives me the difference between old and new configuration as a diff with “+” and “-”.
But I’m more interested in the actual commands that are required to go from old_config to new_config if I would do this configuration change via cli.

Example:
[old config present on device]
interface Gi0/10/6
ip address 10.0.0.1 255.255.255.252

[new target config]
interface Gi0/10/6
service instance 999 ethernet
[… other settings ommitted…]

Expected output are the actual commands deployed on router:
interface Gi0/10/6
no ip address (*)
service instance 999 ethernet
[… other settings ommitted…]

(*) required command as a configuring of a service instance does not allow the configuration of an ip address on the interface

Is there an option in nornir (or napalm or netmiko) to actually do this? I guess nornir or napalm somehow already should do this in the background. But I could not find an option to access this.

napalm dry_run can do the same for you. It would show you the difference between existing and proposed config.
here is the output. Technically it did not change anything, it just tells you what would have been changed in case you run the script.

napalm_configure****************************************************************
* S1 ** changed : True *********************************************************
vvvv napalm_configure ** changed : True vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
@@ -207,6 +207,10 @@
 interface Ethernet54/3
 !
 interface Ethernet54/4
+!
+interface Loopback123
+   description nornir was here!
+   ip address 3.2.3.5/32
 !
 interface Management1
    vrf MGMT
^^^^ END napalm_configure ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^