Files
infix/test/case/ietf_interfaces/vlan_ping.py
T
Mattias WalströmandJoachim Wiberg 941fc31581 infix-vlan: Create a custom vlan model
This implements the new model infix-if-vlan.
The new CLI is:

root@infix-00-00-00:/config/interfaces/interface/vlan10/> set vlan id 10 lower-layer-if eth0

with an possible extra option for tag-type, default tag-type is c-vlan.
2023-10-27 10:53:55 +02:00

61 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
import infamy
with infamy.Test() as test:
with test.step("Initialize"):
env = infamy.Env(infamy.std_topology("1x2"))
target = env.attach("target", "mgmt")
with test.step("Configure VLAN 10 on target:data with IP 10.0.0.2"):
_, tport = env.ltop.xlate("target", "data")
target.put_config_dict("ietf-interfaces", {
"interfaces": {
"interface": [
{
"name": tport,
"type": "infix-if-type:ethernet",
"enabled": True,
},
{
"name": f"{tport}.10",
"type": "infix-if-type:vlan",
"vlan": {
"id": 10,
"lower-layer-if": tport,
},
"ipv4": {
"address": [
{
"ip": "10.0.0.2",
"prefix-length": 24,
}
]
}
},
]
}
})
with test.step("Ping 10.0.0.2 from VLAN 10 on host:data with IP 10.0.0.1"):
_, hport = env.ltop.xlate("host", "data")
with infamy.IsolatedMacVlan(hport) as ns:
pingtest = ns.runsh("""
set -ex
ip link set iface up
ip link add dev vlan10 link iface up type vlan id 10
ip addr add 10.0.0.1/24 dev vlan10
ping -c1 -w5 10.0.0.2 || exit 1
""")
if pingtest.returncode:
print(pingtest.stdout)
test.fail()
test.succeed()