mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix bug in data returns for some queries used by facts module (#52832)
* Fix bug in data returns for some queries used by facts module * Add additional query to return all servers (up to 5000) * Fix key checking in rest_api
This commit is contained in:
parent
be293fbe50
commit
e8cddfd452
3 changed files with 9 additions and 5 deletions
|
@ -190,8 +190,9 @@ class IntersightModule():
|
|||
except Exception as e:
|
||||
self.module.fail_json(msg="API error: %s " % str(e))
|
||||
|
||||
if response.length > 0:
|
||||
return json.loads(response.read())
|
||||
response_data = response.read()
|
||||
if len(response_data) > 0:
|
||||
return json.loads(response_data)
|
||||
return {}
|
||||
|
||||
def intersight_call(self, http_method="", resource_path="", query_params=None, body=None, moid=None, name=None):
|
||||
|
|
|
@ -85,6 +85,7 @@ def get_servers(module, intersight):
|
|||
'resource_path': '/compute/PhysicalSummaries',
|
||||
'query_params': {
|
||||
'$filter': query_str,
|
||||
'$top': 5000
|
||||
}
|
||||
}
|
||||
response_dict = intersight.call_api(**options)
|
||||
|
|
|
@ -150,7 +150,7 @@ def get_resource(intersight):
|
|||
def compare_values(expected, actual):
|
||||
try:
|
||||
for (key, value) in iteritems(expected):
|
||||
if re.search(r'P(ass)?w(or)?d', key) or not actual.get(key):
|
||||
if re.search(r'P(ass)?w(or)?d', key) or key not in actual:
|
||||
# do not compare any password related attributes or attributes that are not in the actual resource
|
||||
continue
|
||||
if not compare_values(value, actual[key]):
|
||||
|
@ -184,8 +184,10 @@ def configure_resource(intersight, moid):
|
|||
'resource_path': intersight.module.params['resource_path'],
|
||||
'body': intersight.module.params['api_body'],
|
||||
}
|
||||
intersight.call_api(**options)
|
||||
intersight.result['api_response'] = get_resource(intersight)
|
||||
resp = intersight.call_api(**options)
|
||||
if 'Moid' not in resp:
|
||||
resp = get_resource(intersight)
|
||||
intersight.result['api_response'] = resp
|
||||
intersight.result['changed'] = True
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue