Changing an interface configuration using NETCONF and ncclient
So far, we have learned how to retrieve or change our entire configuration. But what if we only want to modify certain aspects of our device's state? That is what we are going to cover in this recipe. As an example, we will use an OpenConfig
YANG module to create a VLAN interface. While the code is specific to this example, in the sense that we are generating XML that can be used to create a VLAN, the workflow itself is always the same:
- Generate an XML message that is formatted according to the specifications of the YANG module.
- Send the generated XML to your network device using
ncclient
and theedit_config()
method by choosing the running configuration as your target. This is similar to how we used the running configuration as our source in theget_config()
call.
Getting ready
Open your code editor and create a file called create_vlan.py
. Next, in your Terminal, navigate to the same directory...