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

Replace 'IALLOCATOR_NEVAC_*' with 'NODE_EVAC_*'



Replace uses of 'IALLOCATOR_NEVAC_PRI', 'IALLOCATOR_NEVAC_SEC',
'IALLOCATOR_NEVAC_ALL', and 'IALLOCATOR_NEVAC_MODES', with
'NODE_EVAC_PRI', 'NODE_EVAC_SEC', 'NODE_EVAC_ALL', and
'NODE_EVAC_MODES', given that these constants are repeated.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent b5cad580
......@@ -673,10 +673,10 @@ commands = {
help="Select number of VCPUs for the instance"),
cli_option("--tags", default=None,
help="Comma separated list of tags"),
cli_option("--evac-mode", default=constants.IALLOCATOR_NEVAC_ALL,
choices=list(constants.IALLOCATOR_NEVAC_MODES),
cli_option("--evac-mode", default=constants.NODE_EVAC_ALL,
choices=list(constants.NODE_EVAC_MODES),
help=("Node evacuation mode (one of %s)" %
utils.CommaJoin(constants.IALLOCATOR_NEVAC_MODES))),
utils.CommaJoin(constants.NODE_EVAC_MODES))),
cli_option("--target-groups", help="Target groups for relocation",
default=[], action="append"),
cli_option("--spindle-use", help="How many spindles to use",
......
......@@ -857,15 +857,6 @@ class LUNodeEvacuate(NoHooksLU):
"""
REQ_BGL = False
_MODE2IALLOCATOR = {
constants.NODE_EVAC_PRI: constants.IALLOCATOR_NEVAC_PRI,
constants.NODE_EVAC_SEC: constants.IALLOCATOR_NEVAC_SEC,
constants.NODE_EVAC_ALL: constants.IALLOCATOR_NEVAC_ALL,
}
assert frozenset(_MODE2IALLOCATOR.keys()) == constants.NODE_EVAC_MODES
assert (frozenset(_MODE2IALLOCATOR.values()) ==
constants.IALLOCATOR_NEVAC_MODES)
def CheckArguments(self):
CheckIAllocatorOrNode(self, "iallocator", "remote_node")
......@@ -1022,8 +1013,7 @@ class LUNodeEvacuate(NoHooksLU):
elif self.op.iallocator is not None:
# TODO: Implement relocation to other group
evac_mode = self._MODE2IALLOCATOR[self.op.mode]
req = iallocator.IAReqNodeEvac(evac_mode=evac_mode,
req = iallocator.IAReqNodeEvac(evac_mode=self.op.mode,
instances=list(self.instance_names))
ial = iallocator.IAllocator(self.cfg, self.rpc, req)
......
......@@ -537,7 +537,7 @@ TExportMode = TElemOf(constants.EXPORT_MODES)
TDiskIndex = TAnd(TNonNegativeInt, lambda val: val < constants.MAX_DISKS)
TReplaceDisksMode = TElemOf(constants.REPLACE_MODES)
TDiskTemplate = TElemOf(constants.DISK_TEMPLATES)
TNodeEvacMode = TElemOf(constants.IALLOCATOR_NEVAC_MODES)
TNodeEvacMode = TElemOf(constants.NODE_EVAC_MODES)
TIAllocatorTestDir = TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)
TIAllocatorMode = TElemOf(constants.VALID_IALLOCATOR_MODES)
......
......@@ -336,7 +336,7 @@ class IAReqNodeEvac(IARequestBase):
MODE = constants.IALLOCATOR_MODE_NODE_EVAC
REQ_PARAMS = [
("instances", _STRING_LIST),
("evac_mode", ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)),
("evac_mode", ht.TNodeEvacMode),
]
REQ_RESULT = _NEVAC_RESULT
......
......@@ -146,7 +146,7 @@ class TestLUTestAllocator(CmdlibTestCase):
self.CopyOpCode(self.base_op,
mode=constants.IALLOCATOR_MODE_NODE_EVAC,
instances=["new-instance.example.com"],
evac_mode=constants.IALLOCATOR_NEVAC_PRI)
evac_mode=constants.NODE_EVAC_PRI)
self.iallocator_cls.return_value.in_text = "mock in text"
self.iallocator_cls.return_value.out_text = "mock out text"
......
......@@ -261,7 +261,7 @@ class TestNodeEvacuate(unittest.TestCase):
handler = _CreateHandler(rlib2.R_2_nodes_name_evacuate, ["node92"], {
"dry-run": ["1"],
}, {
"mode": constants.IALLOCATOR_NEVAC_SEC,
"mode": constants.NODE_EVAC_SEC,
}, clfactory)
job_id = handler.POST()
......@@ -272,7 +272,7 @@ class TestNodeEvacuate(unittest.TestCase):
self.assertEqual(job_id, exp_job_id)
self.assertTrue(isinstance(op, opcodes.OpNodeEvacuate))
self.assertEqual(op.node_name, "node92")
self.assertEqual(op.mode, constants.IALLOCATOR_NEVAC_SEC)
self.assertEqual(op.mode, constants.NODE_EVAC_SEC)
self.assertTrue(op.dry_run)
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
......
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