Revision a52978c7
b/doc/rapi.rst | ||
---|---|---|
811 | 811 |
Takes no parameters. |
812 | 812 |
|
813 | 813 |
|
814 |
``/2/instances/[instance_name]/recreate-disks`` |
|
815 |
+++++++++++++++++++++++++++++++++++++++++++++++++ |
|
816 |
|
|
817 |
Recreate disks of an instance. Supports the following commands: |
|
818 |
``POST``. |
|
819 |
|
|
820 |
``POST`` |
|
821 |
~~~~~~~~ |
|
822 |
|
|
823 |
Returns a job ID. |
|
824 |
|
|
825 |
Body parameters: |
|
826 |
|
|
827 |
.. opcode_params:: OP_INSTANCE_RECREATE_DISKS |
|
828 |
:exclude: instance_name |
|
829 |
|
|
830 |
|
|
814 | 831 |
``/2/instances/[instance_name]/disk/[disk_index]/grow`` |
815 | 832 |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
816 | 833 |
|
b/lib/opcodes.py | ||
---|---|---|
1268 | 1268 |
|
1269 | 1269 |
|
1270 | 1270 |
class OpInstanceRecreateDisks(OpCode): |
1271 |
"""Deactivate an instance's disks."""
|
|
1271 |
"""Recreate an instance's disks."""
|
|
1272 | 1272 |
OP_DSC_FIELD = "instance_name" |
1273 | 1273 |
OP_PARAMS = [ |
1274 | 1274 |
_PInstanceName, |
b/lib/rapi/client.py | ||
---|---|---|
753 | 753 |
("/%s/instances/%s/deactivate-disks" % |
754 | 754 |
(GANETI_RAPI_VERSION, instance)), None, None) |
755 | 755 |
|
756 |
def RecreateInstanceDisks(self, instance, disks=None, nodes=None): |
|
757 |
"""Recreate an instance's disks. |
|
758 |
|
|
759 |
@type instance: string |
|
760 |
@param instance: Instance name |
|
761 |
@type disks: list of int |
|
762 |
@param disks: List of disk indexes |
|
763 |
@type nodes: list of string |
|
764 |
@param nodes: New instance nodes, if relocation is desired |
|
765 |
@rtype: string |
|
766 |
@return: job id |
|
767 |
|
|
768 |
""" |
|
769 |
body = {} |
|
770 |
|
|
771 |
if disks is not None: |
|
772 |
body["disks"] = disks |
|
773 |
|
|
774 |
if nodes is not None: |
|
775 |
body["nodes"] = nodes |
|
776 |
|
|
777 |
return self._SendRequest(HTTP_POST, |
|
778 |
("/%s/instances/%s/recreate-disks" % |
|
779 |
(GANETI_RAPI_VERSION, instance)), None, body) |
|
780 |
|
|
756 | 781 |
def GrowInstanceDisk(self, instance, disk, amount, wait_for_sync=None): |
757 | 782 |
"""Grows a disk of an instance. |
758 | 783 |
|
b/lib/rapi/connector.py | ||
---|---|---|
143 | 143 |
rlib2.R_2_instances_name_activate_disks, |
144 | 144 |
re.compile(r"^/2/instances/(%s)/deactivate-disks$" % instance_name_pattern): |
145 | 145 |
rlib2.R_2_instances_name_deactivate_disks, |
146 |
re.compile(r"^/2/instances/(%s)/recreate-disks$" % instance_name_pattern): |
|
147 |
rlib2.R_2_instances_name_recreate_disks, |
|
146 | 148 |
re.compile(r"^/2/instances/(%s)/prepare-export$" % instance_name_pattern): |
147 | 149 |
rlib2.R_2_instances_name_prepare_export, |
148 | 150 |
re.compile(r"^/2/instances/(%s)/export$" % instance_name_pattern): |
b/lib/rapi/rlib2.py | ||
---|---|---|
995 | 995 |
}) |
996 | 996 |
|
997 | 997 |
|
998 |
class R_2_instances_name_recreate_disks(baserlib.OpcodeResource): |
|
999 |
"""/2/instances/[instance_name]/recreate-disks resource. |
|
1000 |
|
|
1001 |
""" |
|
1002 |
POST_OPCODE = opcodes.OpInstanceRecreateDisks |
|
1003 |
|
|
1004 |
def GetPostOpInput(self): |
|
1005 |
"""Recreate disks for an instance. |
|
1006 |
|
|
1007 |
""" |
|
1008 |
return ({}, { |
|
1009 |
"instance_name": self.items[0], |
|
1010 |
}) |
|
1011 |
|
|
1012 |
|
|
998 | 1013 |
class R_2_instances_name_prepare_export(baserlib.OpcodeResource): |
999 | 1014 |
"""/2/instances/[instance_name]/prepare-export resource. |
1000 | 1015 |
|
b/test/docs_unittest.py | ||
---|---|---|
53 | 53 |
opcodes.OpClusterVerifyDisks, |
54 | 54 |
opcodes.OpInstanceChangeGroup, |
55 | 55 |
opcodes.OpInstanceMove, |
56 |
opcodes.OpInstanceRecreateDisks, |
|
57 | 56 |
opcodes.OpNodePowercycle, |
58 | 57 |
opcodes.OpNodeQueryvols, |
59 | 58 |
opcodes.OpOobCommand, |
b/test/ganeti.rapi.client_unittest.py | ||
---|---|---|
1166 | 1166 |
self.assertHandler(rlib2.R_2_instances_name_deactivate_disks) |
1167 | 1167 |
self.assertFalse(self.rapi.GetLastHandler().queryargs) |
1168 | 1168 |
|
1169 |
def testRecreateInstanceDisks(self): |
|
1170 |
self.rapi.AddResponse("13553") |
|
1171 |
job_id = self.client.RecreateInstanceDisks("inst23153") |
|
1172 |
self.assertEqual(job_id, 13553) |
|
1173 |
self.assertItems(["inst23153"]) |
|
1174 |
self.assertHandler(rlib2.R_2_instances_name_recreate_disks) |
|
1175 |
self.assertFalse(self.rapi.GetLastHandler().queryargs) |
|
1176 |
|
|
1169 | 1177 |
def testGetInstanceConsole(self): |
1170 | 1178 |
self.rapi.AddResponse("26876") |
1171 | 1179 |
job_id = self.client.GetInstanceConsole("inst21491") |
b/test/ganeti.rapi.rlib2_unittest.py | ||
---|---|---|
446 | 446 |
self.assertRaises(IndexError, cl.GetNextSubmittedJob) |
447 | 447 |
|
448 | 448 |
|
449 |
class TestInstanceRecreateDisks(unittest.TestCase): |
|
450 |
def test(self): |
|
451 |
clfactory = _FakeClientFactory(_FakeClient) |
|
452 |
handler = _CreateHandler(rlib2.R_2_instances_name_recreate_disks, |
|
453 |
["inst22357"], {}, {}, clfactory) |
|
454 |
job_id = handler.POST() |
|
455 |
|
|
456 |
cl = clfactory.GetNextClient() |
|
457 |
self.assertRaises(IndexError, clfactory.GetNextClient) |
|
458 |
|
|
459 |
(exp_job_id, (op, )) = cl.GetNextSubmittedJob() |
|
460 |
self.assertEqual(job_id, exp_job_id) |
|
461 |
self.assertTrue(isinstance(op, opcodes.OpInstanceRecreateDisks)) |
|
462 |
self.assertEqual(op.instance_name, "inst22357") |
|
463 |
self.assertFalse(hasattr(op, "dry_run")) |
|
464 |
self.assertFalse(hasattr(op, "force")) |
|
465 |
|
|
466 |
self.assertRaises(IndexError, cl.GetNextSubmittedJob) |
|
467 |
|
|
468 |
|
|
449 | 469 |
class TestInstanceFailover(unittest.TestCase): |
450 | 470 |
def test(self): |
451 | 471 |
clfactory = _FakeClientFactory(_FakeClient) |
Also available in: Unified diff