17
17
JAMMY ,
18
18
NOBLE ,
19
19
)
20
- from tests .integration_tests .util import verify_clean_boot , verify_clean_log
20
+ from tests .integration_tests .util import (
21
+ has_netplanlib ,
22
+ verify_clean_boot ,
23
+ verify_clean_log ,
24
+ )
21
25
22
26
# Older Ubuntu series didn't read cloud-init.* config keys
23
27
LXD_NETWORK_CONFIG_KEY = (
@@ -66,13 +70,13 @@ def test_skip(self, client: IntegrationInstance):
66
70
client .execute (
67
71
"mv /var/log/cloud-init.log /var/log/cloud-init.log.bak"
68
72
)
69
- if CURRENT_RELEASE < JAMMY :
73
+ if has_netplanlib (client ):
74
+ assert "Rendered netplan config using netplan python API" in log
75
+ else :
70
76
assert (
71
77
"No netplan python module. Fallback to write"
72
78
" /etc/netplan/50-cloud-init.yaml" in log
73
79
)
74
- else :
75
- assert "Rendered netplan config using netplan python API" in log
76
80
netplan = yaml .safe_load (
77
81
client .execute ("cat /etc/netplan/50-cloud-init.yaml" )
78
82
)
@@ -285,16 +289,7 @@ def test_invalid_network_v2_netplan(session_cloud: IntegrationCloud):
285
289
"config_dict" : config_dict ,
286
290
}
287
291
) as client :
288
- # Netplan python API only available on JAMMY and later
289
- if CURRENT_RELEASE < JAMMY :
290
- assert (
291
- "Skipping netplan schema validation. No netplan API available"
292
- ) in client .read_from_file ("/var/log/cloud-init.log" )
293
- assert (
294
- "Skipping network-config schema validation for version: 2."
295
- " No netplan API available."
296
- ) in client .execute ("cloud-init schema --system" )
297
- else :
292
+ if has_netplanlib (client ):
298
293
assert (
299
294
"network-config failed schema validation! You may run "
300
295
"'sudo cloud-init schema --system' to check the details."
@@ -307,6 +302,14 @@ def test_invalid_network_v2_netplan(session_cloud: IntegrationCloud):
307
302
"# E1: Invalid netplan schema. Error in network definition:"
308
303
" invalid boolean value 'badval"
309
304
) in client .execute ("cloud-init schema --system --annotate" )
305
+ else :
306
+ assert (
307
+ "Skipping netplan schema validation. No netplan API available"
308
+ ) in client .read_from_file ("/var/log/cloud-init.log" )
309
+ assert (
310
+ "Skipping network-config schema validation for version: 2."
311
+ " No netplan API available."
312
+ ) in client .execute ("cloud-init schema --system" )
310
313
311
314
312
315
@pytest .mark .skipif (PLATFORM != "ec2" , reason = "test is ec2 specific" )
0 commit comments