Revision b7a1c816 lib/rapi/rlib2.py
b/lib/rapi/rlib2.py | ||
---|---|---|
104 | 104 |
# Feature string for instance reinstall request version 1 |
105 | 105 |
_INST_REINSTALL_REQV1 = "instance-reinstall-reqv1" |
106 | 106 |
|
107 |
# Feature string for node migration version 1 |
|
108 |
_NODE_MIGRATE_REQV1 = "node-migrate-reqv1" |
|
109 |
|
|
107 | 110 |
# Timeout for /2/jobs/[job_id]/wait. Gives job up to 10 seconds to change. |
108 | 111 |
_WFJC_TIMEOUT = 10 |
109 | 112 |
|
... | ... | |
145 | 148 |
"""Returns list of optional RAPI features implemented. |
146 | 149 |
|
147 | 150 |
""" |
148 |
return [_INST_CREATE_REQV1, _INST_REINSTALL_REQV1] |
|
151 |
return [_INST_CREATE_REQV1, _INST_REINSTALL_REQV1, _NODE_MIGRATE_REQV1]
|
|
149 | 152 |
|
150 | 153 |
|
151 | 154 |
class R_2_os(baserlib.R_Generic): |
... | ... | |
455 | 458 |
""" |
456 | 459 |
node_name = self.items[0] |
457 | 460 |
|
458 |
if "live" in self.queryargs and "mode" in self.queryargs: |
|
459 |
raise http.HttpBadRequest("Only one of 'live' and 'mode' should" |
|
460 |
" be passed") |
|
461 |
elif "live" in self.queryargs: |
|
462 |
if self._checkIntVariable("live", default=1): |
|
463 |
mode = constants.HT_MIGRATION_LIVE |
|
461 |
if self.queryargs: |
|
462 |
# Support old-style requests |
|
463 |
if "live" in self.queryargs and "mode" in self.queryargs: |
|
464 |
raise http.HttpBadRequest("Only one of 'live' and 'mode' should" |
|
465 |
" be passed") |
|
466 |
|
|
467 |
if "live" in self.queryargs: |
|
468 |
if self._checkIntVariable("live", default=1): |
|
469 |
mode = constants.HT_MIGRATION_LIVE |
|
470 |
else: |
|
471 |
mode = constants.HT_MIGRATION_NONLIVE |
|
464 | 472 |
else: |
465 |
mode = constants.HT_MIGRATION_NONLIVE |
|
473 |
mode = self._checkStringVariable("mode", default=None) |
|
474 |
|
|
475 |
data = { |
|
476 |
"mode": mode, |
|
477 |
} |
|
466 | 478 |
else: |
467 |
mode = self._checkStringVariable("mode", default=None)
|
|
479 |
data = self.request_body
|
|
468 | 480 |
|
469 |
op = opcodes.OpNodeMigrate(node_name=node_name, mode=mode) |
|
481 |
op = baserlib.FillOpcode(opcodes.OpNodeMigrate, data, { |
|
482 |
"node_name": node_name, |
|
483 |
}) |
|
470 | 484 |
|
471 | 485 |
return baserlib.SubmitJob([op]) |
472 | 486 |
|
Also available in: Unified diff