Nir Soffer has posted comments on this change.
Change subject: Avoid to recompile namedtuple ATTR classes in lvm. ......................................................................
Patch Set 1:
(1 comment)
http://gerrit.ovirt.org/#/c/25678/1/vdsm/storage/lvm.py File vdsm/storage/lvm.py:
Line 220: args[LV._fields.index("tags")] = tags Line 221: # Convert attr string into named tuple fields. Line 222: sAttr = args[LV._fields.index("attr")] Line 223: attr_values = tuple(sAttr[:len(LV_ATTR._fields)]) Line 224: attrs = LV_ATTR(*attr_values) This change introduce duplication that the _attr2NamedTupple function prevented.
We can instead fix the function like this:
def _attr2NamedTupple(attr, cls): values = attr[:len(cls._fields)] return cls(*values)
What do you think? Line 225: args[LV._fields.index("attr")] = attrs Line 226: # Add properties. Should be ordered as VG_PROPERTIES. Line 227: args.append(attrs.permission == "w") # writable Line 228: args.append(attrs.devopen == "o") # opened