scaleway_compute: check image on get instead of list (#67655)
* fix scaleway_compute: check image on get instead of list * add changelog Signed-off-by: Alexis Camilleri <acamilleri@scaleway.com>
This commit is contained in:
parent
2dadc259d3
commit
feeb380649
2 changed files with 6 additions and 7 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- 'scaleway_compute(check_image_id): use get image instead loop on first page of images results'
|
|
@ -178,14 +178,11 @@ SCALEWAY_TRANSITIONS_STATES = (
|
|||
|
||||
|
||||
def check_image_id(compute_api, image_id):
|
||||
response = compute_api.get(path="images")
|
||||
response = compute_api.get(path="images/%s" % image_id)
|
||||
|
||||
if response.ok and response.json:
|
||||
image_ids = [image["id"] for image in response.json["images"]]
|
||||
if image_id not in image_ids:
|
||||
compute_api.module.fail_json(msg='Error in getting image %s on %s' % (image_id, compute_api.module.params.get('api_url')))
|
||||
else:
|
||||
compute_api.module.fail_json(msg="Error in getting images from: %s" % compute_api.module.params.get('api_url'))
|
||||
if not response.ok:
|
||||
msg = 'Error in getting image %s on %s : %s' % (image_id, compute_api.module.params.get('api_url'), response.json)
|
||||
compute_api.module.fail_json(msg=msg)
|
||||
|
||||
|
||||
def fetch_state(compute_api, server):
|
||||
|
|
Loading…
Reference in a new issue