@@ -64,7 +64,8 @@ def test_public_bonded_task_etc_network_interfaces(
6464    result  +=  dedent (partial )
6565    if  distro  ==  "ubuntu" :
6666        result  +=  "    bond-lacp-rate 1\n " 
67-     result  +=  f"""    bond-slaves { ' ' .join ([iface .name  for  iface  in  builder .network .interfaces  if  iface .bond  ==  "bond0" ])} \n """ 
67+     result  +=  f"""    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  builder .network .bonds ["bond0" ]))} \n """ 
68+ 
6869    partial  =  f""" 
6970        iface bond0 inet6 static 
7071            address { ipv6pub .address }  
@@ -79,6 +80,24 @@ def test_public_bonded_task_etc_network_interfaces(
7980            post-down route del -net 10.0.0.0/8 gw { ipv4priv .gateway }  
8081        """ 
8182    result  +=  dedent (partial )
83+ 
84+     for  bond , members  in  builder .network .bonds .items ():
85+         if  bond  ==  "bond0" :
86+             continue 
87+ 
88+         partial  =  f""" 
89+             auto { bond }  
90+             iface { bond }   inet static 
91+                 bond-downdelay 200 
92+                 bond-miimon 100 
93+                 bond-mode { bonding_mode }  
94+                 bond-updelay 200 
95+                 bond-xmit_hash_policy layer3+4 
96+             """ 
97+         result  +=  dedent (partial )
98+         if  distro  ==  "ubuntu" :
99+             result  +=  "    bond-lacp-rate 1\n " 
100+         result  +=  f"    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  members ))} \n " 
82101    assert  tasks ["etc/network/interfaces" ] ==  result 
83102
84103
@@ -135,8 +154,25 @@ def test_private_bonded_task_etc_network_interfaces(
135154    result  +=  dedent (partial )
136155    if  distro  ==  "ubuntu" :
137156        result  +=  "    bond-lacp-rate 1\n " 
138-     result  +=  f"""    bond-slaves { ' ' .join ([iface .name  for  iface  in  builder .network .interfaces  if  iface .bond  ==  "bond0" ])} \n """ 
157+     result  +=  f"    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  builder .network .bonds ['bond0' ]))} \n " 
158+ 
159+     for  bond , members  in  builder .network .bonds .items ():
160+         if  bond  ==  "bond0" :
161+             continue 
139162
163+         partial  =  f""" 
164+             auto { bond }  
165+             iface { bond }   inet static 
166+                 bond-downdelay 200 
167+                 bond-miimon 100 
168+                 bond-mode { bonding_mode }  
169+                 bond-updelay 200 
170+                 bond-xmit_hash_policy layer3+4 
171+             """ 
172+         result  +=  dedent (partial )
173+         if  distro  ==  "ubuntu" :
174+             result  +=  "    bond-lacp-rate 1\n " 
175+         result  +=  f"    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  members ))} \n " 
140176    assert  tasks ["etc/network/interfaces" ] ==  result 
141177
142178
@@ -194,7 +230,7 @@ def test_public_bonded_task_etc_network_interfaces_with_custom_private_ip_space(
194230    if  distro  ==  "ubuntu" :
195231        result  +=  "    bond-lacp-rate 1\n " 
196232
197-     result  +=  f"""    bond-slaves { ' ' .join ([ iface .name  for  iface  in  builder .network .interfaces   if   iface . bond   ==   "bond0" ])} \n """ 
233+     result  +=  f"""    bond-slaves { ' ' .join (sorted ( nic .name  for  nic  in  builder .network .bonds [ "bond0" ]) )} \n """ 
198234    partial  =  f""" 
199235        iface bond0 inet6 static 
200236            address { ipv6pub .address }  
@@ -211,6 +247,24 @@ def test_public_bonded_task_etc_network_interfaces_with_custom_private_ip_space(
211247            post-down route del -net 172.16.0.0/12 gw { ipv4priv .gateway }  
212248        """ 
213249    result  +=  dedent (partial )
250+ 
251+     for  bond , members  in  builder .network .bonds .items ():
252+         if  bond  ==  "bond0" :
253+             continue 
254+ 
255+         partial  =  f""" 
256+             auto { bond }  
257+             iface { bond }   inet static 
258+                 bond-downdelay 200 
259+                 bond-miimon 100 
260+                 bond-mode { bonding_mode }  
261+                 bond-updelay 200 
262+                 bond-xmit_hash_policy layer3+4 
263+             """ 
264+         result  +=  dedent (partial )
265+         if  distro  ==  "ubuntu" :
266+             result  +=  "    bond-lacp-rate 1\n " 
267+         result  +=  f"    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  members ))} \n " 
214268    assert  tasks ["etc/network/interfaces" ] ==  result 
215269
216270
@@ -269,7 +323,25 @@ def test_private_bonded_task_etc_network_interfaces_with_custom_private_ip_space
269323    if  distro  ==  "ubuntu" :
270324        result  +=  "    bond-lacp-rate 1\n " 
271325
272-     result  +=  f"""    bond-slaves { ' ' .join ([iface .name  for  iface  in  builder .network .interfaces  if  iface .bond  ==  "bond0" ])} \n """ 
326+     result  +=  f"""    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  builder .network .bonds ["bond0" ]))} \n """ 
327+ 
328+     for  bond , members  in  builder .network .bonds .items ():
329+         if  bond  ==  "bond0" :
330+             continue 
331+ 
332+         partial  =  f""" 
333+             auto { bond }  
334+             iface { bond }   inet static 
335+                 bond-downdelay 200 
336+                 bond-miimon 100 
337+                 bond-mode { bonding_mode }  
338+                 bond-updelay 200 
339+                 bond-xmit_hash_policy layer3+4 
340+             """ 
341+         result  +=  dedent (partial )
342+         if  distro  ==  "ubuntu" :
343+             result  +=  "    bond-lacp-rate 1\n " 
344+         result  +=  f"    bond-slaves { ' ' .join (sorted (nic .name  for  nic  in  members ))} \n " 
273345    assert  tasks ["etc/network/interfaces" ] ==  result 
274346
275347
0 commit comments