Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env python
# import the client library
import pyeapi
# load the conf file and connect to the node
pyeapi.load_config('nodes.conf')
node = pyeapi.connect_to('veos01')
# get the vlan api and enable autorefresh
vlans = node.api('vlans')
vlans.autorefresh = True
if vlans.get(123):
print 'Vlan 123 already exists, deleting it'
vlans.delete(1234)
print '\nCreating Vlan 123'
vlans.create(123)
print 'Setting Vlan 123 name to "test_vlan"'
vlans.set_name(123, 'test_vlan')
#!/usr/bin/env python
import pyeapi
pyeapi.load_config('nodes.conf')
node = pyeapi.connect_to('veos01')
print 'Show running-config for veos01'
print '-'*30
print node.get_config('running-config')
print
print
print 'Show startup-config for veos01'
print '-'*30
print node.get_config('startup-config')
print
print
print 'Show config diffs'
print '-'*30
#!/usr/bin/env python
import pyeapi
pyeapi.load_config('nodes.conf')
node = pyeapi.connect_to('veos01')
output = node.enable('show version')
print 'My System MAC address is', output[0]['result']['systemMacAddress']
#!/usr/bin/env python
import pyeapi
pyeapi.load_config('nodes.conf')
node = pyeapi.connect_to('veos01')
output = node.enable('show version')
print 'My System MAC address is', output[0]['systemMacAddress']