@@ -16,12 +16,12 @@ def get_image_objects(self):
16
16
"""
17
17
images = []
18
18
res = self .ibm_vpc_client .list_images ().get_result ()
19
- filtered_res = filter_images (res ['images' ],[ 'operating_system' , 'architecture' ], "amd" )
19
+ filtered_res = filter_images_ubuntu_amd (res ['images' ])
20
20
images .extend (filtered_res )
21
21
while res .get ('next' ,None ):
22
22
link_to_next = res ['next' ]['href' ].split ('start=' )[1 ].split ('&limit' )[0 ]
23
23
res = self .ibm_vpc_client .list_images (start = link_to_next ).get_result ()
24
- filtered_res = filter_images (res ['images' ],[ 'operating_system' , 'architecture' ], "amd" )
24
+ filtered_res = filter_images_ubuntu_amd (res ['images' ])
25
25
images .extend (filtered_res )
26
26
27
27
return sorted (images ,key = lambda img :img ['name' ])
@@ -31,7 +31,7 @@ def run(self) -> Dict[str, Any]:
31
31
32
32
image_objects = self .get_image_objects ()
33
33
34
- default = find_default ({'name' : 'ibm-ubuntu-20 -04-' }, image_objects , name = 'name' , substring = True )
34
+ default = find_default ({'name' : 'ibm-ubuntu-22 -04-' }, image_objects , name = 'name' , substring = True )
35
35
image_obj = find_obj (image_objects , 'Please choose an image. Ubuntu image is advised as node setup is using apt.' , default = default )
36
36
37
37
if 'ubuntu' not in image_obj ['name' ]:
@@ -47,31 +47,24 @@ def verify(self, base_config):
47
47
image_obj = find_obj (image_objects , 'dummy' , obj_id = image_id )
48
48
else :
49
49
# find first occurrence
50
- image_obj = next ((obj for obj in image_objects if 'ibm-ubuntu-20 -04-' in obj ['name' ]), None )
50
+ image_obj = next ((obj for obj in image_objects if 'ibm-ubuntu-22 -04-' in obj ['name' ]), None )
51
51
52
52
return image_obj ['id' ], image_obj ['minimum_provisioned_size' ], image_obj ['owner_type' ] == 'user'
53
53
54
54
@update_decorator
55
55
def create_default (self ):
56
56
image_objects = self .ibm_vpc_client .list_images ().get_result ()['images' ]
57
57
58
- image_obj = next ((image for image in image_objects if 'ibm-ubuntu-20 -04-' in image ['name' ]), None )
58
+ image_obj = next ((image for image in image_objects if 'ibm-ubuntu-22 -04-' in image ['name' ]), None )
59
59
60
- print (f'Selected \033 [92mUbuntu\033 [0m 20 .04 VM image, { image_obj ["name" ]} ' )
60
+ print (f'Selected \033 [92mUbuntu\033 [0m 22 .04 VM image, { image_obj ["name" ]} ' )
61
61
return image_obj ['id' ], image_obj ['minimum_provisioned_size' ], image_obj ['owner_type' ] == 'user'
62
62
63
- def filter_images (images , fields , value ):
64
- """returns filtered list of images matching the prefix of the specified value of a given field
63
+ def filter_images_ubuntu_amd (images ):
64
+ """returns Ubuntu images with amd architecture
65
65
66
- images (dict)
67
- fields (str) - list of dict possibly multilevel dict fields
68
- value (str) - prefix of required value
66
+ images (dict): image objects
69
67
"""
70
- filtered_images = []
71
- for image in images :
72
- img_copy = image .copy ()
73
- for field in fields :
74
- img_copy = img_copy .get (field )
75
- if img_copy and img_copy .startswith (value ):
76
- filtered_images .append (image )
77
- return filtered_images
68
+ return [image for image in images if 'amd' in
69
+ image ['operating_system' ]['architecture' ]
70
+ and 'ubuntu' in image ['operating_system' ]['name' ]]
0 commit comments