Commit 86f1f5d4 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rlib2: Convert /2/groups/[group_name] to OpcodeResource


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 51cc8637
......@@ -605,10 +605,12 @@ class R_2_groups(baserlib.OpcodeResource):
uri_fields=("name", "uri"))
class R_2_groups_name(baserlib.ResourceBase):
class R_2_groups_name(baserlib.OpcodeResource):
"""/2/groups/[group_name] resource.
"""
DELETE_OPCODE = opcodes.OpGroupRemove
def GET(self):
"""Send information about a node group.
......@@ -622,14 +624,15 @@ class R_2_groups_name(baserlib.ResourceBase):
return baserlib.MapFields(G_FIELDS, result[0])
def DELETE(self):
def GetDeleteOpInput(self):
"""Delete a node group.
"""
op = opcodes.OpGroupRemove(group_name=self.items[0],
dry_run=bool(self.dryRun()))
return self.SubmitJob([op])
assert len(self.items) == 1
return ({}, {
"group_name": self.items[0],
"dry_run": self.dryRun(),
})
class R_2_groups_name_modify(baserlib.OpcodeResource):
......
......@@ -515,6 +515,26 @@ class TestBackupPrepare(unittest.TestCase):
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestGroupRemove(unittest.TestCase):
def test(self):
clfactory = _FakeClientFactory(_FakeClient)
handler = _CreateHandler(rlib2.R_2_groups_name,
["grp28575"], {}, {}, clfactory)
job_id = handler.DELETE()
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.OpGroupRemove))
self.assertEqual(op.group_name, "grp28575")
self.assertFalse(op.dry_run)
self.assertFalse(hasattr(op, "force"))
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestParseInstanceCreateRequestVersion1(testutils.GanetiTestCase):
def 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