Professional Documents
Culture Documents
Automating Ip Networks With Python v2
Automating Ip Networks With Python v2
Automating Ip Networks With Python v2
with Python
Tomás Lynch
LACNOG 2019
What would you choose?
PyEZ
● Juniper
netmiko
● Arista, Cisco IOS, Juniper, MikroTik, among others
dev.open() ssh_connect=Netmiko(**device)
ssh_connect.enable()
command
ssh_connect.send_command('skip-page-display')
router_lldp = LLDPNeighborTable(dev)
lldp_neighbors = router_lldp.get() lldp_neighbors =
ssh_connect.send_command('show lldp neighbors
detail')
dis
dev.close() ssh_connect.disconnect()
10 routers 10 routers
16 worldwide locations
Edge Edge
router router
1 2
1600 network elements in Clos topology
bgpq3
remove_customer_bgp
get_bgp_summary
update_transit_config
enable_sflow_everywhere
PyEZ – juni.pr/2YSmf1g
bgpq3 – github.com/snar/bgpq3
tlynch@vultr.com
configuration,
management,
testing,
deployment, and
operations
Device
name REST Router
ASN XML Switch
IP address JSON Server
Description NETCONF Etc.
Etc.
Variables
Variables
Script
API Infrastructure
Script
{ {
'community': [{ 'community': [{
'name': { 'name': 'EXAMPLE_COMM',
'data': 'EXAMPLE_COMM' 'members': ['65536:1']
}, }]
'members': [{ }
'data': '65536:1'
}]
}]
}
try:
cli.load(command, format='set')
except (ConfigLoadError, Exception) as err:
print ("Unable to load configuration changes: {0}".format(err))
try:
cli.load(command, format='set')
except (ConfigLoadError, Exception) as err:
print ("Unable to load configuration changes: {0}".format(err))