test: infamy: Make it easier to resolve mapped port names

The somewhat clumsy construct of resolving a logical port name to its
physical counterpart has been with us from Infamy's inception:

    _, physical_port = env.ltop.xlate(logical_node, logical_port)

This is needlessly verbose. Since devices already have access to the
mappings which applies to it, make them easy to access:

    target = env.attach("target")

    # Get physical port names via the subscript operator
    target["data0"]
This commit is contained in:
Tobias Waldekranz
2025-01-08 10:14:46 +01:00
parent 343400c5fe
commit e4535aa856
2 changed files with 4 additions and 0 deletions
+1
View File
@@ -119,6 +119,7 @@ class Device(Transport):
self.name = name
self.location = location
self.mapping = mapping
self.url_base = f"https://[{location.host}]:{location.port}"
self.restconf_url = f"{self.url_base}/restconf"
self.yang_url = f"{self.url_base}/yang"
+3
View File
@@ -55,6 +55,9 @@ class Transport(ABC):
def call_action(self, xpath):
pass
def __getitem__(self, key):
return self.mapping[key]
def get_iface(self, name):
"""Fetch target dict for iface and extract param from JSON"""
content = self.get_data(infamy.iface.get_xpath(name))