Exemple #1
0
 def run(self, prefixes, json):
     route_db = self.client.get_route_db()
     if json:
         route_db_dict = {route_db.thisNodeName: utils.route_db_to_dict(route_db)}
         utils.print_routes_json(route_db_dict, prefixes)
     else:
         utils.print_routes_table(route_db, prefixes)
Exemple #2
0
 def _run(
     self, client: OpenrCtrl.Client, prefixes: Any, labels: Any, json: bool
 ) -> None:
     route_db = client.getRouteDbUnInstallable()
     if json:
         route_db_dict = {route_db.thisNodeName: utils.route_db_to_dict(route_db)}
         utils.print_routes_json(route_db_dict, prefixes, labels)
     else:
         utils.print_route_db(route_db, prefixes, labels)
Exemple #3
0
 def run(self, nodes, json):
     if 'all' in nodes:
         nodes = self._get_all_nodes()
     if json:
         route_db_dict = {}
         for node in nodes:
             route_db = self.client.get_route_db(node)
             route_db_dict[node] = utils.route_db_to_dict(route_db)
         utils.print_routes_json(route_db_dict)
     else:
         for node in nodes:
             route_db = self.client.get_route_db(node)
             utils.print_routes_table(route_db)
Exemple #4
0
 def run(self, nodes, prefixes, labels, json):
     if "all" in nodes:
         nodes = self._get_all_nodes()
     if json:
         route_db_dict = {}
         for node in nodes:
             route_db = self.client.get_route_db(node)
             route_db_dict[node] = utils.route_db_to_dict(route_db)
         utils.print_routes_json(route_db_dict, prefixes, labels)
     else:
         for node in nodes:
             route_db = self.client.get_route_db(node)
             utils.print_route_db(route_db, prefixes, labels)
Exemple #5
0
 def _run(
     self, client: OpenrCtrl.Client, prefixes: Any, labels: Any, json: bool
 ) -> None:
     route_db = client.getRouteDbComputed("")
     # Filter out all MPLS routes
     route_db.mplsRoutes = []
     # Filter unicast routes on `doNotInstall` attribute
     route_db.unicastRoutes = [r for r in route_db.unicastRoutes if r.doNotInstall]
     if json:
         route_db_dict = {route_db.thisNodeName: utils.route_db_to_dict(route_db)}
         utils.print_routes_json(route_db_dict, prefixes, labels)
     else:
         utils.print_route_db(route_db, prefixes, labels)
Exemple #6
0
    def _run(self, client: OpenrCtrl.Client, prefix_or_ip: List[str],
             json: bool) -> None:
        unicast_route_list = client.getUnicastRoutesFiltered(prefix_or_ip)
        host_name = client.getMyNodeName()

        if json:
            routes = {
                "unicastRoutes":
                [utils.unicast_route_to_dict(r) for r in unicast_route_list]
            }
            route_dict = {host_name: routes}
            utils.print_routes_json(route_dict)
        else:
            utils.print_unicast_routes(
                "Unicast Routes for {}".format(host_name), unicast_route_list)
Exemple #7
0
    def _run(self, client: OpenrCtrl.Client, labels: List[int], json: bool) -> None:
        int_label_filters = [int(label) for label in labels]
        mpls_route_list = client.getMplsRoutesFiltered(int_label_filters)
        host_name = client.getMyNodeName()

        if json:
            routes = {
                "mplsRoutes": [utils.mpls_route_to_dict(r) for r in mpls_route_list]
            }
            route_dict = {host_name: routes}
            utils.print_routes_json(route_dict)
        else:
            utils.print_mpls_routes(
                "MPLS Routes for {}".format(host_name), mpls_route_list
            )
Exemple #8
0
 def _run(
     self,
     client: OpenrCtrl.Client,
     nodes: set,
     prefixes: Any,
     labels: Any,
     json: bool,
 ) -> None:
     if "all" in nodes:
         nodes = self._get_all_nodes(client)
     if json:
         route_db_dict = {}
         for node in nodes:
             route_db = client.getRouteDbComputed(node)
             route_db_dict[node] = utils.route_db_to_dict(route_db)
         utils.print_routes_json(route_db_dict, prefixes, labels)
     else:
         for node in nodes:
             route_db = client.getRouteDbComputed(node)
             utils.print_route_db(route_db, prefixes, labels)