REPLACE_DISK_CHG = "replace_new_secondary"
REPLACE_DISK_AUTO = "replace_auto"
+NODE_EVAC_PRI = "primary-only"
+NODE_EVAC_SEC = "secondary-only"
+NODE_EVAC_ALL = "all"
+
NODE_ROLE_DRAINED = "drained"
NODE_ROLE_MASTER_CANDIATE = "master-candidate"
NODE_ROLE_MASTER = "master"
(GANETI_RAPI_VERSION, instance)), query, None)
def ReplaceInstanceDisks(self, instance, disks=None, mode=REPLACE_DISK_AUTO,
- remote_node=None, iallocator=None, dry_run=False):
+ remote_node=None, iallocator=None):
"""Replaces disks on an instance.
@type instance: str
@type iallocator: str or None
@param iallocator: instance allocator plugin to use (for use with
replace_auto mode)
- @type dry_run: bool
- @param dry_run: whether to perform a dry run
@rtype: string
@return: job id
("mode", mode),
]
- if disks:
+ # TODO: Convert to body parameters
+
+ if disks is not None:
query.append(("disks", ",".join(str(idx) for idx in disks)))
- if remote_node:
+ if remote_node is not None:
query.append(("remote_node", remote_node))
- if iallocator:
+ if iallocator is not None:
query.append(("iallocator", iallocator))
- if dry_run:
- query.append(("dry-run", 1))
-
return self._SendRequest(HTTP_POST,
("/%s/instances/%s/replace-disks" %
(GANETI_RAPI_VERSION, instance)), query, None)
def EvacuateNode(self, node, iallocator=None, remote_node=None,
dry_run=False, early_release=None,
- primary=None, secondary=None, accept_old=False):
+ mode=None, accept_old=False):
"""Evacuates instances from a Ganeti node.
@type node: str
@param dry_run: whether to perform a dry run
@type early_release: bool
@param early_release: whether to enable parallelization
- @type primary: bool
- @param primary: Whether to evacuate primary instances
- @type secondary: bool
- @param secondary: Whether to evacuate secondary instances
+ @type mode: string
+ @param mode: Node evacuation mode
@type accept_old: bool
@param accept_old: Whether caller is ready to accept old-style (pre-2.5)
results
query.append(("dry-run", 1))
if _NODE_EVAC_RES1 in self.GetFeatures():
+ # Server supports body parameters
body = {}
if iallocator is not None:
body["remote_node"] = remote_node
if early_release is not None:
body["early_release"] = early_release
- if primary is not None:
- body["primary"] = primary
- if secondary is not None:
- body["secondary"] = secondary
+ if mode is not None:
+ body["mode"] = mode
else:
# Pre-2.5 request format
body = None
" not accept old-style results (parameter"
" accept_old)")
- if primary or primary is None or not (secondary is None or secondary):
+ # Pre-2.5 servers can only evacuate secondaries
+ if mode is not None and mode != NODE_EVAC_SEC:
raise GanetiApiError("Server can only evacuate secondary instances")
if iallocator: