Skip to content

Commit

Permalink
Add a topology map getter method
Browse files Browse the repository at this point in the history
  • Loading branch information
sajith committed Jan 11, 2024
1 parent 9e67d4d commit 349e2dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sdx_pce/topology/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def set_topology(self, topology):
def get_topology(self):
return self._topology

def get_topology_map(self) -> dict:
return self._topology_map

def get_port_map(self) -> Mapping[str, dict]:
"""
Return a mapping between port IDs and links.
Expand Down
6 changes: 6 additions & 0 deletions src/sdx_pce/topology/temanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def update_topology(self, topology_data: dict):
# port_list=self.topology_manager.port_list,
# )

def get_topology_map(self) -> dict:
"""
Get {topology_id: topology, ..} map.
"""
return self.topology_manager.get_topology_map()

def _update_vlan_tags_table(self, domain_name: str, port_map: dict):
"""
Update VLAN tags table.
Expand Down
6 changes: 6 additions & 0 deletions tests/test_te_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def test_connection_breakdown_three_domains(self):
zaoxi_topology = json.loads(TestData.TOPOLOGY_FILE_ZAOXI.read_text())
self.temanager.add_topology(zaoxi_topology)

topology_map = self.temanager.get_topology_map()
self.assertIsInstance(topology_map, dict)

for num, val in enumerate(topology_map.values()):
print(f"TE topology #{num}: {val}")

request = [
{
"1": [[1, 2], [3, 4]],
Expand Down

0 comments on commit 349e2dd

Please sign in to comment.