mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
intersight_rest_api module and integration tests. (#52430)
* intersight_rest_api module and integration tests. Fix intersight module_utils issues when using POST/PATCH/DELETE. * Update json returns based on code review
This commit is contained in:
parent
008313b8cc
commit
63ea76d174
4 changed files with 412 additions and 2 deletions
|
@ -186,11 +186,13 @@ class IntersightModule():
|
|||
try:
|
||||
response, info = self.intersight_call(**options)
|
||||
if not re.match(r'2..', str(info['status'])):
|
||||
raise RuntimeError(info['status'], info['msg'])
|
||||
raise RuntimeError(info['status'], info['msg'], info['body'])
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="API error: %s " % str(e))
|
||||
|
||||
return json.loads(response.read())
|
||||
if response.length > 0:
|
||||
return json.loads(response.read())
|
||||
return {}
|
||||
|
||||
def intersight_call(self, http_method="", resource_path="", query_params=None, body=None, moid=None, name=None):
|
||||
"""
|
||||
|
@ -278,6 +280,7 @@ class IntersightModule():
|
|||
# Generate the HTTP requests header
|
||||
request_header = {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Host': '{0}'.format(target_host),
|
||||
'Date': '{0}'.format(cdate),
|
||||
'Digest': 'SHA-256={0}'.format(b64_body_digest.decode('ascii')),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue