diff --git a/lib/ansible/module_utils/remote_management/intersight.py b/lib/ansible/module_utils/remote_management/intersight.py index 25329726d2..fa50f815a4 100644 --- a/lib/ansible/module_utils/remote_management/intersight.py +++ b/lib/ansible/module_utils/remote_management/intersight.py @@ -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): diff --git a/lib/ansible/modules/remote_management/intersight/intersight_facts.py b/lib/ansible/modules/remote_management/intersight/intersight_facts.py index 442008308d..3704c85875 100644 --- a/lib/ansible/modules/remote_management/intersight/intersight_facts.py +++ b/lib/ansible/modules/remote_management/intersight/intersight_facts.py @@ -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) diff --git a/lib/ansible/modules/remote_management/intersight/intersight_rest_api.py b/lib/ansible/modules/remote_management/intersight/intersight_rest_api.py index eb4e211d5e..f02817c871 100644 --- a/lib/ansible/modules/remote_management/intersight/intersight_rest_api.py +++ b/lib/ansible/modules/remote_management/intersight/intersight_rest_api.py @@ -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