From e4535aa856754dbda36479486f8959fffd2f305c Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Tue, 10 Dec 2024 18:46:44 +0100 Subject: [PATCH] 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"] --- test/infamy/restconf.py | 1 + test/infamy/transport.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/test/infamy/restconf.py b/test/infamy/restconf.py index b1ebeed1..67e1d1e0 100644 --- a/test/infamy/restconf.py +++ b/test/infamy/restconf.py @@ -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" diff --git a/test/infamy/transport.py b/test/infamy/transport.py index 3c754a94..922a9de2 100644 --- a/test/infamy/transport.py +++ b/test/infamy/transport.py @@ -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))