Eduardo has uploaded a new change for review. Change subject: Avoid to recompile namedtuple ATTR classes in lvm. ......................................................................
Avoid to recompile namedtuple ATTR classes in lvm. Change-Id: I66110a7f25fb5cfd80ddffe9a22e1cbac11de447 Signed-off-by: Eduardo <[email protected]> --- M vdsm/storage/lvm.py 1 file changed, 9 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/25678/1 diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py index 0fbed29..d963736 100644 --- a/vdsm/storage/lvm.py +++ b/vdsm/storage/lvm.py @@ -61,7 +61,9 @@ PV = namedtuple("PV", PV_FIELDS + ",guid") VG = namedtuple("VG", VG_FIELDS + ",writeable,partial") +VG_ATTR = namedtuple("VG_ATTR", VG_ATTR_BITS) LV = namedtuple("LV", LV_FIELDS + ",writeable,opened,active") +LV_ATTR = namedtuple("LV_ATTR", LV_ATTR_BITS) Stub = namedtuple("Stub", "name, stale") @@ -185,19 +187,6 @@ return tuple(sTags.split(",")) if sTags else tuple() -def _attr2NamedTuple(sAttr, attrMask, label): - """ - Converts a attr string into a named tuple. - - Fields are named as in attrMask. - """ - Attrs = namedtuple(label, attrMask) - # tuple("wz--n-") = ('w', 'z', '-', '-', 'n', '-') - values = tuple(sAttr[:len(attrMask)]) - attrs = Attrs(*values) - return attrs - - def makePV(*args): guid = os.path.basename(args[1]) args += (guid,) @@ -210,8 +199,10 @@ tags = _tags2Tuple(args[VG._fields.index("tags")]) args[VG._fields.index("tags")] = tags # Convert attr string into named tuple fields. - attrs = _attr2NamedTuple(args[VG._fields.index("attr")], VG_ATTR_BITS, - "VG_ATTR") + # tuple("wz--n-") = ('w', 'z', '-', '-', 'n', '-') + sAttr = args[VG._fields.index("attr")] + attr_values = tuple(sAttr[:len(VG_ATTR._fields)]) + attrs = VG_ATTR(*attr_values) args[VG._fields.index("attr")] = attrs # Convert pv_names list to tuple. args[VG._fields.index("pv_name")] = \ @@ -228,8 +219,9 @@ tags = _tags2Tuple(args[LV._fields.index("tags")]) args[LV._fields.index("tags")] = tags # Convert attr string into named tuple fields. - attrs = _attr2NamedTuple(args[LV._fields.index("attr")], LV_ATTR_BITS, - "LV_ATTR") + sAttr = args[LV._fields.index("attr")] + attr_values = tuple(sAttr[:len(LV_ATTR._fields)]) + attrs = LV_ATTR(*attr_values) args[LV._fields.index("attr")] = attrs # Add properties. Should be ordered as VG_PROPERTIES. args.append(attrs.permission == "w") # writable -- To view, visit http://gerrit.ovirt.org/25678 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I66110a7f25fb5cfd80ddffe9a22e1cbac11de447 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
