def demonstrate(): ''' Apply function 'inventory_static_route'. Return True if network devices are discovered. ''' print('inventory_static_route()') print(inventory_static_route())
def main(): """ Print the documentation then perform the demonstration(s). """ print(plain(doc(static_route_json))) print('Determine which devices are capable.') print('inventory_static_route()') inventory = inventory_static_route() if not inventory: print(None) print( "There are no 'static route' capable devices. Demonstration cancelled." ) else: print_table(inventory) print() for device_name in inventory: route_list = demonstrate_all(device_name) if route_list: return EX_OK if demonstrate_one(device_name, route_list[0]) else EX_TEMPFAIL else: print() 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 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 function documentation then demonstrate the function usage on a selected device. Repeat for another device if no 'static route' is configured. """ print(plain(doc(static_route_list))) print('Determine which devices are capable.') print('inventory_static_route()') device_names = inventory_static_route() if not device_names: print( "There are no 'static route' capable devices to examine. Demonstration cancelled." ) else: print_table(device_names, headers='device-name') print() for device_name in device_names: if demonstrate(device_name): return EX_OK print( "There are no devices with a 'static route' configured. Demonstration cancelled." ) return EX_TEMPFAIL
def demonstrate(): """ Apply function 'inventory_static_route' to the inventory of network devices. """ print('inventory_static_route()') device_names = inventory_static_route() print_table(device_names, headers=('device-name',)) return device_names
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 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 main(): ''' Select a device and demonstrate on potential routes, repeat until information found.''' print(plain(doc(static_route_json))) inventory = inventory_static_route() if not inventory: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in inventory: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): """ Select a device and demonstrate. If no information is found then retry with a different device.""" print(plain(doc(static_route_list))) 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: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): ''' Select a device and demonstrate, repeat until information found.''' print(plain(doc(static_route_json_all))) inventory = inventory_static_route() if not inventory: print( "There are no 'static route' capable devices to examine. Demonstration cancelled." ) else: for device_name in inventory: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): ''' Select a device and demonstrate for each potential static route prefix.''' print(plain(doc(static_route_exists))) print('inventory_static_route()') device_names = inventory_static_route() print('\t', device_names) if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): ''' Select a device and demonstrate. Retry with a different device until information is deleted.''' print(plain(doc(static_route_delete))) print('inventory_static_route()') device_names = inventory_static_route() print('\t', device_names) if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): ''' Select a capable device and demonstrate.''' print(plain(doc(static_route_create))) print('inventory_static_route()') device_names = inventory_static_route() print('\t', device_names) if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): """ Select a device and demonstrate. If no information is found then retry with a different device.""" print(plain(doc(static_route_list))) 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: if demonstrate(device_name): return os.EX_OK return os.EX_TEMPFAIL
def main(): """ Print the function's documentation then demonstrate the function multiple times on one device. """ print(plain(doc(static_route_exists))) print('Determine which devices are capable.') print('inventory_static_route()') device_names = inventory_static_route() print_table(device_names, headers='device-name') print() if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: if demonstrate(device_name): return EX_OK return EX_TEMPFAIL
def main(): """ Print the function documentation then demonstrate the function usage on a selected device. Repeat for another device if no 'static route' is configured. """ print(plain(doc(static_route_list))) print('Determine which devices are capable.') print('inventory_static_route()') device_names = inventory_static_route() if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: print_table(device_names, headers='device-name') print() for device_name in device_names: if demonstrate(device_name): return EX_OK print("There are no devices with a 'static route' configured. Demonstration cancelled.") return EX_TEMPFAIL
def main(): """ Print the function's documentation then demonstrate the function once. """ print(cleandoc(__doc__)) print() print(plain(doc(static_route_create))) print('Determine which network devices are capable.') print('inventory_static_route()') device_names = inventory_static_route() print_table(device_names, headers='device-name') print() if not device_names: print("There are no 'static route' capable devices to examine. Demonstration cancelled.") else: for device_name in device_names: if demonstrate(device_name): return EX_OK print("Unable to create a 'static route' on %s capable device(s). Demonstration cancelled." % len(device_names)) return EX_TEMPFAIL
def main(): """ Print the function's documentation then demonstrate the function multiple times on one device. """ print(plain(doc(static_route_exists))) print('Determine which devices are capable.') print('inventory_static_route()') device_names = inventory_static_route() print_table(device_names, headers='device-name') print() if not device_names: print( "There are no 'static route' capable devices to examine. Demonstration cancelled." ) else: for device_name in device_names: if demonstrate(device_name): return EX_OK return EX_TEMPFAIL
def main(): """ Print the documentation then perform the demonstration(s). """ print(plain(doc(static_route_json))) print('Determine which devices are capable.') print('inventory_static_route()') inventory = inventory_static_route() if not inventory: print(None) print("There are no 'static route' capable devices. Demonstration cancelled.") else: print_table(inventory) print() for device_name in inventory: route_list = demonstrate_all(device_name) if route_list: return EX_OK if demonstrate_one(device_name, route_list[0]) else EX_TEMPFAIL else: print() print("There are no devices with a 'static route' configured. Demonstration cancelled.") return EX_TEMPFAIL
try: run_module(script, run_name='__main__') except SystemExit as e: # Return the exit code of the script. # It indicates whether the script able to proceed. # Don't actually exit, though. return e.code # Run static_route scripts. Context: one static_route capable device. run_script('01_inventory_dismount_atomic') while run_script('04_static_route_capability') != EX_OK and run_script('01_device_connect') == EX_OK: continue run_script('04_static_route_capability') from basics.routes import inventory_static_route assert inventory_static_route(), "Expect at least one device with static route capability." # Context: no static routes while EX_OK == run_script('04_static_route_delete'): continue run_script('04_static_route_exists') assert run_script('04_static_route_json') != EX_OK run_script('04_static_route_list') run_script('04_static_route_delete') # Context: one static routes assert run_script('04_static_route_create') == EX_OK run_script('04_static_route_exists') assert run_script('04_static_route_json') == EX_OK run_script('04_static_route_list') assert run_script('04_static_route_delete') == EX_OK
run_module(script, run_name='__main__') except SystemExit as e: # Return the exit code of the script. # It indicates whether the script able to proceed. # Don't actually exit, though. return e.code # Run static_route scripts. Context: one static_route capable device. run_script('01_inventory_dismount_atomic') while run_script('04_static_route_capability') != EX_OK and run_script( '01_device_connect') == EX_OK: continue run_script('04_static_route_capability') from basics.routes import inventory_static_route assert inventory_static_route( ), "Expect at least one device with static route capability." # Context: no static routes while EX_OK == run_script('04_static_route_delete'): continue run_script('04_static_route_exists') assert run_script('04_static_route_json') != EX_OK run_script('04_static_route_list') run_script('04_static_route_delete') # Context: one static routes assert run_script('04_static_route_create') == EX_OK run_script('04_static_route_exists') assert run_script('04_static_route_json') == EX_OK run_script('04_static_route_list') assert run_script('04_static_route_delete') == EX_OK
run_module(script, run_name='__main__') except SystemExit as e: # Return the exit code of the script. # It indicates whether the script able to proceed. # Don't actually exit, though. return e.code # Run static_route scripts. Context: one static_route capable device. run_script('01_inventory_dismount_atomic') while run_script('04_inventory_static_route') != EX_OK and run_script( '01_device_connect') == EX_OK: continue run_script('04_static_route_capability') from basics.routes import inventory_static_route assert inventory_static_route() # Context: no static routes while EX_OK == run_script('04_static_route_delete'): continue run_script('04_static_route_exists') assert run_script('04_static_route_json') != EX_OK assert run_script('04_static_route_json_all') != EX_OK run_script('04_static_route_list') run_script('04_static_route_delete_all') # Context: one static routes assert run_script('04_static_route_create') == EX_OK run_script('04_static_route_exists') assert run_script('04_static_route_json') == EX_OK assert run_script('04_static_route_json_all') == EX_OK