mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
feat: meaningful error message scaleway image not found (#48829)
This commit is contained in:
parent
9f785cf8a9
commit
70fff13a6e
3 changed files with 15 additions and 1 deletions
|
@ -225,6 +225,17 @@ SCALEWAY_TRANSITIONS_STATES = (
|
|||
)
|
||||
|
||||
|
||||
def check_image_id(compute_api, image_id):
|
||||
response = compute_api.get(path="images")
|
||||
|
||||
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'))
|
||||
|
||||
|
||||
def fetch_state(compute_api, server):
|
||||
compute_api.module.debug("fetch_state of server: %s" % server["id"])
|
||||
response = compute_api.get(path="servers/%s" % server["id"])
|
||||
|
@ -662,6 +673,8 @@ def core(module):
|
|||
|
||||
compute_api = Scaleway(module=module)
|
||||
|
||||
check_image_id(compute_api, wished_server["image"])
|
||||
|
||||
# IP parameters of the wished server depends on the configuration
|
||||
ip_payload = public_ip_payload(compute_api=compute_api, public_ip=module.params["public_ip"])
|
||||
wished_server.update(ip_payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue