Commit 973ec124 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rlib2: Convert /2/instances/[inst]/deactivate-disks to OpcodeResource


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 1824a7a1
...@@ -971,19 +971,19 @@ class R_2_instances_name_activate_disks(baserlib.OpcodeResource): ...@@ -971,19 +971,19 @@ class R_2_instances_name_activate_disks(baserlib.OpcodeResource):
}) })
class R_2_instances_name_deactivate_disks(baserlib.ResourceBase): class R_2_instances_name_deactivate_disks(baserlib.OpcodeResource):
"""/2/instances/[instance_name]/deactivate-disks resource. """/2/instances/[instance_name]/deactivate-disks resource.
""" """
def PUT(self): PUT_OPCODE = opcodes.OpInstanceDeactivateDisks
def GetPutOpInput(self):
"""Deactivate disks for an instance. """Deactivate disks for an instance.
""" """
instance_name = self.items[0] return ({}, {
"instance_name": self.items[0],
op = opcodes.OpInstanceDeactivateDisks(instance_name=instance_name) })
return self.SubmitJob([op])
class R_2_instances_name_prepare_export(baserlib.ResourceBase): class R_2_instances_name_prepare_export(baserlib.ResourceBase):
......
...@@ -426,6 +426,26 @@ class TestInstanceActivateDisks(unittest.TestCase): ...@@ -426,6 +426,26 @@ class TestInstanceActivateDisks(unittest.TestCase):
self.assertRaises(IndexError, cl.GetNextSubmittedJob) self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestInstanceDeactivateDisks(unittest.TestCase):
def test(self):
clfactory = _FakeClientFactory(_FakeClient)
handler = _CreateHandler(rlib2.R_2_instances_name_deactivate_disks,
["inst22357"], {}, {}, clfactory)
job_id = handler.PUT()
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.OpInstanceDeactivateDisks))
self.assertEqual(op.instance_name, "inst22357")
self.assertFalse(hasattr(op, "dry_run"))
self.assertFalse(hasattr(op, "force"))
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestParseInstanceCreateRequestVersion1(testutils.GanetiTestCase): class TestParseInstanceCreateRequestVersion1(testutils.GanetiTestCase):
def setUp(self): def setUp(self):
testutils.GanetiTestCase.setUp(self) testutils.GanetiTestCase.setUp(self)
......
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