Ejemplo n.º 1
0
    def print_adj(self, publications: Dict[str, openr_types.Publication],
                  nodes, bidir, json):
        adjs_list = defaultdict(list)
        # get list of adjancencies from each area and add it to the final
        # adjacency DB.
        adjs_map = {}
        for area, publication in publications.items():
            adjs = utils.adj_dbs_to_dict(publication, nodes, bidir,
                                         self.iter_publication)
            # handle case when area has no adjacencies
            if len(adjs):
                adjs_map = adjs
            else:
                continue
            for key, val in adjs_map.items():
                for adj_entry in val["adjacencies"]:
                    adj_entry["area"] = area
                adjs_list[key].extend(val["adjacencies"])

        for key, val in adjs_list.items():
            adjs_map[key]["adjacencies"] = val

        if json:
            utils.print_json(adjs_map)
        else:
            utils.print_adjs_table(adjs_map)
Ejemplo n.º 2
0
 def run(self, nodes, bidir, json):
     adj_dbs = self.client.get_adj_dbs()
     adjs_map = utils.adj_dbs_to_dict(adj_dbs, nodes, bidir, self.iter_dbs)
     if json:
         utils.print_adjs_json(adjs_map)
     else:
         utils.print_adjs_table(adjs_map, self.enable_color)
Ejemplo n.º 3
0
 def _run(self, client: OpenrCtrl.Client, nodes: set, node: Any,
          interface: Any) -> None:
     keyDumpParams = self.buildKvStoreKeyDumpParams(Consts.ADJ_DB_MARKER)
     publication = client.getKvStoreKeyValsFiltered(keyDumpParams)
     adjs_map = utils.adj_dbs_to_dict(publication, nodes, True,
                                      self.iter_publication)
     utils.print_adjs_table(adjs_map, self.enable_color, node, interface)
Ejemplo n.º 4
0
 def run(self, nodes, bidir, json):
     publication = self.client.dump_all_with_prefix(Consts.ADJ_DB_MARKER)
     adjs_map = utils.adj_dbs_to_dict(publication, nodes, bidir,
                                      self.iter_publication)
     if json:
         utils.print_adjs_json(adjs_map)
     else:
         utils.print_adjs_table(adjs_map, self.enable_color)
Ejemplo n.º 5
0
 def _run(self, client: OpenrCtrl.Client, nodes: set, bidir: bool,
          json: bool) -> None:
     adj_dbs = client.getDecisionAdjacencyDbs()
     adjs_map = utils.adj_dbs_to_dict(adj_dbs, nodes, bidir, self.iter_dbs)
     if json:
         utils.print_json(adjs_map)
     else:
         utils.print_adjs_table(adjs_map, self.enable_color, None, None)
Ejemplo n.º 6
0
 def _run(self, client: OpenrCtrl.Client, nodes: set, bidir: bool,
          json: bool) -> None:
     keyDumpParams = self.buildKvStoreKeyDumpParams(Consts.ADJ_DB_MARKER)
     publication = client.getKvStoreKeyValsFiltered(keyDumpParams)
     adjs_map = utils.adj_dbs_to_dict(publication, nodes, bidir,
                                      self.iter_publication)
     if json:
         utils.print_json(adjs_map)
     else:
         utils.print_adjs_table(adjs_map, self.enable_color)
Ejemplo n.º 7
0
Archivo: lm.py Proyecto: guodong/openr
    def _run(self, client: OpenrCtrl.Client, nodes: set, json: bool) -> None:
        adj_db = client.getLinkMonitorAdjacencies()

        # adj_dbs is built with ONLY one single (node, adjDb). Ignpre bidir option
        adjs_map = utils.adj_dbs_to_dict({adj_db.thisNodeName: adj_db}, nodes,
                                         False, self.iter_dbs)
        if json:
            utils.print_json(adjs_map)
        else:
            utils.print_adjs_table(adjs_map, None, None)
Ejemplo n.º 8
0
 def _run(self, client: OpenrCtrl.Client, nodes: set, bidir: bool,
          json: bool) -> None:
     adj_dbs = client.getDecisionAdjacencyDbs()
     adjs_map = utils.adj_dbs_to_dict(adj_dbs, nodes, bidir, self.iter_dbs)
     for _, val in adjs_map.items():
         for adj_entry in val["adjacencies"]:
             adj_entry["area"] = val.get("area", "N/A")
     if json:
         utils.print_json(adjs_map)
     else:
         utils.print_adjs_table(adjs_map, None, None)
Ejemplo n.º 9
0
    def _run(self, client: OpenrCtrl.Client, nodes: set, areas: set,
             bidir: bool, json: bool) -> None:

        adj_dbs = client.getDecisionAdjacenciesFiltered(
            ctrl_types.AdjacenciesFilter(selectAreas=areas))

        # convert list<adjDb> from server to a two level map: {area: {node: adjDb}}
        adjs_map_all_areas = utils.adj_dbs_to_area_dict(adj_dbs, nodes, bidir)

        if json:
            utils.print_json(adjs_map_all_areas)
        else:
            # print per-node adjDb tables on a per-area basis
            for area, adjs_map in sorted(adjs_map_all_areas.items()):
                print("\n== Area:", area, "==\n")
                utils.print_adjs_table(adjs_map, None, None)
Ejemplo n.º 10
0
 def run(self, nodes, node, interface):
     publication = self.client.dump_all_with_filter(Consts.ADJ_DB_MARKER)
     adjs_map = utils.adj_dbs_to_dict(
         publication, nodes, True, self.iter_publication
     )
     utils.print_adjs_table(adjs_map, self.enable_color, node, interface)
Ejemplo n.º 11
0
 def printAdjNode(self, publication, nodes, node, interface):
     adjs_map = utils.adj_dbs_to_dict(publication, nodes, True,
                                      self.iter_publication)
     utils.print_adjs_table(adjs_map, node, interface)