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>
pull/67686/head
Alexis Camilleri 5 years ago committed by GitHub
parent 2dadc259d3
commit feeb380649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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): 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: if not response.ok:
image_ids = [image["id"] for image in response.json["images"]] msg = 'Error in getting image %s on %s : %s' % (image_id, compute_api.module.params.get('api_url'), response.json)
if image_id not in image_ids: compute_api.module.fail_json(msg=msg)
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'))
def fetch_state(compute_api, server): def fetch_state(compute_api, server):

Loading…
Cancel
Save