Commit 7b3df961 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rlib2: Convert /2/instances/[inst]/info to OpcodeResource


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent a6fa7892
......@@ -782,20 +782,21 @@ class R_2_instances_name(baserlib.OpcodeResource):
})
class R_2_instances_name_info(baserlib.ResourceBase):
class R_2_instances_name_info(baserlib.OpcodeResource):
"""/2/instances/[instance_name]/info resource.
"""
def GET(self):
GET_OPCODE = opcodes.OpInstanceQueryData
def GetGetOpInput(self):
"""Request detailed instance information.
"""
instance_name = self.items[0]
static = bool(self._checkIntVariable("static", default=0))
op = opcodes.OpInstanceQueryData(instances=[instance_name],
static=static)
return self.SubmitJob([op])
assert len(self.items) == 1
return ({}, {
"instances": [self.items[0]],
"static": bool(self._checkIntVariable("static", default=0)),
})
class R_2_instances_name_reboot(baserlib.ResourceBase):
......
......@@ -318,6 +318,26 @@ class TestInstanceDelete(unittest.TestCase):
self.assertRaises(IndexError, cl.GetNextSubmittedJob)
class TestInstanceInfo(unittest.TestCase):
def test(self):
clfactory = _FakeClientFactory(_FakeClient)
handler = _CreateHandler(rlib2.R_2_instances_name_info, ["inst31217"], {
"static": ["1"],
}, {}, clfactory)
job_id = handler.GET()
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.OpInstanceQueryData))
self.assertEqual(op.instances, ["inst31217"])
self.assertTrue(op.static)
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