Skip to content

Commit 0e99451

Browse files
committed
fix serious quoting issue
1 parent ec0cdca commit 0e99451

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

actions/get_properties.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,12 @@ def __init__(self, *args, **kwargs):
103103
super(PyVmomiObjectJSONEncoder, self).__init__(*args, **kwargs)
104104

105105
def default(self, obj): # pylint: disable=method-hidden
106-
# ISO8601
107106
if isinstance(obj, datetime.datetime):
108107
return pyVmomi.Iso8601.ISO8601Format(obj)
109-
# DataObject
110108
elif isinstance(obj, pyVmomi.VmomiSupport.DataObject):
111109
return obj.__dict__
112-
# ManagedObject
113110
elif isinstance(obj, pyVmomi.VmomiSupport.ManagedObject):
114-
# The ManagedObject's reference name.
115-
return repr(obj)[1:-1].split(':')[-1] # strip outer quotes
116-
# Python Type
111+
return unquote(obj).split(':')[-1]
117112
elif isinstance(obj, type):
118113
return str(obj)
119114
return json.JSONEncoder.default(self, obj)
@@ -122,9 +117,14 @@ def default(self, obj): # pylint: disable=method-hidden
122117
def transform(self, ids, rawdata):
123118
result = {}
124119
for obj in rawdata:
125-
objid = repr(obj.obj)[1:-1].split(':')[-1]
120+
objid = unquote(obj.obj).split(':')[-1]
126121
ps = {}
127122
for prop in obj.propSet:
128-
ps[repr(prop.name)[1:-1]] = self.jsonify_vsphere_obj(prop.val)
123+
ps[unquote(prop.name)] = self.jsonify_vsphere_obj(prop.val)
129124
result[objid] = ps
130125
return (not ids or sorted(result.keys()) == sorted(ids), result)
126+
127+
128+
def unquote(item):
129+
return str(item).strip("'")
130+

0 commit comments

Comments
 (0)