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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Below information has been taken from https://developer.scaleway.com/#servers
|
||||
---
|
||||
scaleway_image_id: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
scaleway_image_id: 6a601340-19c1-4ca7-9c1c-0704bcc9f5fe
|
||||
scaleway_organization: '{{ scw_org }}'
|
||||
scaleway_region: ams1
|
||||
scaleway_commerial_type: START1-S
|
||||
|
|
|
@ -384,3 +384,4 @@
|
|||
that:
|
||||
- unexisting_image_check is not success
|
||||
- unexisting_image_check is not changed
|
||||
- unexisting_image_check.msg == "Error in getting image this-image-does-not-exists on https://cp-{{scaleway_region}}.scaleway.com"
|
||||
|
|
Loading…
Reference in a new issue