mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
This can now a days be inferred and isn't needed. Also, the interface type in virtual testing is now etherlike not ethernet. Signed-off-by: Richard Alpe <richard@bit42.se>
43 lines
1.3 KiB
Python
Executable File
43 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import copy
|
|
import infamy
|
|
import infamy.iface as iface
|
|
|
|
from infamy.util import until
|
|
|
|
with infamy.Test() as test:
|
|
with test.step("Initialize"):
|
|
env = infamy.Env(infamy.std_topology("1x2"))
|
|
target = env.attach("target", "mgmt")
|
|
_, tport = env.ltop.xlate("target", "data")
|
|
pmac = iface.get_phys_address(target, tport)
|
|
cmac = "02:01:00:c0:ff:ee"
|
|
print(f"Target iface {tport} original mac {pmac}")
|
|
|
|
with test.step("Set custom MAC address"):
|
|
config = {
|
|
"interfaces": {
|
|
"interface": [{
|
|
"name": f"{tport}",
|
|
"phys-address": f"{cmac}"
|
|
}]
|
|
}
|
|
}
|
|
target.put_config_dict("ietf-interfaces", config)
|
|
mac = iface.get_phys_address(target, tport)
|
|
print(f"Target iface {tport} current mac: {mac}")
|
|
assert mac == cmac
|
|
|
|
with test.step(f"Remove custom MAC address"):
|
|
running = target.get_config_dict("/ietf-interfaces:interfaces")
|
|
new = copy.deepcopy(running)
|
|
for i in new["interfaces"]["interface"]:
|
|
if i["name"] == tport:
|
|
del i["phys-address"]
|
|
break
|
|
target.put_diff_dicts("ietf-interfaces", running, new)
|
|
until(lambda: iface.get_phys_address(target, tport) == pmac)
|
|
|
|
test.succeed()
|