print('static_route_exists(%s, %s)' % (device_name, destination_network)) exists = static_route_exists(device_name, destination_network) print(exists) if not exists: return True else: print() 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 if __name__ == "__main__": sys_exit(main())
''' Apply function 'static_route_exists' to one or more static route destinations for the specified device.''' destination_network = static_route_fixture.sample_destination(device_name) print() print('static_route_exists(' + device_name, destination_network, sep=', ', end=')\n') print('\t', static_route_exists(device_name, destination_network)) return True 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 if __name__ == "__main__": sys_exit(main())
print_table(odl_coordinates) print() try: print('Connecting...') response = odl_http_head( # Use any URL that is likely to succeed. url_suffix='operational/opendaylight-inventory:nodes', accept='application/json', expected_status_code=[200, 404, 503]) outcome = { "status code":response.status_code, "status": 'Not found (either the URL is incorrect or the controller is starting).' if response.status_code == 404 else 'Service unavailable (allow 5 or 10 minutes for controller to become ready)' if response.status_code == 503 else 'OK' if response.status_code == 200 else 'Unknown', "method":response.request.method, "url":response.url} print_table(outcome) exit_code = EX_OK except Exception as e: exit_code = EX_CONFIG print(e, file=stderr) finally: sys_exit(exit_code)