Skip to content

Commit

Permalink
New examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mpergament committed Dec 9, 2020
1 parent d460c23 commit ef2e620
Show file tree
Hide file tree
Showing 4 changed files with 353 additions and 0 deletions.
26 changes: 26 additions & 0 deletions INTF_L2/nc-del-l2if.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from ncclient import manager

eos=manager.connect(host="hostname", port="22", timeout=30, username="admin", password="", hostkey_verify=False)

ethernet_trunk = '''
<config>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Ethernet3/1</name>
<config>
<name>Ethernet3/1</name>
</config>
<ethernet xmlns="http://openconfig.net/yang/interfaces/ethernet">
<switched-vlan xmlns="http://openconfig.net/yang/vlan"
nc:operation="delete">
</switched-vlan>
</ethernet>
</interface>
</interfaces>
</config>
'''

configuration = eos.edit_config(target="running", config=ethernet_trunk, default_operation="merge")
print(configuration)

eos.close_session()
30 changes: 30 additions & 0 deletions INTF_L3/nc-del-if.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ncclient import manager

eos=manager.connect(host="hostname", port="22", timeout=30, username="admin", password="", hostkey_verify=False)

config = """
<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Ethernet4/1</name>
<subinterfaces>
<subinterface>
<index>0</index>
<ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
<addresses>
<address nc:operation="delete">
<ip>172.168.14.2</ip>
</address>
</addresses>
</ipv4>
</subinterface>
</subinterfaces>
</interface>
</interfaces>
</config>
"""

configuration = eos.edit_config(target="running", config=config, default_operation="none")
print(configuration)

eos.close_session()
55 changes: 55 additions & 0 deletions ISIS/nc-del-isis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from ncclient import manager

eos=manager.connect(host="hostname", port="22", timeout=30, username="admin", password="", hostkey_verify=False)

isis = """
<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<network-instances xmlns="http://openconfig.net/yang/network-instance"
xmlns:oc-pol-types="http://openconfig.net/yang/policy-types"
xmlns:oc-isis-types="http://openconfig.net/yang/isis-types"
>
<network-instance>
<name>
default
</name>
<protocols>
<protocol>
<identifier>
oc-pol-types:ISIS
</identifier>
<name>
SUPERCORE
</name>
<config>
<identifier>
oc-pol-types:ISIS
</identifier>
<name>
SUPERCORE
</name>
</config>
<isis>
<interfaces>
<interface nc:operation="delete">
<interface-id>
Ethernet4/1
</interface-id>
<config>
<interface-id>
Ethernet4/1
</interface-id>
</config>
</interface>
</interfaces>
</isis>
</protocol>
</protocols>
</network-instance>
</network-instances>
</config>
"""

configuration = eos.edit_config(target="running", config=isis, default_operation="none")
print(configuration)

eos.close_session()
242 changes: 242 additions & 0 deletions ISIS/nc-isis-add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
from ncclient import manager
eos=manager.connect(host="hostname", port="22", timeout=30, username="admin", password="", hostkey_verify=False)

isis = """
<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<network-instances xmlns="http://openconfig.net/yang/network-instance"
xmlns:oc-pol-types="http://openconfig.net/yang/policy-types"
xmlns:oc-isis-types="http://openconfig.net/yang/isis-types"
>
<network-instance>
<name>
default
</name>
<protocols>
<protocol>
<identifier>
oc-pol-types:ISIS
</identifier>
<name>
SUPERCORE
</name>
<config>
<enabled>
true
</enabled>
<identifier>
oc-pol-types:ISIS
</identifier>
<name>
SUPERCORE
</name>
</config>
<isis>
<interfaces>
<interface>
<interface-id>
Ethernet4/1
</interface-id>
<config>
<circuit-type>
POINT_TO_POINT
</circuit-type>
<enabled>
true
</enabled>
<hello-padding>
STRICT
</hello-padding>
<interface-id>
Ethernet4/1
</interface-id>
<passive>
false
</passive>
</config>
<interface-ref>
<config>
<interface>
Ethernet4/1
</interface>
</config>
</interface-ref>
<levels>
<level>
<level-number>
1
</level-number>
<afi-safi>
<af>
<afi-name>
oc-isis-types:IPV4
</afi-name>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
<config>
<afi-name>
oc-isis-types:IPV4
</afi-name>
<metric>
10
</metric>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
</config>
</af>
<af>
<afi-name>
oc-isis-types:IPV6
</afi-name>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
<config>
<afi-name>
oc-isis-types:IPV6
</afi-name>
<metric>
GLOBAL_METRIC
</metric>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
</config>
</af>
</afi-safi>
<config>
<enabled>
false
</enabled>
<level-number>
1
</level-number>
<priority>
64
</priority>
</config>
<hello-authentication>
<config>
<hello-authentication>
false
</hello-authentication>
</config>
<key>
<config/>
</key>
</hello-authentication>
<packet-counters>
<csnp/>
<iih/>
<lsp/>
<psnp/>
</packet-counters>
<timers>
<config>
<hello-interval>
10
</hello-interval>
<hello-multiplier>
3
</hello-multiplier>
</config>
</timers>
</level>
<level>
<level-number>
2
</level-number>
<afi-safi>
<af>
<afi-name>
oc-isis-types:IPV4
</afi-name>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
<config>
<afi-name>
oc-isis-types:IPV4
</afi-name>
<metric>
10
</metric>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
</config>
</af>
<af>
<afi-name>
oc-isis-types:IPV6
</afi-name>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
<config>
<afi-name>
oc-isis-types:IPV6
</afi-name>
<metric>
GLOBAL_METRIC
</metric>
<safi-name>
oc-isis-types:UNICAST
</safi-name>
</config>
</af>
</afi-safi>
<config>
<enabled>
true
</enabled>
<level-number>
2
</level-number>
<priority>
64
</priority>
</config>
<hello-authentication>
<config>
<hello-authentication>
false
</hello-authentication>
</config>
<key>
<config/>
</key>
</hello-authentication>
<packet-counters>
<csnp/>
<iih/>
<lsp/>
<psnp/>
</packet-counters>
<timers>
<config>
<hello-interval>
10
</hello-interval>
<hello-multiplier>
3
</hello-multiplier>
</config>
</timers>
</level>
</levels>
</interface>
</interfaces>
</isis>
</protocol>
</protocols>
</network-instance>
</network-instances>
</config>
"""

configuration = eos.edit_config(target = "running", config = isis, default_operation="merge")
print(configuration)

eos.close_session()

0 comments on commit ef2e620

Please sign in to comment.