Revision 5823e0d2
b/doc/rapi.rst | ||
---|---|---|
629 | 629 |
Destination X509 CA (remote export only). |
630 | 630 |
|
631 | 631 |
|
632 |
``/2/instances/[instance_name]/migrate`` |
|
633 |
++++++++++++++++++++++++++++++++++++++++ |
|
634 |
|
|
635 |
Migrates an instance. |
|
636 |
|
|
637 |
Supports the following commands: ``PUT``. |
|
638 |
|
|
639 |
``PUT`` |
|
640 |
~~~~~~~ |
|
641 |
|
|
642 |
Returns a job ID. |
|
643 |
|
|
644 |
Body parameters: |
|
645 |
|
|
646 |
``mode`` (string) |
|
647 |
Migration mode. |
|
648 |
``cleanup`` (bool) |
|
649 |
Whether a previously failed migration should be cleaned up. |
|
650 |
|
|
651 |
|
|
632 | 652 |
``/2/instances/[instance_name]/tags`` |
633 | 653 |
+++++++++++++++++++++++++++++++++++++ |
634 | 654 |
|
b/lib/rapi/connector.py | ||
---|---|---|
209 | 209 |
rlib2.R_2_instances_name_prepare_export, |
210 | 210 |
re.compile(r'^/2/instances/(%s)/export$' % instance_name_pattern): |
211 | 211 |
rlib2.R_2_instances_name_export, |
212 |
re.compile(r'^/2/instances/(%s)/migrate$' % instance_name_pattern): |
|
213 |
rlib2.R_2_instances_name_migrate, |
|
212 | 214 |
|
213 | 215 |
"/2/jobs": rlib2.R_2_jobs, |
214 | 216 |
re.compile(r'/2/jobs/(%s)$' % job_id_pattern): |
b/lib/rapi/rlib2.py | ||
---|---|---|
991 | 991 |
return baserlib.SubmitJob([op]) |
992 | 992 |
|
993 | 993 |
|
994 |
def _ParseMigrateInstanceRequest(name, data): |
|
995 |
"""Parses a request for an instance migration. |
|
996 |
|
|
997 |
@rtype: L{opcodes.OpMigrateInstance} |
|
998 |
@return: Instance migration opcode |
|
999 |
|
|
1000 |
""" |
|
1001 |
mode = baserlib.CheckParameter(data, "mode", default=None) |
|
1002 |
cleanup = baserlib.CheckParameter(data, "cleanup", exptype=bool, |
|
1003 |
default=False) |
|
1004 |
|
|
1005 |
return opcodes.OpMigrateInstance(instance_name=name, mode=mode, |
|
1006 |
cleanup=cleanup) |
|
1007 |
|
|
1008 |
|
|
1009 |
class R_2_instances_name_migrate(baserlib.R_Generic): |
|
1010 |
"""/2/instances/[instance_name]/migrate resource. |
|
1011 |
|
|
1012 |
""" |
|
1013 |
def PUT(self): |
|
1014 |
"""Migrates an instance. |
|
1015 |
|
|
1016 |
@return: a job id |
|
1017 |
|
|
1018 |
""" |
|
1019 |
baserlib.CheckType(self.request_body, dict, "Body contents") |
|
1020 |
|
|
1021 |
op = _ParseMigrateInstanceRequest(self.items[0], self.request_body) |
|
1022 |
|
|
1023 |
return baserlib.SubmitJob([op]) |
|
1024 |
|
|
1025 |
|
|
994 | 1026 |
class _R_Tags(baserlib.R_Generic): |
995 | 1027 |
""" Quasiclass for tagging resources |
996 | 1028 |
|
b/test/ganeti.rapi.rlib2_unittest.py | ||
---|---|---|
223 | 223 |
{ "remove_instance": "False", }) |
224 | 224 |
|
225 | 225 |
|
226 |
class TestParseMigrateInstanceRequest(testutils.GanetiTestCase): |
|
227 |
def setUp(self): |
|
228 |
testutils.GanetiTestCase.setUp(self) |
|
229 |
|
|
230 |
self.Parse = rlib2._ParseMigrateInstanceRequest |
|
231 |
|
|
232 |
def test(self): |
|
233 |
name = "instYooho6ek" |
|
234 |
|
|
235 |
for cleanup in [False, True]: |
|
236 |
for mode in constants.HT_MIGRATION_MODES: |
|
237 |
data = { |
|
238 |
"cleanup": cleanup, |
|
239 |
"mode": mode, |
|
240 |
} |
|
241 |
op = self.Parse(name, data) |
|
242 |
self.assert_(isinstance(op, opcodes.OpMigrateInstance)) |
|
243 |
self.assertEqual(op.instance_name, name) |
|
244 |
self.assertEqual(op.mode, mode) |
|
245 |
self.assertEqual(op.cleanup, cleanup) |
|
246 |
|
|
247 |
def testDefaults(self): |
|
248 |
name = "instnohZeex0" |
|
249 |
|
|
250 |
op = self.Parse(name, {}) |
|
251 |
self.assert_(isinstance(op, opcodes.OpMigrateInstance)) |
|
252 |
self.assertEqual(op.instance_name, name) |
|
253 |
self.assertEqual(op.mode, None) |
|
254 |
self.assertFalse(op.cleanup) |
|
255 |
|
|
256 |
|
|
226 | 257 |
if __name__ == '__main__': |
227 | 258 |
testutils.GanetiTestProgram() |
Also available in: Unified diff