Change in vdsm[master]: Handle spaces in device names using lvm filter

danken at redhat.com danken at redhat.com
Sun Nov 25 20:57:09 UTC 2012


Dan Kenigsberg has posted comments on this change.

Change subject: Handle spaces in device names using lvm filter
......................................................................


Patch Set 4: I would prefer that you didn't submit this

(4 inline comments)

....................................................
File vdsm/storage/lvm.py
Line 126: 
Line 127: USER_DEV_LIST = filter(None, config.get("irs", "lvm_dev_whitelist").split(","))
Line 128: 
Line 129: 
Line 130: def _buildFilter(devList):
this function begs for a unit test, which would help us understand what it can and cannot handle.
Line 131:     devList = list(devList)
Line 132:     devList.sort()
Line 133:     devs = []
Line 134:     for dev in devList:


Line 131:     devList = list(devList)
Line 132:     devList.sort()
Line 133:     devs = []
Line 134:     for dev in devList:
Line 135:         if dev.strip():
dev.strip() is calculated twice
Line 136:             devs.append(dev.strip().encode("string_escape").
Line 137:                                     replace(' ', r'\\\\x20'))
Line 138:     filt = '|'.join(devs)
Line 139:     if len(filt) > 0:


Line 132:     devList.sort()
Line 133:     devs = []
Line 134:     for dev in devList:
Line 135:         if dev.strip():
Line 136:             devs.append(dev.strip().encode("string_escape").
I'm pretty sure that you need decode() here, for non-printable characters.
Line 137:                                     replace(' ', r'\\\\x20'))
Line 138:     filt = '|'.join(devs)
Line 139:     if len(filt) > 0:
Line 140:         filt = "'a%" + filt + "%', "


Line 133:     devs = []
Line 134:     for dev in devList:
Line 135:         if dev.strip():
Line 136:             devs.append(dev.strip().encode("string_escape").
Line 137:                                     replace(' ', r'\\\\x20'))
please take the time to handle other funny characters: tab, pipe, doublequotes, backslash, whatnot.

This is untested with multipath encoding, but may be found helpful:

 re.sub("\W", lambda m: r'\\\\x%x' % ord(m.group()), 'hello world')
Line 138:     filt = '|'.join(devs)
Line 139:     if len(filt) > 0:
Line 140:         filt = "'a%" + filt + "%', "
Line 141: 


--
To view, visit http://gerrit.ovirt.org/9191
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1efb6dfd30c0999f14c413fff778213b247a178f
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan at redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Eduardo <ewarszaw at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Igor Lvovsky <ilvovsky at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Shu Ming <shuming at linux.vnet.ibm.com>
Gerrit-Reviewer: Yeela Kaplan <ykaplan at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list