mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
kubevirt_cdi_upload: add more error handling (#54041)
This commit is contained in:
parent
9e30300034
commit
0acef98dc4
1 changed files with 11 additions and 1 deletions
|
@ -161,10 +161,20 @@ class KubeVirtCDIUpload(KubernetesRawModule):
|
||||||
|
|
||||||
headers = {'Authorization': "Bearer {0}".format(result['result']['status']['token'])}
|
headers = {'Authorization': "Bearer {0}".format(result['result']['status']['token'])}
|
||||||
url = "{0}/{1}/upload".format(upload_host, API)
|
url = "{0}/{1}/upload".format(upload_host, API)
|
||||||
requests.post(url, data=imgfile, headers=headers, verify=upload_host_verify_ssl)
|
ret = requests.post(url, data=imgfile, headers=headers, verify=upload_host_verify_ssl)
|
||||||
|
|
||||||
|
if ret.status_code != 200:
|
||||||
|
self.fail_request("Something went wrong while uploading data", method='POST', url=url,
|
||||||
|
reason=ret.reason, status_code=ret.status_code)
|
||||||
|
|
||||||
self.exit_json(changed=True)
|
self.exit_json(changed=True)
|
||||||
|
|
||||||
|
def fail_request(self, msg, **kwargs):
|
||||||
|
req_info = {}
|
||||||
|
for k, v in kwargs.items():
|
||||||
|
req_info['req_' + k] = v
|
||||||
|
self.fail_json(msg=msg, **req_info)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = KubeVirtCDIUpload()
|
module = KubeVirtCDIUpload()
|
||||||
|
|
Loading…
Reference in a new issue