Skip to content

Commit d159e66

Browse files
author
Tim Smith
committed
CA-414438 Defend against unexpected VDI name_description contents
It seems to be possible for a description field on an LV snapshot to be converted to a dictionary, which results in attempts to remove it from the MGT volume failing after it is deleted, which in turn results in a subsequent scan failing because an LV which should exist does not. It is not immediately clear how this ended up as a dictionary as it has been back and forth through XMLRPC a few times, but to solve the immediate issue, defend against such things. Signed-off-by: Tim Smith <[email protected]>
1 parent fbb729d commit d159e66

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

libs/sm/core/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def roundup(divisor, value):
116116
def to_plain_string(obj):
117117
if obj is None:
118118
return None
119-
if type(obj) == str:
120-
return obj
119+
if isinstance(obj, dict) and len(obj) == 0:
120+
SMlog(f"util.to_plain_string() corrected empty dict to empty str")
121+
return ""
121122
return str(obj)
122123

123124

libs/sm/srmetadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ def getVdiInfo(self, Dict, generateSector=0):
712712
# which will be called by all classes
713713
# and one specific to this class
714714
if generateSector == 1 or generateSector == 0:
715-
label = xml.sax.saxutils.escape(Dict[NAME_LABEL_TAG])
716-
desc = xml.sax.saxutils.escape(Dict[NAME_DESCRIPTION_TAG])
715+
label = xml.sax.saxutils.escape(util.to_plain_string(Dict[NAME_LABEL_TAG]))
716+
desc = xml.sax.saxutils.escape(util.to_plain_string(Dict[NAME_DESCRIPTION_TAG]))
717717
label_length = len(to_utf8(label))
718718
desc_length = len(to_utf8(desc))
719719

0 commit comments

Comments
 (0)