def check_model_state(self):
base_url = self.module.params['base_url']
model_name = self.module.params['label']
uri = "%s/model" % base_url
try:
json_result, http_success = hanlon_get_request(uri)
for response in json_result['response']:
uri = response['@uri']
model, http_success = hanlon_get_request(uri)
if http_success:
model_response = model['response']
if model_response['@label'] == model_name:
return 'present', model_response['@uuid']
except requests.ConnectionError as connect_error:
self.module.fail_json(msg="Connection Error; confirm Hanlon base_url.", apierror=str(connect_error))
except requests.Timeout as timeout_error:
self.module.fail_json(msg="Timeout Error; confirm status of Hanlon server", apierror=str(timeout_error))
except requests.RequestException as request_exception:
self.module.fail_json(msg="Unknown Request library failure", apierror=str(request_exception))
return 'absent', None
评论列表
文章目录