mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-05 07:03:02 +02:00
All mgmt links should be lightgrey, all mgmt ports should be named mgmt links between duts should be named link.
80 lines
2.4 KiB
Python
Executable File
80 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
USB configuration with two USB ports
|
|
|
|
Test that the USB locked/unlocked configuration is consistent
|
|
when having two USB ports.
|
|
"""
|
|
import infamy
|
|
import copy
|
|
import infamy.usb as usb
|
|
import time
|
|
import infamy.netconf as netconf
|
|
from infamy.util import until,wait_boot
|
|
|
|
with infamy.Test() as test:
|
|
with test.step("Set up topology and attach to target DUTs"):
|
|
env = infamy.Env()
|
|
target = env.attach("target", "mgmt")
|
|
available=usb.get_usb_ports(target)
|
|
|
|
if len(available) < 2:
|
|
test.skip()
|
|
|
|
with test.step("Lock the first USB port and unlock the second USB port"):
|
|
components = []
|
|
component = {
|
|
"name": available[0],
|
|
"class": "infix-hardware:usb",
|
|
"state": {
|
|
"admin-state": "locked"
|
|
}
|
|
}
|
|
components.append(component)
|
|
component = {
|
|
"name": available[1],
|
|
"class": "infix-hardware:usb",
|
|
"state": {
|
|
"admin-state": "unlocked"
|
|
}
|
|
}
|
|
components.append(component)
|
|
|
|
target.put_config_dict("ietf-hardware", {
|
|
"hardware": {
|
|
"component": components
|
|
}
|
|
})
|
|
with test.step("Verify that the correct port is locked and the correct one is unlocked"):
|
|
until(lambda: usb.get_usb_state(target, available[0]) == "locked")
|
|
until(lambda: usb.get_usb_state(target, available[1]) == "unlocked")
|
|
|
|
with test.step("Unlock the first USB port, and lock the second USB port"):
|
|
components = []
|
|
component = {
|
|
"name": available[0],
|
|
"class": "infix-hardware:usb",
|
|
"state": {
|
|
"admin-state": "unlocked"
|
|
}
|
|
}
|
|
components.append(component)
|
|
component = {
|
|
"name": available[1],
|
|
"class": "infix-hardware:usb",
|
|
"state": {
|
|
"admin-state": "locked"
|
|
}
|
|
}
|
|
components.append(component)
|
|
|
|
target.put_config_dict("ietf-hardware", {
|
|
"hardware": {
|
|
"component": components
|
|
}
|
|
})
|
|
with test.step("Verify that the correct port is locked and the correct one is unlocked"):
|
|
until(lambda: usb.get_usb_state(target, available[0]) == "unlocked")
|
|
until(lambda: usb.get_usb_state(target, available[1]) == "locked")
|
|
test.succeed()
|