clicon / clixon-controller

Clixon network controller
Apache License 2.0
12 stars 4 forks source link

Add device / profile ignore fields #55

Closed olofhagsand closed 8 months ago

olofhagsand commented 8 months ago

Some devices rewrite some fields such as passwords on commit. Such fields therefore cannot be used when determining if a config has changed. Add the ability to add xpaths for fields in device (profile) configuration. These fields are ignored when checking if a configuration has changed on the device.

olofhagsand commented 8 months ago

Fixed by using a YANG extension to mark which fields should be ignored when comparing configs. It needs some config. First, a new yang needs to be created (or an existing be amended), example: controller-extensions.yang for the existing junos setting:

module controller-extensions {
   namespace "http://clicon.org/ext";
   prefix cl-ext;
   import openconfig-interfaces{
      prefix oc-if;
   }
   import clixon-lib{
      prefix cl;
   }
   revision 2023-11-01{
      description "Initial prototype";
   }
   augment "/oc-if:interfaces/oc-if:interface/oc-if:config/oc-if:mtu" {
      cl:ignore-compare;
   }
}

Second, this yang needs to be loaded with the mounted yangs:

<devices xmlns="http://clicon.org/controller">
      <device-profile>
          <name>junos</name>
          <module-set>
            <module>
              <name>controller-extensions</name>
              <namespace>http://clicon.org/ext</namespace>
           </module>
        </module-set>
   </device-profile>
</devices>
krihal commented 8 months ago

Tested by altering the authentication key for a BGP neighbor. Before the device became out of sync after changing the key, now it remains in sync. Path used:

   augment "/js:configuration/js:protocols/js:bgp/js:group/js:neighbor/js:authentication-key" {
      cl:ignore-compare;
   }

YANG file was put in mounts/ with the following device profile:

set devices device-profile junos
set devices device-profile junos user admin
set devices device-profile junos conn-type NETCONF_SSH
set devices device-profile junos module-set module controller-extensions
set devices device-profile junos module-set module controller-extensions namespace http://clicon.org/ext