Revision 941b9309

b/doc/rapi.rst
863 863
    evacuate?iallocator=[iallocator]
864 864
    evacuate?remote_node=[nodeX.example.com]
865 865

  
866
The result value will be a list, each element being a triple of the job
867
id (for this specific evacuation), the instance which is being evacuated
868
by this job, and the node to which it is being relocated. In case the
869
node is already empty, the result will be an empty list (without any
870
jobs being submitted).
871

  
872
And additional parameter ``early_release`` signifies whether to try to
873
parallelize the evacuations, at the risk of increasing I/O contention
874
and increasing the chances of data loss, if the primary node of any of
875
the instances being evacuated is not fully healthy.
876

  
877
If the dry-run parameter was specified, then the evacuation jobs were
878
not actually submitted, and the job IDs will be null.
879

  
880

  
866 881
``/2/nodes/[node_name]/migrate``
867 882
+++++++++++++++++++++++++++++++++
868 883

  
b/lib/rapi/client.py
1022 1022
                             None, None)
1023 1023

  
1024 1024
  def EvacuateNode(self, node, iallocator=None, remote_node=None,
1025
                   dry_run=False):
1025
                   dry_run=False, early_release=False):
1026 1026
    """Evacuates instances from a Ganeti node.
1027 1027

  
1028 1028
    @type node: str
......
1033 1033
    @param remote_node: node to evaucate to
1034 1034
    @type dry_run: bool
1035 1035
    @param dry_run: whether to perform a dry run
1036
    @type early_release: bool
1037
    @param early_release: whether to enable parallelization
1036 1038

  
1037
    @rtype: int
1038
    @return: job id
1039
    @rtype: list
1040
    @return: list of (job ID, instance name, new secondary node); if
1041
        dry_run was specified, then the actual move jobs were not
1042
        submitted and the job IDs will be C{None}
1039 1043

  
1040
    @raises GanetiApiError: if an iallocator and remote_node are both specified
1044
    @raises GanetiApiError: if an iallocator and remote_node are both
1045
        specified
1041 1046

  
1042 1047
    """
1043 1048
    if iallocator and remote_node:
......
1050 1055
      query.append(("remote_node", remote_node))
1051 1056
    if dry_run:
1052 1057
      query.append(("dry-run", 1))
1058
    if early_release:
1059
      query.append(("early_release", 1))
1053 1060

  
1054 1061
    return self._SendRequest(HTTP_POST,
1055 1062
                             ("/%s/nodes/%s/evacuate" %
b/lib/rapi/rlib2.py
389 389
    node_name = self.items[0]
390 390
    remote_node = self._checkStringVariable("remote_node", default=None)
391 391
    iallocator = self._checkStringVariable("iallocator", default=None)
392
    early_r = bool(self._checkIntVariable("early_release", default=0))
393
    dry_run = bool(self.dryRun())
392 394

  
393
    op = opcodes.OpEvacuateNode(node_name=node_name,
394
                                remote_node=remote_node,
395
                                iallocator=iallocator)
395
    cl = baserlib.GetClient()
396 396

  
397
    return baserlib.SubmitJob([op])
397
    op = opcodes.OpNodeEvacuationStrategy(nodes=[node_name],
398
                                          iallocator=iallocator,
399
                                          remote_node=remote_node)
400

  
401
    job_id = baserlib.SubmitJob([op], cl)
402
    # we use custom feedback function, instead of print we log the status
403
    result = cli.PollJob(job_id, cl, feedback_fn=baserlib.FeedbackFn)
404

  
405
    jobs = []
406
    for iname, node in result:
407
      if dry_run:
408
        jid = None
409
      else:
410
        op = opcodes.OpReplaceDisks(instance_name=iname,
411
                                    remote_node=node, disks=[],
412
                                    mode=constants.REPLACE_DISK_CHG,
413
                                    early_release=early_r)
414
        jid = baserlib.SubmitJob([op])
415
      jobs.append((jid, iname, node))
416

  
417
    return jobs
398 418

  
399 419

  
400 420
class R_2_nodes_name_migrate(baserlib.R_Generic):

Also available in: Unified diff