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:
Alexis Camilleri 2020-02-24 06:38:14 +01:00 committed by GitHub
parent 2dadc259d3
commit feeb380649
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- 'scaleway_compute(check_image_id): use get image instead loop on first page of images results'

View file

@ -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):