mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-23 17:33:01 +02:00
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:
@@ -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"
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user