From aefe9634836287818c4fbcf193e15b6ed7558d75 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Fri, 27 Jul 2018 12:17:10 +0530 Subject: [PATCH] VMware: handle special characters in datacenter name (#42922) This fix handles special characters in VMware objects Signed-off-by: Abhijeet Kasurde --- lib/ansible/module_utils/vmware.py | 2 +- lib/ansible/modules/cloud/vmware/vmware_guest.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 091f725d5dd..6a8be7eabba 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -90,7 +90,7 @@ def find_obj(content, vimtype, name, first=True): # Select the first match if first is True: for obj in obj_list: - if obj.name == name: + if to_text(obj.name) == to_text(name): return obj # If no object found, return None diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 6213cf1bcd8..eb9821d9311 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -710,11 +710,11 @@ class PyVmomiCache(object): """ Wrapper around find_obj to set datacenter context """ result = find_obj(content, types, name) if result and confine_to_datacenter: - if self.get_parent_datacenter(result).name != self.dc_name: + if to_text(self.get_parent_datacenter(result).name) != to_text(self.dc_name): result = None objects = self.get_all_objs(content, types, confine_to_datacenter=True) for obj in objects: - if name is None or obj.name == name: + if name is None or to_text(obj.name) == to_text(name): return obj return result