Skip to content

Commit 548b12f

Browse files
zmcVaibhav Mahajan
authored andcommitted
maas: Correct image names
Signed-off-by: Zack Cerza <zack@cerza.org>
1 parent 902d8c1 commit 548b12f

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

teuthology/provision/maas.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ def get_machines_data(self, interval: int = 3, timeout: int = 30) -> Dict[str, A
193193
)
194194
return resp[0]
195195

196+
def get_image_name(self) -> str:
197+
match self.os_type:
198+
case 'ubuntu':
199+
os_version = OS._version_to_codename(self.os_type, self.os_version)
200+
return f"{self.os_type}/{os_version}"
201+
case 'centos':
202+
os_version = self.os_version.replace('.', '-')
203+
return f"{self.os_type}/{self.os_type}{os_version}"
204+
return f"{self.os_type}/{self.os_version}"
205+
196206
def get_image_data(self) -> Dict[str, Any]:
197207
"""Locate the image we want to use
198208
@@ -202,7 +212,7 @@ def get_image_data(self) -> Dict[str, Any]:
202212
if len(resp) == 0:
203213
raise RuntimeError("MaaS has no images available")
204214

205-
name = self._normalize_image_name()
215+
name = self.get_image_name()
206216
for image in resp:
207217
if image["name"] == name and self.cpu_arch in image["architecture"]:
208218
return image
@@ -362,22 +372,6 @@ def release(self) -> None:
362372
self.log.info(f"Releasing machine '{self.shortname}'")
363373
self.release_machine()
364374

365-
def _normalize_image_name(self) -> str:
366-
match self.os_type:
367-
case "ubuntu":
368-
os_version = OS._version_to_codename(self.os_type, self.os_version)
369-
return f"{self.os_type}/{os_version}"
370-
371-
case "centos":
372-
os_version = self.os_version.replace('.', '-')
373-
return f"{self.os_type}/{self.os_type}{os_version}"
374-
375-
case "rocky":
376-
_os_version = self.os_version.split('.')[0]
377-
return f"rocky{_os_version}"
378-
379-
return f"{self.os_type}/{self.os_version}"
380-
381375
def _get_user_data(self) -> Optional[io.BytesIO]:
382376
"""Get user data for cloud-init
383377

0 commit comments

Comments
 (0)