Skip to content

Commit 738bb9f

Browse files
authored
debian: minimize differences between Ubuntu (#87)
* debian: minimize differences between Ubuntu Lets make the generated configs standardized * debian: remove Ubuntu variations from tests
1 parent ffe994e commit 738bb9f

File tree

2 files changed

+69
-85
lines changed

2 files changed

+69
-85
lines changed

packetnetworking/distros/debian/templates/bonded/etc_network_interfaces.j2

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
auto lo
22
iface lo inet loopback
33

4-
{% if osinfo.distro == 'ubuntu' %}
54
{% for iface in interfaces | sort(attribute="name") %}
65

76
auto {{ iface.name }}
@@ -11,7 +10,6 @@ iface {{ iface.name }} inet manual
1110
{% endif %}
1211
bond-master bond0
1312
{% endfor %}
14-
{% endif %}
1513

1614
{% for bond in bonds | sort %}
1715

@@ -36,7 +34,7 @@ iface {{ bond }} inet {% if bond == "bond0" %}static{% else %}manual{% endif %}
3634
bond-mode {{ net.bonding.mode }}
3735
bond-updelay 200
3836
bond-xmit_hash_policy layer3+4
39-
{% if osinfo.distro == 'ubuntu' and net.bonding.mode == 4 %}
37+
{% if net.bonding.mode == 4 %}
4038
bond-lacp-rate 1
4139
{% endif %}
4240
bond-slaves {{ bonds[bond] | map(attribute='name') | sort | join(' ') }}

packetnetworking/distros/debian/test_bonded.py

Lines changed: 68 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,21 @@ def test_public_bonded_task_etc_network_interfaces(
2929
iface lo inet loopback
3030
"""
3131
result = dedent(partial)
32-
if distro == "ubuntu":
33-
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
34-
if iface.name != builder.network.interfaces[0].name:
35-
partial = f"""
36-
auto {iface.name}
37-
iface {iface.name} inet manual
38-
pre-up sleep 4
39-
bond-master bond0
40-
"""
41-
else:
42-
partial = f"""
43-
auto {iface.name}
44-
iface {iface.name} inet manual
45-
bond-master bond0
46-
"""
47-
result += dedent(partial)
32+
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
33+
if iface.name != builder.network.interfaces[0].name:
34+
partial = f"""
35+
auto {iface.name}
36+
iface {iface.name} inet manual
37+
pre-up sleep 4
38+
bond-master bond0
39+
"""
40+
else:
41+
partial = f"""
42+
auto {iface.name}
43+
iface {iface.name} inet manual
44+
bond-master bond0
45+
"""
46+
result += dedent(partial)
4847
partial = f"""
4948
auto bond0
5049
iface bond0 inet static
@@ -60,8 +59,7 @@ def test_public_bonded_task_etc_network_interfaces(
6059
bond-xmit_hash_policy layer3+4
6160
"""
6261
result += dedent(partial)
63-
if distro == "ubuntu":
64-
result += " bond-lacp-rate 1\n"
62+
result += " bond-lacp-rate 1\n"
6563
result += f""" bond-slaves {' '.join(sorted(nic.name for nic in builder.network.bonds["bond0"]))}\n"""
6664

6765
partial = f"""
@@ -93,8 +91,7 @@ def test_public_bonded_task_etc_network_interfaces(
9391
bond-xmit_hash_policy layer3+4
9492
"""
9593
result += dedent(partial)
96-
if distro == "ubuntu":
97-
result += " bond-lacp-rate 1\n"
94+
result += " bond-lacp-rate 1\n"
9895
result += f" bond-slaves {' '.join(sorted(nic.name for nic in members))}\n"
9996
assert tasks["etc/network/interfaces"] == result
10097

@@ -117,22 +114,21 @@ def test_private_bonded_task_etc_network_interfaces(
117114
iface lo inet loopback
118115
"""
119116
result = dedent(partial)
120-
if distro == "ubuntu":
121-
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
122-
if iface.name != builder.network.interfaces[0].name:
123-
partial = f"""
124-
auto {iface.name}
125-
iface {iface.name} inet manual
126-
pre-up sleep 4
127-
bond-master bond0
128-
"""
129-
else:
130-
partial = f"""
131-
auto {iface.name}
132-
iface {iface.name} inet manual
133-
bond-master bond0
134-
"""
135-
result += dedent(partial)
117+
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
118+
if iface.name != builder.network.interfaces[0].name:
119+
partial = f"""
120+
auto {iface.name}
121+
iface {iface.name} inet manual
122+
pre-up sleep 4
123+
bond-master bond0
124+
"""
125+
else:
126+
partial = f"""
127+
auto {iface.name}
128+
iface {iface.name} inet manual
129+
bond-master bond0
130+
"""
131+
result += dedent(partial)
136132
partial = f"""
137133
auto bond0
138134
iface bond0 inet static
@@ -148,8 +144,7 @@ def test_private_bonded_task_etc_network_interfaces(
148144
bond-xmit_hash_policy layer3+4
149145
"""
150146
result += dedent(partial)
151-
if distro == "ubuntu":
152-
result += " bond-lacp-rate 1\n"
147+
result += " bond-lacp-rate 1\n"
153148
result += f" bond-slaves {' '.join(sorted(nic.name for nic in builder.network.bonds['bond0']))}\n"
154149

155150
for bond, members in builder.network.bonds.items():
@@ -166,8 +161,7 @@ def test_private_bonded_task_etc_network_interfaces(
166161
bond-xmit_hash_policy layer3+4
167162
"""
168163
result += dedent(partial)
169-
if distro == "ubuntu":
170-
result += " bond-lacp-rate 1\n"
164+
result += " bond-lacp-rate 1\n"
171165
result += f" bond-slaves {' '.join(sorted(nic.name for nic in members))}\n"
172166
assert tasks["etc/network/interfaces"] == result
173167

@@ -190,22 +184,21 @@ def test_public_bonded_task_etc_network_interfaces_with_custom_private_ip_space(
190184
iface lo inet loopback
191185
"""
192186
result = dedent(partial)
193-
if distro == "ubuntu":
194-
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
195-
if iface.name != builder.network.interfaces[0].name:
196-
partial = f"""
197-
auto {iface.name}
198-
iface {iface.name} inet manual
199-
pre-up sleep 4
200-
bond-master bond0
201-
"""
202-
else:
203-
partial = f"""
204-
auto {iface.name}
205-
iface {iface.name} inet manual
206-
bond-master bond0
207-
"""
208-
result += dedent(partial)
187+
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
188+
if iface.name != builder.network.interfaces[0].name:
189+
partial = f"""
190+
auto {iface.name}
191+
iface {iface.name} inet manual
192+
pre-up sleep 4
193+
bond-master bond0
194+
"""
195+
else:
196+
partial = f"""
197+
auto {iface.name}
198+
iface {iface.name} inet manual
199+
bond-master bond0
200+
"""
201+
result += dedent(partial)
209202
partial = f"""
210203
auto bond0
211204
iface bond0 inet static
@@ -221,9 +214,7 @@ def test_public_bonded_task_etc_network_interfaces_with_custom_private_ip_space(
221214
bond-xmit_hash_policy layer3+4
222215
"""
223216
result += dedent(partial)
224-
if distro == "ubuntu":
225-
result += " bond-lacp-rate 1\n"
226-
217+
result += " bond-lacp-rate 1\n"
227218
result += f""" bond-slaves {' '.join(sorted(nic.name for nic in builder.network.bonds["bond0"]))}\n"""
228219
partial = f"""
229220
iface bond0 inet6 static
@@ -256,8 +247,7 @@ def test_public_bonded_task_etc_network_interfaces_with_custom_private_ip_space(
256247
bond-xmit_hash_policy layer3+4
257248
"""
258249
result += dedent(partial)
259-
if distro == "ubuntu":
260-
result += " bond-lacp-rate 1\n"
250+
result += " bond-lacp-rate 1\n"
261251
result += f" bond-slaves {' '.join(sorted(nic.name for nic in members))}\n"
262252
assert tasks["etc/network/interfaces"] == result
263253

@@ -280,22 +270,21 @@ def test_private_bonded_task_etc_network_interfaces_with_custom_private_ip_space
280270
iface lo inet loopback
281271
"""
282272
result = dedent(partial)
283-
if distro == "ubuntu":
284-
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
285-
if iface.name != builder.network.interfaces[0].name:
286-
partial = f"""
287-
auto {iface.name}
288-
iface {iface.name} inet manual
289-
pre-up sleep 4
290-
bond-master bond0
291-
"""
292-
else:
293-
partial = f"""
294-
auto {iface.name}
295-
iface {iface.name} inet manual
296-
bond-master bond0
297-
"""
298-
result += dedent(partial)
273+
for iface in sorted(builder.network.interfaces, key=lambda iface: iface.name):
274+
if iface.name != builder.network.interfaces[0].name:
275+
partial = f"""
276+
auto {iface.name}
277+
iface {iface.name} inet manual
278+
pre-up sleep 4
279+
bond-master bond0
280+
"""
281+
else:
282+
partial = f"""
283+
auto {iface.name}
284+
iface {iface.name} inet manual
285+
bond-master bond0
286+
"""
287+
result += dedent(partial)
299288
partial = f"""
300289
auto bond0
301290
iface bond0 inet static
@@ -311,9 +300,7 @@ def test_private_bonded_task_etc_network_interfaces_with_custom_private_ip_space
311300
bond-xmit_hash_policy layer3+4
312301
"""
313302
result += dedent(partial)
314-
if distro == "ubuntu":
315-
result += " bond-lacp-rate 1\n"
316-
303+
result += " bond-lacp-rate 1\n"
317304
result += f""" bond-slaves {' '.join(sorted(nic.name for nic in builder.network.bonds["bond0"]))}\n"""
318305

319306
for bond, members in builder.network.bonds.items():
@@ -330,8 +317,7 @@ def test_private_bonded_task_etc_network_interfaces_with_custom_private_ip_space
330317
bond-xmit_hash_policy layer3+4
331318
"""
332319
result += dedent(partial)
333-
if distro == "ubuntu":
334-
result += " bond-lacp-rate 1\n"
320+
result += " bond-lacp-rate 1\n"
335321
result += f" bond-slaves {' '.join(sorted(nic.name for nic in members))}\n"
336322
assert tasks["etc/network/interfaces"] == result
337323

0 commit comments

Comments
 (0)