1#!/usr/bin/env python 2from __future__ import print_function 3# import the client library 4import pyeapi 5 6# load the conf file and connect to the node 7pyeapi.load_config('nodes.conf') 8node = pyeapi.connect_to('veos01') 9 10# get the vlan api and enable autorefresh 11vlans = node.api('vlans') 12vlans.autorefresh = True 13 14if vlans.get(123): 15 print('Vlan 123 already exists, deleting it') 16 vlans.delete(1234) 17 18print('\nCreating Vlan 123') 19vlans.create(123) 20 21print('Setting Vlan 123 name to "test_vlan"') 22vlans.set_name(123, 'test_vlan') 23 24print('\nDisplaying all vlans on the node') 25print(('-'*30)) 26for vlan in list(vlans.values()): 27 print((" Vlan Id: {vlan_id}, Name: {name}".format(**vlan))) 28 29if vlans.get(123): 30 print('\nDeleting Vlan 123') 31 vlans.delete(123) 32 33print() 34 35 36