Skip to content

Commit 9c8f5e1

Browse files
committed
Fixed spawn always spawning ubuntu-25
Ticket: ENT-13314 Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent a7d7c1a commit 9c8f5e1

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

cf_remote/spawn.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,23 @@ def get_cloud_driver(provider, creds, region):
348348
# image for that platform and version.
349349
def _get_image_criteria(platform_name):
350350
log.debug("Looking for AWS AMI for platform_name '%s'" % (platform_name))
351-
platform = platform_name.split("-")[0]
351+
platform_parts = platform_name.split("-")
352+
platform = platform_parts[0]
352353
if platform == "ubuntu":
353-
if platform_name.count("-") > 0:
354-
platform_version = ".".join(platform_name.split("-")[1:-1])
354+
if len(platform_parts) == 2:
355+
platform_version = platform_parts[1]
356+
elif len(platform_parts) > 2:
357+
platform_version = ".".join(platform_parts[1:-1])
355358
else:
356359
platform_version = ""
357360
else:
358-
platform_version = (
359-
platform_name.count("-") > 0 and platform_name.split("-")[1] or "*"
360-
)
361+
platform_version = platform_name.count("-") > 0 and platform_parts[1] or "*"
361362
log.debug(
362363
"Parsed platform_version '%s' from platform_name '%s'"
363364
% (platform_version, platform_name)
364365
)
365-
platform_with_major_version = "-".join(platform_name.split("-")[0:2])
366-
architecture = platform_name.split("-")[-1]
366+
platform_with_major_version = "-".join(platform_parts[0:2])
367+
architecture = platform_parts[-1]
367368
# architecture should be either x64 or arm64
368369
if not (architecture == "x64" or architecture == "arm64"):
369370
# default to x64

0 commit comments

Comments
 (0)