def main(): """ Print the documentation then perform the demonstration(s). """ print(plain(doc(static_route_delete))) print('Determine which devices are capable.') print('inventory_static_route()') inventory = inventory_static_route() print_table(inventory, headers='device-name') if not inventory: print( "There are no 'static route' capable devices. Demonstration cancelled." ) else: print() for device_name in inventory: print('static_route_list(%s)' % device_name) route_list = static_route_list(device_name) print_table(route_list, headers='destination-network') print() if route_list: demonstrate_one(device_name, route_list[0]) if len(route_list) > 1: demonstrate_all(device_name) return EX_OK print( "There are no devices with a 'static route' configured. Demonstration cancelled." ) return EX_TEMPFAIL
def main(): """ Print the documentation then perform the demonstration(s). """ print(plain(doc(static_route_delete))) print('Determine which devices are capable.') print('inventory_static_route()') inventory = inventory_static_route() print_table(inventory, headers='device-name') if not inventory: print("There are no 'static route' capable devices. Demonstration cancelled.") else: print() for device_name in inventory: print('static_route_list(%s)' % device_name) route_list = static_route_list(device_name) print_table(route_list, headers='destination-network') print() if route_list: demonstrate_one(device_name, route_list[0]) if len(route_list) > 1: demonstrate_all(device_name) return EX_OK print("There are no devices with a 'static route' configured. Demonstration cancelled.") return EX_TEMPFAIL
def demonstrate(device_name): ''' Apply function 'static_route_list' to the specified device. Return True when one or more routes are found. ''' print('static_route_list(' + device_name, end=')\n') routes = static_route_list(device_name) print('\t', [str(route) for route in routes]) return bool(routes)
def showstaticroute(): device_names = inventory_static_route() if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: print('static_route_list(' + device_name, end=')\n') routes = static_route_list(device_name) print('\t', [str(route) for route in routes])
def demonstrate_one(device_name, destination_network): """ Apply function 'static_route_delete' to the specified device and destination. """ print('static_route_delete(%s, %s)' % (device_name, destination_network)) static_route_delete(device_name, destination_network) print() print('static_route_list(%s)' % device_name) print_table(static_route_list(device_name), headers='destination-network')
def demonstrate_all(device_name): """ Apply function 'static_route_delete' to all routes on the specified device. """ print() print('static_route_delete(%s)' % device_name) static_route_delete(device_name) print() print('static_route_list(%s)' % device_name) print_table(static_route_list(device_name), headers='destination-network')
def demonstrate(device_name): """ Apply function 'static_route_list' to the specified device. Return True when one or more routes are found. """ print('static_route_list(%s)' % device_name) routes = static_route_list(device_name) print_table(routes, headers='destination-network') print() return bool(routes)
def showstaticroute(): device_names = inventory_static_route() if not device_names: print( "There are no 'static route' capable devices to examine. Demonstration cancelled." ) else: for device_name in device_names: print('static_route_list(' + device_name, end=')\n') routes = static_route_list(device_name) print('\t', [str(route) for route in routes])
def demonstrate(device_name): ''' Apply function 'static_route_delete' to any route of the specified device.''' print() print('static_route_list(' + device_name, sep=', ', end=')\n') route_list=static_route_list(device_name) print('\t', [str(route) for route in route_list]) for destination_network in route_list: print() print('static_route_delete(' + device_name, destination_network, sep=', ', end=')\n') static_route_delete(device_name, destination_network) return True return False
def demonstrate(device_name): ''' Apply function 'static_route_delete' to any route of the specified device.''' print() print('static_route_list(' + device_name, sep=', ', end=')\n') route_list = static_route_list(device_name) print('\t', [str(route) for route in route_list]) for destination_network in route_list: print() print('static_route_delete(' + device_name, destination_network, sep=', ', end=')\n') static_route_delete(device_name, destination_network) return True return False
def demonstrate(device_name): """ Apply function 'static_route_delete' to the specified device. Return True if one or more static routes are deleted. """ print() print('static_route_list(%s)' % device_name) route_list = static_route_list(device_name) if not route_list: print('\t', None) else: print('\t', [str(route) for route in route_list]) for destination_network in route_list: print() print('static_route_delete(' + device_name, destination_network, sep=', ', end=')\n') static_route_delete(device_name, destination_network) return bool(route_list)
def main(): device_list = settings.config['network_device'] connected_list = topology.connected_nodes() if len(connected_list) != len(device_list): print('not all devices are connected!') return device_1 = 'iosxrv-1' device_2 = 'iosxrv-2' device_3 = 'iosxrv-3' device_4 = 'iosxrv-4' device_5 = 'iosxrv-5' device_6 = 'iosxrv-6' device_7 = 'iosxrv-7' device_8 = 'iosxrv-8' interface_0 = 'GigabitEthernet0/0/0/0' interface_1 = 'GigabitEthernet0/0/0/1' interface_2 = 'GigabitEthernet0/0/0/2' interface_3 = 'GigabitEthernet0/0/0/3' interface_4 = 'GigabitEthernet0/0/0/4' interface_5 = 'GigabitEthernet0/0/0/5' interface_6 = 'GigabitEthernet0/0/0/6' #add static route for flow 1 destination_network = to_ip_network('100.0.0.0', '24') #device_1 next_hop_address = '10.0.12.2' discription = 'for flow 1: to device_2' add_static_route(device_1, destination_network, next_hop_address, discription, 0) #device_2 next_hop_address = '198.18.1.34' discription = 'for flow 1: to device_5' add_static_route(device_2, destination_network, next_hop_address, discription, 0) #device_8 next_hop_address = '10.0.28.2' discription = 'for flow 1: to device_2' add_static_route(device_8, destination_network, next_hop_address, discription, 0) #display print('add route for flow 1 (to 100.0.0.0/24): ', device_8, ' -> ', device_2) #add static route for flow 2 destination_network = to_ip_network('200.0.0.0', '24') #device_1 next_hop_address = '10.0.12.2' discription = 'for flow 2: to device_2' add_static_route(device_1, destination_network, next_hop_address, discription, 0) #device_2 next_hop_address = '198.18.1.34' discription = 'for flow 2: to device_5' add_static_route(device_2, destination_network, next_hop_address, discription, 0) #device_8 next_hop_address = '10.0.18.1' discription = 'for flow 2: to device_1' add_static_route(device_8, destination_network, next_hop_address, discription, 0) #display print('add route for flow 2 (to 200.0.0.0/24): ', device_8, ' -> ', device_1, ' -> ', device_2) #add static route for flow 3 destination_network = to_ip_network('50.0.0.0', '24') next_hop_address = '198.18.1.32' discription = 'for flow 3: to device_3' add_static_route(device_8, destination_network, next_hop_address, discription, 0) #display print('add route for flow 3 (to 50.0.0.0/24): ', device_8, ' -> black_hole') #display static route print('\n') routes = static_route_list(device_8) print('static route table', device_8) print_table(routes)
def test_route_delete(router_lists_delete): for router_list in router_lists_delete: route_list_all = static_route_list(router_list[0]) print(route_list_all) return static_route_delete(router_list[0], router_list[1], router_list[2])
def main(): device_list=settings.config['network_device'] connected_list = topology.connected_nodes() if len(connected_list) != len(device_list): print('not all devices are connected!') return device_1 = 'iosxrv-1' device_2 = 'iosxrv-2' device_3 = 'iosxrv-3' device_4 = 'iosxrv-4' device_5 = 'iosxrv-5' device_6 = 'iosxrv-6' device_7 = 'iosxrv-7' device_8 = 'iosxrv-8' interface_0 = 'GigabitEthernet0/0/0/0' interface_1 = 'GigabitEthernet0/0/0/1' interface_2 = 'GigabitEthernet0/0/0/2' interface_3 = 'GigabitEthernet0/0/0/3' interface_4 = 'GigabitEthernet0/0/0/4' interface_5 = 'GigabitEthernet0/0/0/5' interface_6 = 'GigabitEthernet0/0/0/6' #add static route for flow 1 destination_network = to_ip_network('100.0.0.0', '24') #device_1 next_hop_address = '10.0.12.2' add_static_route(device_1, destination_network, next_hop_address, 0) #device_2 next_hop_address = '198.18.1.34' add_static_route(device_2, destination_network, next_hop_address, 0) #device_8 next_hop_address = '10.0.28.2' add_static_route(device_8, destination_network, next_hop_address, 0) #display print('add route for flow 1 (to 100.0.0.0/24): ', device_8, ' -> ', device_2) #add static route for flow 2 destination_network = to_ip_network('200.0.0.0', '24') #device_1 next_hop_address = '10.0.12.2' add_static_route(device_1, destination_network, next_hop_address, 0) #device_2 next_hop_address = '198.18.1.34' add_static_route(device_2, destination_network, next_hop_address, 0) #device_8 next_hop_address = '10.0.18.1' add_static_route(device_8, destination_network, next_hop_address, 0) #display print('add route for flow 2 (to 200.0.0.0/24): ', device_8, ' -> ', device_1, ' -> ', device_2) #add static route for flow 3 destination_network = to_ip_network('50.0.0.0', '24') next_hop_address = '198.18.1.32' add_static_route(device_8, destination_network, next_hop_address, 0) #display print('add route for flow 3 (to 50.0.0.0/24): ', device_8, ' -> black_hole') #display static route print('\n') routes = static_route_list(device_8) print('static route table', device_8) print_table(routes)