test: usb: adapt to new yangerd

This commit is contained in:
Mattias Walström
2026-06-19 11:38:09 +02:00
parent 937e7caf52
commit c3c5ec3bb4
+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"]