def run(self, prefixes: List[str], labels: List[int], json_opt: bool = False): routes = [] mpls_routes = [] try: routes = self.client.getRouteTableByClient(self.client.client_id) except Exception as e: print("Failed to get routes from Fib.") print("Exception: {}".format(e)) return 1 host_id = utils.get_connected_node_name(self.cli_opts) client_id = self.client.client_id try: mpls_routes = self.client.getMplsRouteTableByClient(self.client.client_id) except platform_types.PlatformError as e: print("Pls check Open/R version. Exception: {}".format(e)) if json_opt: utils.print_json( utils.get_routes_json( host_id, client_id, routes, prefixes, mpls_routes, labels ) ) else: caption = f"{host_id}'s FIB routes by client {client_id}" utils.print_unicast_routes(caption, routes, prefixes) caption = f"{host_id}'s MPLS routes by client {client_id}" utils.print_mpls_routes(caption, mpls_routes, labels) return 0
def run( self, prefixes: List[str], labels: List[int] = (), json_opt: bool = False, client_id: Optional[int] = None, ): routes = [] mpls_routes = [] client_id = client_id if client_id is not None else self.client.client_id try: routes = self.client.getRouteTableByClient(client_id) except Exception as e: print("Failed to get routes from Fib.") print("Exception: {}".format(e)) return 1 try: mpls_routes = self.client.getMplsRouteTableByClient(client_id) except Exception: pass if json_opt: utils.print_json( utils.get_routes_json("", client_id, routes, prefixes, mpls_routes, labels)) else: caption = f"FIB routes by client {client_id}" utils.print_unicast_routes(caption, routes, prefixes) caption = f"MPLS routes by client {client_id}" utils.print_mpls_routes(caption, mpls_routes, labels) return 0
def run(self, prefixes, json_opt=False): try: routes = self.client.getRouteTableByClient(self.client.client_id) except Exception as e: print('Failed to get routes from Fib.') print('Exception: {}'.format(e)) return 1 host_id = utils.get_connected_node_name(self.client.host, self.lm_cmd_port) client_id = self.client.client_id if json_opt: utils.print_json(utils.get_routes_json( host_id, client_id, routes, prefixes)) else: caption = '{}\'s FIB routes by client {}'.format(host_id, client_id) utils.print_routes(caption, routes, prefixes) return 0
def run(self, prefixes, json_opt=False): try: routes = self.client.getRouteTableByClient(self.client.client_id) except Exception as e: print("Failed to get routes from Fib.") print("Exception: {}".format(e)) return 1 host_id = utils.get_connected_node_name(self.cli_opts) client_id = self.client.client_id if json_opt: utils.print_json( utils.get_routes_json(host_id, client_id, routes, prefixes)) else: caption = "{}'s FIB routes by client {}".format(host_id, client_id) utils.print_unicast_routes(caption, routes, prefixes) return 0
def run( self, prefixes: List[str], labels: List[int], json_opt: bool = False, client_id: Optional[int] = None, ): routes = [] mpls_routes = [] client_id = client_id if client_id is not None else self.client.client_id try: routes = self.client.getRouteTableByClient(client_id) except Exception as e: print("Failed to get routes from Fib.") print("Exception: {}".format(e)) return 1 with utils.get_openr_ctrl_client(self.cli_opts.host, self.cli_opts) as client: host_id = client.getMyNodeName() try: mpls_routes = self.client.getMplsRouteTableByClient(client_id) except Exception as e: print("Pls check Open/R version. Exception: {}".format(e)) if json_opt: utils.print_json( utils.get_routes_json(host_id, client_id, routes, prefixes, mpls_routes, labels)) else: caption = f"{host_id}'s FIB routes by client {client_id}" utils.print_unicast_routes(caption, routes, prefixes) caption = f"{host_id}'s MPLS routes by client {client_id}" utils.print_mpls_routes(caption, mpls_routes, labels) return 0