Skip to content
Snippets Groups Projects
Commit 7fa91722 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rlib2: Convert /2/nodes/[node_name]/evacuate to OpcodeResource


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 55168cc7
No related branches found
No related tags found
No related merge requests found
......@@ -441,21 +441,21 @@ class R_2_nodes_name_role(baserlib.ResourceBase):
return self.SubmitJob([op])
class R_2_nodes_name_evacuate(baserlib.ResourceBase):
class R_2_nodes_name_evacuate(baserlib.OpcodeResource):
"""/2/nodes/[node_name]/evacuate resource.
"""
def POST(self):
POST_OPCODE = opcodes.OpNodeEvacuate
def GetPostOpInput(self):
"""Evacuate all instances off a node.
"""
op = baserlib.FillOpcode(opcodes.OpNodeEvacuate, self.request_body, {
return (self.request_body, {
"node_name": self.items[0],
"dry_run": self.dryRun(),
})
return self.SubmitJob([op])
class R_2_nodes_name_migrate(baserlib.OpcodeResource):
"""/2/nodes/[node_name]/migrate resource.
......
......@@ -249,6 +249,29 @@ class TestNodeMigrate(unittest.TestCase):
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestNodeEvacuate(unittest.TestCase):
def test(self):
clfactory = _FakeClientFactory(_FakeClient)
handler = _CreateHandler(rlib2.R_2_nodes_name_evacuate, ["node92"], {
"dry-run": ["1"],
}, {
"mode": constants.IALLOCATOR_NEVAC_SEC,
}, clfactory)
job_id = handler.POST()
cl = clfactory.GetNextClient()
self.assertRaises(IndexError, clfactory.GetNextClient)
(exp_job_id, (op, )) = cl.GetNextSubmittedJob()
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.assertTrue(op.dry_run)
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestParseInstanceCreateRequestVersion1(testutils.GanetiTestCase):
def setUp(self):
testutils.GanetiTestCase.setUp(self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment