test: usb: adapt to new yangerd

This commit is contained in:
Mattias Walström
2026-06-17 11:54:25 +02:00
parent 6c12b30383
commit 5884a7f6fb
+4 -3
View File
@@ -1,11 +1,12 @@
def _get_hardware(target):
xpath="/ietf-hardware:hardware"
return target.get_data(xpath)["hardware"]
hw = target.get_data(xpath)
return {} if hw is None else hw.get("hardware", {})
def get_usb_ports(target):
hardware=_get_hardware(target)
ports=[]
for component in hardware["component"]:
for component in hardware.get("component"):
if component.get("class") == "infix-hardware:usb":
ports.append(component["name"])
@@ -13,6 +14,6 @@ def get_usb_ports(target):
def get_usb_state(target, name):
hardware=_get_hardware(target)
for component in hardware["component"]:
for component in hardware.get("component"):
if component.get("name") == name and component.get("class") == "infix-hardware:usb":
return component["state"]["admin-state"]