kubevirt_cdi_upload: add more error handling (#54041)

pull/54775/head
Mariusz Mazur 6 years ago committed by ansibot
parent 9e30300034
commit 0acef98dc4

@ -161,10 +161,20 @@ class KubeVirtCDIUpload(KubernetesRawModule):
headers = {'Authorization': "Bearer {0}".format(result['result']['status']['token'])}
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)
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():
module = KubeVirtCDIUpload()

Loading…
Cancel
Save