From 0f5f5fffee010456f960dafac43c0a9d43da8f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Wed, 6 Jul 2016 20:27:31 +0200 Subject: [PATCH] cloudstack: handle unicode API results in has_changed (#16601) * cloudstack: handle unicode API results in has_changed * cloudstack: add more case sensitve keys --- lib/ansible/module_utils/cloudstack.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index 9eea9f83811..2332286200a 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -93,6 +93,9 @@ class AnsibleCloudStack(object): # these keys will be compared case sensitive in self.has_changed() self.case_sensitive_keys = [ 'id', + 'displaytext', + 'displayname', + 'description', ] self.module = module @@ -155,12 +158,17 @@ class AnsibleCloudStack(object): continue if key in current_dict: - if self.case_sensitive_keys and key in self.case_sensitive_keys: - if str(value) != str(current_dict[key]): + if isinstance(current_dict[key], (int, long, float, complex)): + if value != current_dict[key]: + return True + else: + if self.case_sensitive_keys and key in self.case_sensitive_keys: + if value != current_dict[key].encode('utf-8'): + return True + + # Test for diff in case insensitive way + elif value.lower() != current_dict[key].encode('utf-8').lower(): return True - # Test for diff in case insensitive way - elif str(value).lower() != str(current_dict[key]).lower(): - return True else: return True return False