Commit b2fbea47 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Replace literals with constants



In "lib/cmdlib/node.py", in lines 1315-1316, 1354, and 1359-1370,
replace string literals with constants.  Fixes issue 558.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 02eb0fe5
......@@ -1312,8 +1312,9 @@ class LUNodeQueryvols(NoHooksLU):
REQ_BGL = False
def CheckArguments(self):
_CheckOutputFields(utils.FieldSet("node", "phys", "vg", "name", "size",
"instance"),
_CheckOutputFields(utils.FieldSet(constants.VF_NODE, constants.VF_PHYS,
constants.VF_VG, constants.VF_NAME,
constants.VF_SIZE, constants.VF_INSTANCE),
self.op.output_fields)
def ExpandNames(self):
......@@ -1351,24 +1352,24 @@ class LUNodeQueryvols(NoHooksLU):
continue
node_vols = sorted(nresult.payload,
key=operator.itemgetter("dev"))
key=operator.itemgetter(constants.VF_DEV))
for vol in node_vols:
node_output = []
for field in self.op.output_fields:
if field == "node":
if field == constants.VF_NODE:
val = self.cfg.GetNodeName(node_uuid)
elif field == "phys":
val = vol["dev"]
elif field == "vg":
val = vol["vg"]
elif field == "name":
val = vol["name"]
elif field == "size":
val = int(float(vol["size"]))
elif field == "instance":
inst = vol2inst.get((node_uuid, vol["vg"] + "/" + vol["name"]),
None)
elif field == constants.VF_PHYS:
val = vol[constants.VF_DEV]
elif field == constants.VF_VG:
val = vol[constants.VF_VG]
elif field == constants.VF_NAME:
val = vol[constants.VF_NAME]
elif field == constants.VF_SIZE:
val = int(float(vol[constants.VF_SIZE]))
elif field == constants.VF_INSTANCE:
inst = vol2inst.get((node_uuid, vol[constants.VF_VG] + "/" +
vol[constants.VF_NAME]), None)
if inst is not None:
val = inst.name
else:
......
......@@ -433,6 +433,15 @@ VALID_STORAGE_OPERATIONS = {
ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
}
# Volume fields
VF_DEV = "dev"
VF_INSTANCE = "instance"
VF_NAME = "name"
VF_NODE = "node"
VF_PHYS = "phys"
VF_SIZE = "size"
VF_VG = "vg"
# Local disk status
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
(LDS_OKAY,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment