Revision de40437a lib/rapi/client.py
b/lib/rapi/client.py | ||
---|---|---|
93 | 93 |
_INST_CREATE_REQV1 = "instance-create-reqv1" |
94 | 94 |
_INST_REINSTALL_REQV1 = "instance-reinstall-reqv1" |
95 | 95 |
_NODE_MIGRATE_REQV1 = "node-migrate-reqv1" |
96 |
_NODE_EVAC_RES1 = "node-evac-res1" |
|
96 | 97 |
_INST_NIC_PARAMS = frozenset(["mac", "ip", "mode", "link"]) |
97 | 98 |
_INST_CREATE_V0_DISK_PARAMS = frozenset(["size"]) |
98 | 99 |
_INST_CREATE_V0_PARAMS = frozenset([ |
... | ... | |
1250 | 1251 |
None, None) |
1251 | 1252 |
|
1252 | 1253 |
def EvacuateNode(self, node, iallocator=None, remote_node=None, |
1253 |
dry_run=False, early_release=False): |
|
1254 |
dry_run=False, early_release=None, |
|
1255 |
primary=None, secondary=None, accept_old=False): |
|
1254 | 1256 |
"""Evacuates instances from a Ganeti node. |
1255 | 1257 |
|
1256 | 1258 |
@type node: str |
... | ... | |
1263 | 1265 |
@param dry_run: whether to perform a dry run |
1264 | 1266 |
@type early_release: bool |
1265 | 1267 |
@param early_release: whether to enable parallelization |
1266 |
|
|
1267 |
@rtype: list |
|
1268 |
@return: list of (job ID, instance name, new secondary node); if |
|
1269 |
dry_run was specified, then the actual move jobs were not |
|
1270 |
submitted and the job IDs will be C{None} |
|
1268 |
@type primary: bool |
|
1269 |
@param primary: Whether to evacuate primary instances |
|
1270 |
@type secondary: bool |
|
1271 |
@param secondary: Whether to evacuate secondary instances |
|
1272 |
@type accept_old: bool |
|
1273 |
@param accept_old: Whether caller is ready to accept old-style (pre-2.5) |
|
1274 |
results |
|
1275 |
|
|
1276 |
@rtype: string, or a list for pre-2.5 results |
|
1277 |
@return: Job ID or, if C{accept_old} is set and server is pre-2.5, |
|
1278 |
list of (job ID, instance name, new secondary node); if dry_run was |
|
1279 |
specified, then the actual move jobs were not submitted and the job IDs |
|
1280 |
will be C{None} |
|
1271 | 1281 |
|
1272 | 1282 |
@raises GanetiApiError: if an iallocator and remote_node are both |
1273 | 1283 |
specified |
... | ... | |
1277 | 1287 |
raise GanetiApiError("Only one of iallocator or remote_node can be used") |
1278 | 1288 |
|
1279 | 1289 |
query = [] |
1280 |
if iallocator: |
|
1281 |
query.append(("iallocator", iallocator)) |
|
1282 |
if remote_node: |
|
1283 |
query.append(("remote_node", remote_node)) |
|
1284 | 1290 |
if dry_run: |
1285 | 1291 |
query.append(("dry-run", 1)) |
1286 |
if early_release: |
|
1287 |
query.append(("early_release", 1)) |
|
1292 |
|
|
1293 |
if _NODE_EVAC_RES1 in self.GetFeatures(): |
|
1294 |
body = {} |
|
1295 |
|
|
1296 |
if iallocator is not None: |
|
1297 |
body["iallocator"] = iallocator |
|
1298 |
if remote_node is not None: |
|
1299 |
body["remote_node"] = remote_node |
|
1300 |
if early_release is not None: |
|
1301 |
body["early_release"] = early_release |
|
1302 |
if primary is not None: |
|
1303 |
body["primary"] = primary |
|
1304 |
if secondary is not None: |
|
1305 |
body["secondary"] = secondary |
|
1306 |
else: |
|
1307 |
# Pre-2.5 request format |
|
1308 |
body = None |
|
1309 |
|
|
1310 |
if not accept_old: |
|
1311 |
raise GanetiApiError("Server is version 2.4 or earlier and caller does" |
|
1312 |
" not accept old-style results (parameter" |
|
1313 |
" accept_old)") |
|
1314 |
|
|
1315 |
if primary or primary is None or not (secondary is None or secondary): |
|
1316 |
raise GanetiApiError("Server can only evacuate secondary instances") |
|
1317 |
|
|
1318 |
if iallocator: |
|
1319 |
query.append(("iallocator", iallocator)) |
|
1320 |
if remote_node: |
|
1321 |
query.append(("remote_node", remote_node)) |
|
1322 |
if early_release: |
|
1323 |
query.append(("early_release", 1)) |
|
1288 | 1324 |
|
1289 | 1325 |
return self._SendRequest(HTTP_POST, |
1290 | 1326 |
("/%s/nodes/%s/evacuate" % |
1291 |
(GANETI_RAPI_VERSION, node)), query, None)
|
|
1327 |
(GANETI_RAPI_VERSION, node)), query, body)
|
|
1292 | 1328 |
|
1293 | 1329 |
def MigrateNode(self, node, mode=None, dry_run=False, iallocator=None, |
1294 | 1330 |
target_node=None): |
Also available in: Unified diff