From: Christos Sfakianakis <csfakian(a)redhat.com>
Reduce repetitive coding in recipes using loops while maintaining
readability.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/Recipes/ENRT/BondRecipe.py | 28 ++++----
lnst/Recipes/ENRT/DoubleBondRecipe.py | 24 +++----
lnst/Recipes/ENRT/DoubleTeamRecipe.py | 47 +++++--------
lnst/Recipes/ENRT/IpsecEspAeadRecipe.py | 9 +--
lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py | 9 +--
lnst/Recipes/ENRT/NoVirtOvsVxlanRecipe.py | 12 ++--
.../ENRT/ShortLivedConnectionsRecipe.py | 9 +--
lnst/Recipes/ENRT/SimpleMacsecRecipe.py | 5 +-
lnst/Recipes/ENRT/SimplePerfRecipe.py | 11 ++-
lnst/Recipes/ENRT/TeamRecipe.py | 21 +++---
lnst/Recipes/ENRT/TeamVsBondRecipe.py | 36 ++++------
lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py | 11 +--
.../VirtualBridgeVlanInGuestMirroredRecipe.py | 50 +++++---------
.../ENRT/VirtualBridgeVlanInGuestRecipe.py | 33 ++++-----
.../VirtualBridgeVlanInHostMirroredRecipe.py | 43 +++++-------
.../ENRT/VirtualBridgeVlanInHostRecipe.py | 26 +++----
.../ENRT/VirtualBridgeVlansOverBondRecipe.py | 31 +++------
...rtualOvsBridgeVlanInGuestMirroredRecipe.py | 33 ++++-----
.../ENRT/VirtualOvsBridgeVlanInGuestRecipe.py | 32 +++------
...irtualOvsBridgeVlanInHostMirroredRecipe.py | 43 +++++-------
.../ENRT/VirtualOvsBridgeVlanInHostRecipe.py | 24 ++-----
.../VirtualOvsBridgeVlansOverBondRecipe.py | 67 +++++--------------
lnst/Recipes/ENRT/VlansOverBondRecipe.py | 18 ++---
lnst/Recipes/ENRT/VlansOverTeamRecipe.py | 18 ++---
lnst/Recipes/ENRT/VlansRecipe.py | 10 +--
lnst/Recipes/ENRT/VxlanMulticastRecipe.py | 14 ++--
26 files changed, 224 insertions(+), 440 deletions(-)
diff --git a/lnst/Recipes/ENRT/BondRecipe.py b/lnst/Recipes/ENRT/BondRecipe.py
index bbe2d57..3a18354 100644
--- a/lnst/Recipes/ENRT/BondRecipe.py
+++ b/lnst/Recipes/ENRT/BondRecipe.py
@@ -29,31 +29,27 @@ class BondRecipe(BaseEnrtRecipe):
host1, host2 = self.matched.host1, self.matched.host2
host1.bond0 = BondDevice(mode=self.params.bonding_mode,
miimon=self.params.miimon_value)
- host1.eth0.down()
- host1.eth1.down()
- host1.bond0.slave_add(host1.eth0)
- host1.bond0.slave_add(host1.eth1)
+ for dev in [host1.eth0, host1.eth1]:
+ dev.down()
+ host1.bond0.slave_add(dev)
configuration = EnrtConfiguration()
configuration.endpoint1 = host1.bond0
configuration.endpoint2 = host2.eth0
+ net_addr = "192.168.101"
+ net_addr6 = "fc00:0:0:0"
+ for i, dev in enumerate([host1.bond0, host2.eth0]):
+ dev.ip_add(ipaddress(net_addr + "." + str(i+1) + "/24"))
+ dev.ip_add(ipaddress(net_addr6 + "::" + str(i+1) +
"/64"))
+
+ for dev in [host1.eth0, host1.eth1, host1.bond0, host2.eth0]:
+ dev.up()
+
if "mtu" in self.params:
host1.bond0.mtu = self.params.mtu
host2.eth0.mtu = self.params.mtu
- net_addr = "192.168.101"
- net_addr6 = "fc00:0:0:0"
- host1.bond0.ip_add(ipaddress(net_addr + ".1/24"))
- host1.bond0.ip_add(ipaddress(net_addr6 + "::1/64"))
- host1.eth0.up()
- host1.eth1.up()
- host1.bond0.up()
-
- host2.eth0.ip_add(ipaddress(net_addr + ".2/24"))
- host2.eth0.ip_add(ipaddress(net_addr6 + "::2/64"))
- host2.eth0.up()
-
if "adaptive_rx_coalescing" in self.params:
for dev in [host1.eth0, host1.eth1, host2.eth0]:
dev.adaptive_rx_coalescing = self.params.adaptive_rx_coalescing
diff --git a/lnst/Recipes/ENRT/DoubleBondRecipe.py
b/lnst/Recipes/ENRT/DoubleBondRecipe.py
index c9fdc50..599563a 100644
--- a/lnst/Recipes/ENRT/DoubleBondRecipe.py
+++ b/lnst/Recipes/ENRT/DoubleBondRecipe.py
@@ -29,12 +29,17 @@ class DoubleBondRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in (host1, host2):
+ net_addr = "192.168.101"
+ net_addr6 = "fc00:0:0:0"
+ for i, host in enumerate([host1, host2]):
host.bond0 = BondDevice(mode=self.params.bonding_mode,
miimon=self.params.miimon_value)
- host.eth0.down()
- host.eth1.down()
- host.bond0.slave_add(host.eth0)
- host.bond0.slave_add(host.eth1)
+ for dev in [host.eth0, host.eth1]:
+ dev.down()
+ host.bond0.slave_add(dev)
+ host.bond0.ip_add(ipaddress(net_addr + "." + str(i+1) +
"/24"))
+ host.bond0.ip_add(ipaddress(net_addr6 + "::" + str(i+1) +
"/64"))
+ for dev in [host.eth0, host.eth1, host.bond0]:
+ dev.up()
configuration = EnrtConfiguration()
configuration.endpoint1 = host1.bond0
@@ -44,15 +49,6 @@ class DoubleBondRecipe(BaseEnrtRecipe):
host1.bond0.mtu = self.params.mtu
host2.bond0.mtu = self.params.mtu
- net_addr = "192.168.101"
- net_addr6 = "fc00:0:0:0"
- for i, host in enumerate([host1, host2]):
- host.bond0.ip_add(ipaddress(net_addr + "." + str(i+1) +
"/24"))
- host.bond0.ip_add(ipaddress(net_addr6 + "::" + str(i+1) +
"/64"))
- host.eth0.up()
- host.eth1.up()
- host.bond0.up()
-
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
for dev in [host.eth0, host.eth1]:
diff --git a/lnst/Recipes/ENRT/DoubleTeamRecipe.py
b/lnst/Recipes/ENRT/DoubleTeamRecipe.py
index cea3542..1191430 100644
--- a/lnst/Recipes/ENRT/DoubleTeamRecipe.py
+++ b/lnst/Recipes/ENRT/DoubleTeamRecipe.py
@@ -29,44 +29,27 @@ class DoubleTeamRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- host1.eth0.down()
- host1.eth1.down()
- #The config argument needs to be used with a team device normally (e.g to
specify
- #the runner mode), but it is not used here due to a bug in the TeamDevice module
- host1.team0 = TeamDevice()
- host1.team0.slave_add(host1.eth0)
- host1.team0.slave_add(host1.eth1)
-
- host2.eth0.down()
- host2.eth1.down()
- host2.team0 = TeamDevice()
- host2.team0.slave_add(host2.eth0)
- host2.team0.slave_add(host2.eth1)
+ net_addr_1 = "192.168.10"
+ net_addr6_1 = "fc00:0:0:1"
+ for i, host in enumerate([host1, host2]):
+ #The config argument needs to be used with a team device normally (e.g to
specify
+ #the runner mode), but it is not used here due to a bug in the TeamDevice
module
+ host.team0 = TeamDevice()
+ for dev in [host.eth0, host.eth1]:
+ dev.down()
+ host.team0.slave_add(dev)
+ if "mtu" in self.params:
+ host.team0.mtu = self.params.mtu
+ host.team0.ip_add(ipaddress(net_addr_1 + "." + str(i+1) +
"/24"))
+ host.team0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+1) +
"/64"))
+ for dev in [host.eth0, host.eth1, host.team0]:
+ dev.up()
#EnrtConfiguration and both-side Netperf config need to be checked
configuration = EnrtConfiguration()
configuration.endpoint1 = host1.team0
configuration.endpoint2 = host2.team0
- if "mtu" in self.params:
- host1.team0.mtu = self.params.mtu
- host2.team0.mtu = self.params.mtu
-
- net_addr_1 = "192.168.10"
- net_addr6_1 = "fc00:0:0:1"
-
- host1.team0.ip_add(ipaddress(net_addr_1 + ".1/24"))
- host1.team0.ip_add(ipaddress(net_addr6_1 + "::1/64"))
- host2.team0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.team0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
-
- host1.eth0.up()
- host1.eth1.up()
- host1.team0.up()
- host2.eth0.up()
- host2.eth1.up()
- host2.team0.up()
-
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
for dev in [host.eth0, host.eth1]:
diff --git a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py
b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py
index ded15a6..ae615a7 100644
--- a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py
+++ b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py
@@ -165,15 +165,13 @@ class IpsecEspAeadRecipe(BaseEnrtRecipe,
PacketAssertTestAndEvaluate):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in [host1, host2]:
- host.eth0.down()
-
net_addr = "192.168."
net_addr6 = "fc00:"
-
for i, host in enumerate([host1, host2]):
+ host.eth0.down()
host.eth0.ip_add(ipaddress(net_addr + str(i+99) + ".1/24"))
host.eth0.ip_add(ipaddress(net_addr6 + str(i+1) + "::1/64"))
+ host.eth0.up()
#Due to limitations in the current EnrtConfiguration
#class, a single test pair is chosen
@@ -189,9 +187,6 @@ class IpsecEspAeadRecipe(BaseEnrtRecipe,
PacketAssertTestAndEvaluate):
for host in [host1, host2]:
host.eth0.mtu = self.params.mtu
- for host in [host1, host2]:
- host.eth0.up()
-
for host, dst in [(host1, host2), (host2, host1)]:
for family in [AF_INET, AF_INET6]:
host.run("ip route add %s dev %s" %
diff --git a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py
b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py
index b4ab4a7..6c74fae 100644
--- a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py
+++ b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py
@@ -195,15 +195,13 @@ class IpsecEspAhCompRecipe(BaseEnrtRecipe,
PacketAssertTestAndEvaluate):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in [host1, host2]:
- host.eth0.down()
-
net_addr = "192.168."
net_addr6 = "fc00:"
-
for i, host in enumerate([host1, host2]):
+ host.eth0.down()
host.eth0.ip_add(ipaddress(net_addr + str(i+99) + ".1/24"))
host.eth0.ip_add(ipaddress(net_addr6 + str(i+1) + "::1/64"))
+ host.eth0.up()
#Due to limitations in the current EnrtConfiguration
#class, a single test pair is chosen
@@ -219,9 +217,6 @@ class IpsecEspAhCompRecipe(BaseEnrtRecipe,
PacketAssertTestAndEvaluate):
for host in [host1, host2]:
host.eth0.mtu = self.params.mtu
- for host in [host1, host2]:
- host.eth0.up()
-
for host, dst in [(host1, host2), (host2, host1)]:
for family in [AF_INET, AF_INET6]:
host.run("ip route add %s dev %s" %
diff --git a/lnst/Recipes/ENRT/NoVirtOvsVxlanRecipe.py
b/lnst/Recipes/ENRT/NoVirtOvsVxlanRecipe.py
index 4c365a2..6e246df 100644
--- a/lnst/Recipes/ENRT/NoVirtOvsVxlanRecipe.py
+++ b/lnst/Recipes/ENRT/NoVirtOvsVxlanRecipe.py
@@ -17,9 +17,6 @@ class NoVirtOvsVxlanRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in [host1, host2]:
- host.eth0.down()
-
net_addr = "192.168.2"
vxlan_net_addr = "192.168.100"
vxlan_net_addr6 = "fc00:0:0:0"
@@ -30,6 +27,7 @@ class NoVirtOvsVxlanRecipe(BaseEnrtRecipe):
flow_entries.append("table=0,priority=100,actions=drop")
for i, host in enumerate([host1, host2]):
+ host.eth0.down()
host.eth0.ip_add(ipaddress(net_addr + "." + str (i+1) +
"/24"))
host.br0 = OvsBridgeDevice()
host.int0 = host.br0.internal_port_add(ofport_request='5',
name="int0")
@@ -39,6 +37,9 @@ class NoVirtOvsVxlanRecipe(BaseEnrtRecipe):
"ofport_request" : "10"}
host.br0.tunnel_add("vxlan", tunnel_opts)
host.br0.flows_add(flow_entries)
+ host.eth0.up()
+ host.int0.up()
+ host.br0.up()
#Due to limitations in the current EnrtConfiguration
#class, a single test pair is chosen
@@ -50,11 +51,6 @@ class NoVirtOvsVxlanRecipe(BaseEnrtRecipe):
for host in [host1, host2]:
host.int0.mtu = self.params.mtu
- for host in [host1, host2]:
- host.eth0.up()
- host.int0.up()
- host.br0.up()
-
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
for host in [host1, host2]:
diff --git a/lnst/Recipes/ENRT/ShortLivedConnectionsRecipe.py
b/lnst/Recipes/ENRT/ShortLivedConnectionsRecipe.py
index 42a2d86..3af503d 100644
--- a/lnst/Recipes/ENRT/ShortLivedConnectionsRecipe.py
+++ b/lnst/Recipes/ENRT/ShortLivedConnectionsRecipe.py
@@ -22,13 +22,11 @@ class ShortLivedConnectionsRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in [host1, host2]:
- host.eth0.down()
-
net_addr = "192.168.101"
-
for i, host in enumerate([host1, host2], 10):
+ host.eth0.down()
host.eth0.ip_add(ipaddress(net_addr + "." + str(i) +
"/24"))
+ host.eth0.up()
#Due to limitations in the current EnrtConfiguration
#class, a single test pair is chosen
@@ -40,9 +38,6 @@ class ShortLivedConnectionsRecipe(BaseEnrtRecipe):
for host in [host1, host2]:
host.eth0.mtu = self.params.mtu
- for host in [host1, host2]:
- host.eth0.up()
-
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
for host in [host1, host2]:
diff --git a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
index 1da586d..17cbc68 100644
--- a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
+++ b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
@@ -71,12 +71,9 @@ class SimpleMacsecRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- for host in [host1, host2]:
- host.eth0.down()
-
net_addr = "192.168.0"
-
for i, host in enumerate([host1, host2]):
+ host.eth0.down()
host.eth0.ip_add(ipaddress(net_addr + '.' + str(i+1) +
"/24"))
#Due to limitations in the current EnrtConfiguration
diff --git a/lnst/Recipes/ENRT/SimplePerfRecipe.py
b/lnst/Recipes/ENRT/SimplePerfRecipe.py
index bc23a97..53e4086 100644
--- a/lnst/Recipes/ENRT/SimplePerfRecipe.py
+++ b/lnst/Recipes/ENRT/SimplePerfRecipe.py
@@ -31,13 +31,10 @@ class SimplePerfRecipe(BaseEnrtRecipe):
host1.eth0.mtu = self.params.mtu
host2.eth0.mtu = self.params.mtu
- host1.eth0.ip_add(ipaddress("192.168.101.1/24"))
- host1.eth0.ip_add(ipaddress("fc00::1/64"))
- host1.eth0.up()
-
- host2.eth0.ip_add(ipaddress("192.168.101.2/24"))
- host2.eth0.ip_add(ipaddress("fc00::2/64"))
- host2.eth0.up()
+ for i, host in enumerate([host1, host2]):
+ host.eth0.ip_add(ipaddress("192.168.101." + str(i+1) +
"/24"))
+ host.eth0.ip_add(ipaddress("fc00::" + str(i+1) + "/64"))
+ host.eth0.up()
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
diff --git a/lnst/Recipes/ENRT/TeamRecipe.py b/lnst/Recipes/ENRT/TeamRecipe.py
index 93d1c05..3fa866b 100644
--- a/lnst/Recipes/ENRT/TeamRecipe.py
+++ b/lnst/Recipes/ENRT/TeamRecipe.py
@@ -28,13 +28,12 @@ class TeamRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- host1.eth0.down()
- host1.eth1.down()
#The config argument needs to be used with a team device normally (e.g to
specify
#the runner mode), but it is not used here due to a bug in the TeamDevice module
host1.team0 = TeamDevice()
- host1.team0.slave_add(host1.eth0)
- host1.team0.slave_add(host1.eth1)
+ for dev in [host1.eth0, host1.eth1]:
+ dev.down()
+ host1.team0.slave_add(dev)
#EnrtConfiguration and both-side Netperf config need to be checked
configuration = EnrtConfiguration()
@@ -47,16 +46,12 @@ class TeamRecipe(BaseEnrtRecipe):
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
+ for i, dev in enumerate([host1.team0, host2.eth0]):
+ dev.ip_add(ipaddress(net_addr_1 + "." + str(i+1) +
"/24"))
+ dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i+1) +
"/64"))
- host1.team0.ip_add(ipaddress(net_addr_1 + ".1/24"))
- host1.team0.ip_add(ipaddress(net_addr6_1 + "::1/64"))
- host2.eth0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.eth0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
-
- host1.eth0.up()
- host1.eth1.up()
- host1.team0.up()
- host2.eth0.up()
+ for dev in [host1.eth0, host1.eth1, host1.team0, host2.eth0]:
+ dev.up()
if "adaptive_rx_coalescing" in self.params:
for dev in [host1.eth0, host1.eth1, host2.eth0]:
diff --git a/lnst/Recipes/ENRT/TeamVsBondRecipe.py
b/lnst/Recipes/ENRT/TeamVsBondRecipe.py
index 5170071..0f3b66e 100644
--- a/lnst/Recipes/ENRT/TeamVsBondRecipe.py
+++ b/lnst/Recipes/ENRT/TeamVsBondRecipe.py
@@ -33,19 +33,21 @@ class TeamVsBondRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- host1.eth0.down()
- host1.eth1.down()
+ net_addr_1 = "192.168.10"
+ net_addr6_1 = "fc00:0:0:1"
#The config argument needs to be used with a team device normally (e.g to
specify
#the runner mode), but it is not used here due to a bug in the TeamDevice module
host1.team0 = TeamDevice()
- host1.team0.slave_add(host1.eth0)
- host1.team0.slave_add(host1.eth1)
- host2.eth0.down()
- host2.eth1.down()
host2.bond0 = BondDevice(mode=self.params.bonding_mode,
miimon=self.params.miimon_value)
- host2.bond0.slave_add(host2.eth0)
- host2.bond0.slave_add(host2.eth1)
+
+ for i, (host, dev) in enumerate([(host1, host1.team0), (host2, host2.bond0)]):
+ host.eth0.down()
+ host.eth1.down()
+ dev.slave_add(host.eth0)
+ dev.slave_add(host.eth1)
+ dev.ip_add(ipaddress(net_addr_1 + "." + str(i+1) +
"/24"))
+ dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i+1) +
"/64"))
#EnrtConfiguration and both-side Netperf config need to be checked
configuration = EnrtConfiguration()
@@ -56,20 +58,10 @@ class TeamVsBondRecipe(BaseEnrtRecipe):
host1.team0.mtu = self.params.mtu
host2.bond0.mtu = self.params.mtu
- net_addr_1 = "192.168.10"
- net_addr6_1 = "fc00:0:0:1"
-
- host1.team0.ip_add(ipaddress(net_addr_1 + ".1/24"))
- host1.team0.ip_add(ipaddress(net_addr6_1 + "::1/64"))
- host2.bond0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.bond0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
-
- host1.eth0.up()
- host1.eth1.up()
- host1.team0.up()
- host2.eth0.up()
- host2.eth1.up()
- host2.bond0.up()
+ for host, dev in [(host1, host1.team0), (host2, host2.bond0)]:
+ host.eth0.up()
+ host.eth1.up()
+ dev.up()
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
diff --git a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py
b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py
index 0b04e39..5a47306 100644
--- a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py
+++ b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py
@@ -61,10 +61,13 @@ class VirtOvsVxlanRecipe(BaseEnrtRecipe):
"ofport_request" : '10'}
host.br0.tunnel_add("vxlan", tunnel_opts)
host.br0.flows_add(flow_entries)
+ for dev in [host.eth0, host.tap0, host.tap1, host.br0]:
+ dev.up()
for i, guest in enumerate([guest1, guest2, guest3, guest4]):
guest.eth0.ip_add(ipaddress(vxlan_net_addr + "." + str (i+1) +
"/24"))
guest.eth0.ip_add(ipaddress(vxlan_net_addr6 + "::" + str (i+1) +
"/64"))
+ guest.eth0.up()
#Due to limitations in the current EnrtConfiguration
#class, a single test pair is chosen
@@ -76,14 +79,6 @@ class VirtOvsVxlanRecipe(BaseEnrtRecipe):
for guest in [guest1, guest2, guest3, guest4]:
guest.eth0.mtu = self.params.mtu
- for host in [host1, host2]:
- host.eth0.up()
- host.tap0.up()
- host.tap1.up()
- host.br0.up()
- for guest in [guest1, guest2, guest3, guest4]:
- guest.eth0.up()
-
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
for machine in [host1, host2, guest1, guest2, guest3, guest4]:
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestMirroredRecipe.py
b/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestMirroredRecipe.py
index 83d9f41..64d6fa6 100644
--- a/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestMirroredRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestMirroredRecipe.py
@@ -35,17 +35,11 @@ class VirtualBridgeVlanInGuestMirroredRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1, guest2 = self.matched.host1, self.matched.host2,
self.matched.guest1, self.matched.guest2
- host1.eth0.down()
- host1.tap0.down()
- host1.br0 = BridgeDevice()
- host1.br0.slave_add(host1.eth0)
- host1.br0.slave_add(host1.tap0)
-
- host2.eth0.down()
- host2.tap0.down()
- host2.br0 = BridgeDevice()
- host2.br0.slave_add(host2.eth0)
- host2.br0.slave_add(host2.tap0)
+ for host in [host1, host2]:
+ host.br0 = BridgeDevice()
+ for dev in [host.eth0, host.tap0]:
+ dev.down()
+ host.br0.slave_add(dev)
guest1.eth0.down()
@@ -54,12 +48,9 @@ class VirtualBridgeVlanInGuestMirroredRecipe(BaseEnrtRecipe):
guest1_vlan_args0 = dict(realdev=guest1.eth0, vlan_id=10)
guest2_vlan_args0 = dict(realdev=guest2.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- host2.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.br0.mtu = self.params.mtu
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.mtu = self.params.mtu
guest1.eth0.mtu = self.params.mtu
guest2.eth0.mtu = self.params.mtu
for vlan_args in (guest1_vlan_args0, guest2_vlan_args0):
@@ -79,21 +70,16 @@ class VirtualBridgeVlanInGuestMirroredRecipe(BaseEnrtRecipe):
host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
host2.br0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- guest1.vlan0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.vlan0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
- guest2.vlan0.ip_add(ipaddress(net_addr_1 + ".4/24"))
- guest2.vlan0.ip_add(ipaddress(net_addr6_1 + "::4/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.tap0.up()
- host2.br0.up()
- guest1.eth0.up()
- guest1.vlan0.up()
- guest2.eth0.up()
- guest2.vlan0.up()
+ for i, guest in enumerate([guest1, guest2]):
+ guest.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
"/24"))
+ guest.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
"/64"))
+
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.up()
+ for guest in [guest1, guest2]:
+ guest.eth0.up()
+ guest.vlan0.up()
#TODO better service handling through HostAPI
if "perf_tool_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestRecipe.py
b/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestRecipe.py
index c712e28..9542437 100644
--- a/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualBridgeVlanInGuestRecipe.py
@@ -31,11 +31,10 @@ class VirtualBridgeVlanInGuestRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1 = self.matched.host1, self.matched.host2,
self.matched.guest1
- host1.eth0.down()
- host1.tap0.down()
host1.br0 = BridgeDevice()
- host1.br0.slave_add(host1.eth0)
- host1.br0.slave_add(host1.tap0)
+ for dev in [host1.eth0, host1.tap0]:
+ dev.down()
+ host1.br0.slave_add(dev)
host2.eth0.down()
@@ -45,11 +44,8 @@ class VirtualBridgeVlanInGuestRecipe(BaseEnrtRecipe):
guest1_vlan_args0 = dict(realdev=guest1.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- guest1.eth0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
+ for dev in [host1.eth0, host1.tap0, host1.br0, guest1.eth0, host2.eth0]:
+ dev.mtu = self.params.mtu
for vlan_args in (host2_vlan_args0, guest1_vlan_args0):
vlan_args["mtu"] = self.params.mtu
@@ -66,18 +62,13 @@ class VirtualBridgeVlanInGuestRecipe(BaseEnrtRecipe):
net_addr6_1 = "fc00:0:0:1"
host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
- host2.vlan0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.vlan0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
- guest1.vlan0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.vlan0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.vlan0.up()
- guest1.eth0.up()
- guest1.vlan0.up()
+ for i, machine in enumerate([host2, guest1]):
+ machine.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+2) +
"/24"))
+ machine.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+2) +
"/64"))
+
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0,
+ host2.vlan0, guest1.eth0, guest1.vlan0]:
+ dev.up()
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlanInHostMirroredRecipe.py
b/lnst/Recipes/ENRT/VirtualBridgeVlanInHostMirroredRecipe.py
index 1c9ea4d..793cebc 100644
--- a/lnst/Recipes/ENRT/VirtualBridgeVlanInHostMirroredRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualBridgeVlanInHostMirroredRecipe.py
@@ -35,15 +35,11 @@ class VirtualBridgeVlanInHostMirroredRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1, guest2 = self.matched.host1, self.matched.host2,
self.matched.guest1, self.matched.guest2
- host1.eth0.down()
- host1.tap0.down()
- host1.br0 = BridgeDevice()
- host1.br0.slave_add(host1.tap0)
-
- host2.eth0.down()
- host2.tap0.down()
- host2.br0 = BridgeDevice()
- host2.br0.slave_add(host2.tap0)
+ for host in [host1, host2]:
+ host.eth0.down()
+ host.tap0.down()
+ host.br0 = BridgeDevice()
+ host.br0.slave_add(host.tap0)
guest1.eth0.down()
@@ -52,12 +48,9 @@ class VirtualBridgeVlanInHostMirroredRecipe(BaseEnrtRecipe):
host1_vlan_args0 = dict(realdev=host1.eth0, vlan_id=10, master=host1.br0)
host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10, master=host2.br0)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- host2.tap0.mtu = self.params.mtu
- host2.br0.mtu = self.params.mtu
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.mtu = self.params.mtu
guest1.eth0.mtu = self.params.mtu
guest2.eth0.mtu = self.params.mtu
for vlan_args in (host1_vlan_args0, host2_vlan_args0):
@@ -75,19 +68,13 @@ class VirtualBridgeVlanInHostMirroredRecipe(BaseEnrtRecipe):
host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
host2.br0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- guest1.eth0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.eth0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
- guest2.eth0.ip_add(ipaddress(net_addr_1 + ".4/24"))
- guest2.eth0.ip_add(ipaddress(net_addr6_1 + "::4/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.vlan0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.tap0.up()
- host2.vlan0.up()
- host2.br0.up()
+ for i, guest in enumerate([guest1, guest2]):
+ guest.eth0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
"/24"))
+ guest.eth0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
"/64"))
+
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.vlan0, host.br0]:
+ dev.up()
guest1.eth0.up()
guest2.eth0.up()
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlanInHostRecipe.py
b/lnst/Recipes/ENRT/VirtualBridgeVlanInHostRecipe.py
index b5d4677..90ba81d 100644
--- a/lnst/Recipes/ENRT/VirtualBridgeVlanInHostRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualBridgeVlanInHostRecipe.py
@@ -43,11 +43,8 @@ class VirtualBridgeVlanInHostRecipe(BaseEnrtRecipe):
host1_vlan_args0 = dict(realdev=host1.eth0, vlan_id=10, master=host1.br0)
host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- guest1.eth0.mtu = self.params.mtu
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0, guest1.eth0]:
+ dev.mtu = self.params.mtu
for vlan_args in (host1_vlan_args0, host2_vlan_args0):
vlan_args["mtu"] = self.params.mtu
@@ -62,18 +59,13 @@ class VirtualBridgeVlanInHostRecipe(BaseEnrtRecipe):
net_addr6_1 = "fc00:0:0:1"
host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24"))
- host2.vlan0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.vlan0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
- guest1.eth0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.eth0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.vlan0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.vlan0.up()
- guest1.eth0.up()
+ for i, dev in enumerate([host2.vlan0, guest1.eth0]):
+ dev.ip_add(ipaddress(net_addr_1 + "." + str(i+2) +
"/24"))
+ dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i+2) +
"/64"))
+
+ for dev in [host1.eth0, host1.tap0, host1.vlan0, host1.br0,
+ host2.eth0, host2.vlan0, guest1.eth0]:
+ dev.up()
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py
b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py
index d40f3a0..2d7058a 100644
--- a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py
@@ -49,10 +49,8 @@ class VirtualBridgeVlansOverBondRecipe(BaseEnrtRecipe):
host1, host2, guest1, guest2, guest3, guest4 = self.matched.host1,
self.matched.host2, self.matched.guest1, self.matched.guest2, self.matched.guest3,
self.matched.guest4
for host in [host1, host2]:
- host.eth0.down()
- host.eth1.down()
- host.tap0.down()
- host.tap1.down()
+ for dev in [host.eth0, host.eth1, host.tap0, host.tap1]:
+ dev.down()
host.bond0 = BondDevice(mode=self.params.bonding_mode,
miimon=self.params.miimon_value)
host.bond0.slave_add(host.eth0)
host.bond0.slave_add(host.eth1)
@@ -70,11 +68,8 @@ class VirtualBridgeVlansOverBondRecipe(BaseEnrtRecipe):
host2_vlan_args1 = dict(realdev=host2.bond0, vlan_id=20, master=host2.br1)
if "mtu" in self.params:
for host in [host1, host2]:
- host.bond0.mtu = self.params.mtu
- host.tap0.mtu = self.params.mtu
- host.tap1.mtu = self.params.mtu
- host.br0.mtu = self.params.mtu
- host.br1.mtu = self.params.mtu
+ for dev in [host.bond0, host.tap0, host.tap1, host.br0, host.br1]:
+ dev.mtu = self.params.mtu
for guest in [guest1, guest2, guest3, guest4]:
guest.eth0.mtu = self.params.mtu
for vlan_args in (host1_vlan_args0, host1_vlan_args1,
@@ -105,18 +100,12 @@ class VirtualBridgeVlansOverBondRecipe(BaseEnrtRecipe):
guest_b.eth0.ip_add(ipaddress(net_addr_2 + "." + str(n+1) +
"/24"))
guest_b.eth0.ip_add(ipaddress(net_addr6_2 + "::" + str(n+1) +
"/64"))
- for host, guest_a, guest_b in [(host1, guest1, guest2), (host2, guest3,
guest4)]:
- host.eth0.up()
- host.eth1.up()
- host.tap0.up()
- host.tap1.up()
- host.bond0.up()
- host.vlan0.up()
- host.vlan1.up()
- host.br0.up()
- host.br1.up()
- guest_a.eth0.up()
- guest_b.eth0.up()
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.eth1, host.tap0, host.tap1, host.bond0,
+ host.vlan0, host.vlan1, host.br0, host.br1]:
+ dev.up()
+ for guest in [guest1, guest2, guest3, guest4]:
+ guest.eth0.up()
#TODO better service handling through HostAPI
if "perf_tool_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestMirroredRecipe.py
b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestMirroredRecipe.py
index 61510af..1e66afa 100644
--- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestMirroredRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestMirroredRecipe.py
@@ -50,12 +50,9 @@ class VirtualOvsBridgeVlanInGuestMirroredRecipe(BaseEnrtRecipe):
guest1_vlan_args0 = dict(realdev=guest1.eth0, vlan_id=10)
guest2_vlan_args0 = dict(realdev=guest2.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- host2.tap0.mtu = self.params.mtu
- host2.br0.mtu = self.params.mtu
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.mtu = self.params.mtu
guest1.eth0.mtu = self.params.mtu
guest2.eth0.mtu = self.params.mtu
for vlan_args in (guest1_vlan_args0, guest2_vlan_args0):
@@ -72,22 +69,16 @@ class VirtualOvsBridgeVlanInGuestMirroredRecipe(BaseEnrtRecipe):
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
+ for i, guest in enumerate([guest1, guest2]):
+ guest.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
"/24"))
+ guest.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
"/64"))
- guest1.vlan0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.vlan0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
- guest2.vlan0.ip_add(ipaddress(net_addr_1 + ".4/24"))
- guest2.vlan0.ip_add(ipaddress(net_addr6_1 + "::4/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.tap0.up()
- host2.br0.up()
- guest1.eth0.up()
- guest1.vlan0.up()
- guest2.eth0.up()
- guest2.vlan0.up()
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.up()
+ for guest in [guest1, guest2]:
+ guest.eth0.up()
+ guest.vlan0.up()
#TODO better service handling through HostAPI
if "perf_tool_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestRecipe.py
b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestRecipe.py
index 8f628b6..6bb5da6 100644
--- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInGuestRecipe.py
@@ -31,11 +31,10 @@ class VirtualOvsBridgeVlanInGuestRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1 = self.matched.host1, self.matched.host2,
self.matched.guest1
- host1.eth0.down()
- host1.tap0.down()
host1.br0 = OvsBridgeDevice()
- host1.br0.port_add(host1.eth0)
- host1.br0.port_add(host1.tap0)
+ for dev in [host1.eth0, host1.tap0]:
+ dev.down()
+ host1.br0.port_add(dev)
host2.eth0.down()
@@ -44,11 +43,8 @@ class VirtualOvsBridgeVlanInGuestRecipe(BaseEnrtRecipe):
host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10)
guest1_vlan_args0 = dict(realdev=guest1.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- guest1.eth0.mtu = self.params.mtu
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0, guest1.eth0]:
+ dev.mtu = self.params.mtu
for vlan_args in (host2_vlan_args0, guest1_vlan_args0):
vlan_args["mtu"] = self.params.mtu
@@ -63,19 +59,13 @@ class VirtualOvsBridgeVlanInGuestRecipe(BaseEnrtRecipe):
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
+ for i, machine in enumerate([host2, guest1]):
+ machine.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+2) +
"/24"))
+ machine.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+2) +
"/64"))
- host2.vlan0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.vlan0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
- guest1.vlan0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.vlan0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.vlan0.up()
- guest1.eth0.up()
- guest1.vlan0.up()
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0,
+ host2.vlan0, guest1.eth0, guest1.vlan0]:
+ dev.up()
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostMirroredRecipe.py
b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostMirroredRecipe.py
index 734f5c2..70d10a0 100644
--- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostMirroredRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostMirroredRecipe.py
@@ -35,17 +35,12 @@ class VirtualOvsBridgeVlanInHostMirroredRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1, guest2 = self.matched.host1, self.matched.host2,
self.matched.guest1, self.matched.guest2
- host1.eth0.down()
- host1.tap0.down()
- host1.br0 = OvsBridgeDevice()
- host1.br0.port_add(host1.eth0)
- host1.br0.port_add(host1.tap0, tag="10")
-
- host2.eth0.down()
- host2.tap0.down()
- host2.br0 = OvsBridgeDevice()
- host2.br0.port_add(host2.eth0)
- host2.br0.port_add(host2.tap0, tag="10")
+ for host in [host1, host2]:
+ host.br0 = OvsBridgeDevice()
+ host.eth0.down()
+ host.tap0.down()
+ host.br0.port_add(host.eth0)
+ host.br0.port_add(host.tap0, tag="10")
guest1.eth0.down()
@@ -58,29 +53,21 @@ class VirtualOvsBridgeVlanInHostMirroredRecipe(BaseEnrtRecipe):
configuration.endpoint2 = guest2.eth0
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- host2.tap0.mtu = self.params.mtu
- host2.br0.mtu = self.params.mtu
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.mtu = self.params.mtu
guest1.eth0.mtu = self.params.mtu
guest2.eth0.mtu = self.params.mtu
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
+ for i, guest in enumerate([guest1, guest2]):
+ guest.eth0.ip_add(ipaddress(net_addr_1 + "." + str(i+3) +
"/24"))
+ guest.eth0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+3) +
"/64"))
- guest1.eth0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.eth0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
- guest2.eth0.ip_add(ipaddress(net_addr_1 + ".4/24"))
- guest2.eth0.ip_add(ipaddress(net_addr6_1 + "::4/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.tap0.up()
- host2.br0.up()
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.tap0, host.br0]:
+ dev.up()
guest1.eth0.up()
guest2.eth0.up()
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostRecipe.py
b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostRecipe.py
index ce646ec..1f55598 100644
--- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlanInHostRecipe.py
@@ -43,12 +43,8 @@ class VirtualOvsBridgeVlanInHostRecipe(BaseEnrtRecipe):
host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10)
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- guest1.eth0.mtu = self.params.mtu
-
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0, guest1.eth0]:
+ dev.mtu = self.params.mtu
host2_vlan_args0["mtu"] = self.params.mtu
host2.vlan0 = VlanDevice(**host2_vlan_args0)
@@ -61,18 +57,12 @@ class VirtualOvsBridgeVlanInHostRecipe(BaseEnrtRecipe):
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
+ for i, dev in enumerate([host2.vlan0, guest1.eth0]):
+ dev.ip_add(ipaddress(net_addr_1 + "." + str(i+2) +
"/24"))
+ dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i+2) +
"/64"))
- host2.vlan0.ip_add(ipaddress(net_addr_1 + ".2/24"))
- host2.vlan0.ip_add(ipaddress(net_addr6_1 + "::2/64"))
- guest1.eth0.ip_add(ipaddress(net_addr_1 + ".3/24"))
- guest1.eth0.ip_add(ipaddress(net_addr6_1 + "::3/64"))
-
- host1.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- host2.eth0.up()
- host2.vlan0.up()
- guest1.eth0.up()
+ for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0, host2.vlan0,
guest1.eth0]:
+ dev.up()
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py
b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py
index bba905b..cbd3b0b 100644
--- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py
+++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py
@@ -48,28 +48,15 @@ class VirtualOvsBridgeVlansOverBondRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1, guest2, guest3, guest4 = self.matched.host1,
self.matched.host2, self.matched.guest1, self.matched.guest2, self.matched.guest3,
self.matched.guest4
- host1.eth0.down()
- host1.eth1.down()
- host1.tap0.down()
- host1.tap1.down()
- host1.br0 = OvsBridgeDevice()
- for dev, tag in [(host1.tap0, "10"), (host1.tap1, "20")]:
- host1.br0.port_add(dev, tag=tag)
+ for host, port_name in [(host1, "bond_port1"), (host2,
"bond_port2")]:
+ for dev in [host.eth0, host.eth1, host.tap0, host.tap1]:
+ dev.down()
+ host.br0 = OvsBridgeDevice()
+ for dev, tag in [(host.tap0, "10"), (host.tap1, "20")]:
+ host.br0.port_add(dev, tag=tag)
- #miimon cannot be set due to colon in argument name -->
other_config:bond-miimon-interval
-
#https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/12/html/advanced_overcloud_customization/appe-bonding_options
- host1.br0.bond_add("bond_host1", (host1.eth0, host1.eth1),
bond_mode=self.params.bonding_mode)
-
- host2.eth0.down()
- host2.eth1.down()
- host2.tap0.down()
- host2.tap1.down()
- host2.br0 = OvsBridgeDevice()
-
- for dev, tag in [(host2.tap0, "10"), (host2.tap1, "20")]:
- host2.br0.port_add(dev, tag=tag)
-
- host2.br0.bond_add("bond_host2", (host2.eth0, host2.eth1),
bond_mode=self.params.bonding_mode)
+ #miimon cannot be set due to colon in argument name -->
other_config:bond-miimon-interval
+ host.br0.bond_add(port_name, (host.eth0, host.eth1),
bond_mode=self.params.bonding_mode)
guest1.eth0.down()
@@ -86,20 +73,11 @@ class VirtualOvsBridgeVlansOverBondRecipe(BaseEnrtRecipe):
configuration.endpoint2 = guest3.eth0
if "mtu" in self.params:
- host1.eth0.mtu = self.params.mtu
- host1.eth1.mtu = self.params.mtu
- host1.tap0.mtu = self.params.mtu
- host1.tap1.mtu = self.params.mtu
- host1.br0.mtu = self.params.mtu
- host2.eth0.mtu = self.params.mtu
- host2.eth1.mtu = self.params.mtu
- host2.tap0.mtu = self.params.mtu
- host2.tap1.mtu = self.params.mtu
- host2.br0.mtu = self.params.mtu
- guest1.eth0.mtu = self.params.mtu
- guest2.eth0.mtu = self.params.mtu
- guest3.eth0.mtu = self.params.mtu
- guest4.eth0.mtu = self.params.mtu
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.eth1, host.tap0, host.tap1, host.br0]:
+ dev.mtu = self.params.mtu
+ for guest in [guest1, guest2, guest3, guest4]:
+ guest.eth0.mtu = self.params.mtu
net_addr_1 = "192.168.10"
net_addr6_1 = "fc00:0:0:1"
@@ -114,20 +92,11 @@ class VirtualOvsBridgeVlansOverBondRecipe(BaseEnrtRecipe):
guest.eth0.ip_add(ipaddress(net_addr_2 + "." + str (i+1) +
"/24"))
guest.eth0.ip_add(ipaddress(net_addr6_2 + "::" + str (i+1) +
"/64"))
- host1.eth0.up()
- host1.eth1.up()
- host1.tap0.up()
- host1.tap1.up()
- host1.br0.up()
- host2.eth0.up()
- host2.eth1.up()
- host2.tap0.up()
- host2.tap1.up()
- host2.br0.up()
- guest1.eth0.up()
- guest2.eth0.up()
- guest3.eth0.up()
- guest4.eth0.up()
+ for host in [host1, host2]:
+ for dev in [host.eth0, host.eth1, host.tap0, host.tap1, host.br0]:
+ dev.up()
+ for guest in [guest1, guest2, guest3, guest4]:
+ guest.eth0.up()
#TODO better service handling through HostAPI
if "perf_tool_cpu" in self.params:
diff --git a/lnst/Recipes/ENRT/VlansOverBondRecipe.py
b/lnst/Recipes/ENRT/VlansOverBondRecipe.py
index 9c788c1..61dfe57 100644
--- a/lnst/Recipes/ENRT/VlansOverBondRecipe.py
+++ b/lnst/Recipes/ENRT/VlansOverBondRecipe.py
@@ -31,10 +31,9 @@ class VlansOverBondRecipe(BaseEnrtRecipe):
host1, host2 = self.matched.host1, self.matched.host2
host1.bond0 = BondDevice(mode=self.params.bonding_mode,
miimon=self.params.miimon_value)
- host1.eth0.down()
- host1.eth1.down()
- host1.bond0.slave_add(host1.eth0)
- host1.bond0.slave_add(host1.eth1)
+ for dev in [host1.eth0, host1.eth1]:
+ dev.down()
+ host1.bond0.slave_add(dev)
host1_vlan_args0 = dict(realdev=host1.bond0, vlan_id=10)
host1_vlan_args1 = dict(realdev=host1.bond0, vlan_id=20)
@@ -69,14 +68,9 @@ class VlansOverBondRecipe(BaseEnrtRecipe):
host.vlan1.ip_add(ipaddress(net_addr_2 + "." + str(i+1) +
"/24"))
host.vlan1.ip_add(ipaddress(net_addr6_2 + "::" + str(i+1) +
"/64"))
- host1.eth0.up()
- host1.eth1.up()
- host1.bond0.up()
- host1.vlan0.up()
- host1.vlan1.up()
- host2.eth0.up()
- host2.vlan0.up()
- host2.vlan1.up()
+ for dev in [host1.eth0, host1.eth1, host1.bond0, host1.vlan0,
+ host1.vlan1, host2.eth0, host2.vlan0, host2.vlan1]:
+ dev.up()
if "adaptive_rx_coalescing" in self.params:
for dev in [host1.eth0, host1.eth1, host2.eth0]:
diff --git a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py
b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py
index a470512..77ac4e2 100644
--- a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py
+++ b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py
@@ -28,13 +28,12 @@ class VlansOverTeamRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2 = self.matched.host1, self.matched.host2
- host1.eth0.down()
- host1.eth1.down()
#The config argument needs to be used with a team device normally (e.g to
specify
#the runner mode), but it is not used here due to a bug in the TeamDevice module
host1.team0 = TeamDevice()
- host1.team0.slave_add(host1.eth0)
- host1.team0.slave_add(host1.eth1)
+ for dev in [host1.eth0, host1.eth1]:
+ dev.down()
+ host1.team0.slave_add(dev)
host1_vlan_args0 = dict(realdev=host1.team0, vlan_id=10)
host1_vlan_args1 = dict(realdev=host1.team0, vlan_id=20)
@@ -69,14 +68,9 @@ class VlansOverTeamRecipe(BaseEnrtRecipe):
host.vlan1.ip_add(ipaddress(net_addr_2 + "." + str(i+1) +
"/24"))
host.vlan1.ip_add(ipaddress(net_addr6_2 + "::" + str(i+1) +
"/64"))
- host1.eth0.up()
- host1.eth1.up()
- host1.team0.up()
- host1.vlan0.up()
- host1.vlan1.up()
- host2.eth0.up()
- host2.vlan0.up()
- host2.vlan1.up()
+ for dev in [host1.eth0, host1.eth1, host1.team0, host1.vlan0,
+ host1.vlan1, host2.eth0, host2.vlan0, host2.vlan1]:
+ dev.up()
if "adaptive_rx_coalescing" in self.params:
for dev in [host1.eth0, host1.eth1, host2.eth0]:
diff --git a/lnst/Recipes/ENRT/VlansRecipe.py b/lnst/Recipes/ENRT/VlansRecipe.py
index 8e20535..89a748a 100644
--- a/lnst/Recipes/ENRT/VlansRecipe.py
+++ b/lnst/Recipes/ENRT/VlansRecipe.py
@@ -60,13 +60,9 @@ class VlansRecipe(BaseEnrtRecipe):
host.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+1) +
"/64"))
host.vlan1.ip_add(ipaddress(net_addr_2 + "." + str(i+1) +
"/24"))
host.vlan1.ip_add(ipaddress(net_addr6_2 + "::" + str(i+1) +
"/64"))
-
- host1.eth0.up()
- host1.vlan0.up()
- host1.vlan1.up()
- host2.eth0.up()
- host2.vlan0.up()
- host2.vlan1.up()
+ host.eth0.up()
+ host.vlan0.up()
+ host.vlan1.up()
if "adaptive_rx_coalescing" in self.params:
for host in [host1, host2]:
diff --git a/lnst/Recipes/ENRT/VxlanMulticastRecipe.py
b/lnst/Recipes/ENRT/VxlanMulticastRecipe.py
index b489278..644c7f8 100644
--- a/lnst/Recipes/ENRT/VxlanMulticastRecipe.py
+++ b/lnst/Recipes/ENRT/VxlanMulticastRecipe.py
@@ -21,9 +21,8 @@ class VxlanMulticastRecipe(BaseEnrtRecipe):
def test_wide_configuration(self):
host1, host2, guest1 = self.matched.host1, self.matched.host2,
self.matched.guest1
- for machine in [host1, host2, guest1]:
- machine.eth0.down()
- host1.tap0.down()
+ for dev in [host1.eth0, host2.eth0, guest1.eth0, host1.tap0]:
+ dev.down()
net_addr = "192.168.0"
vxlan_net_addr = "192.168.100"
@@ -53,12 +52,9 @@ class VxlanMulticastRecipe(BaseEnrtRecipe):
configuration.endpoint1 = host1.vxlan0
configuration.endpoint2 = host2.vxlan0
- for machine in [host1, host2, guest1]:
- machine.eth0.up()
- host1.tap0.up()
- host1.br0.up()
- for machine in [host1, host2, guest1]:
- machine.vxlan0.up()
+ for dev in [host1.eth0, host2.eth0, guest1.eth0, host1.tap0,
+ host1.br0, host1.vxlan0, host2.vxlan0, guest1.vxlan0]:
+ dev.up()
#TODO better service handling through HostAPI
if "dev_intr_cpu" in self.params:
--
2.17.1