Revision de40437a lib/rapi/rlib2.py

b/lib/rapi/rlib2.py
107 107
# Feature string for node migration version 1
108 108
_NODE_MIGRATE_REQV1 = "node-migrate-reqv1"
109 109

  
110
# Feature string for node evacuation with LU-generated jobs
111
_NODE_EVAC_RES1 = "node-evac-res1"
112

  
110 113
# Timeout for /2/jobs/[job_id]/wait. Gives job up to 10 seconds to change.
111 114
_WFJC_TIMEOUT = 10
112 115

  
......
148 151
    """Returns list of optional RAPI features implemented.
149 152

  
150 153
    """
151
    return [_INST_CREATE_REQV1, _INST_REINSTALL_REQV1, _NODE_MIGRATE_REQV1]
154
    return [_INST_CREATE_REQV1, _INST_REINSTALL_REQV1, _NODE_MIGRATE_REQV1,
155
            _NODE_EVAC_RES1]
152 156

  
153 157

  
154 158
class R_2_os(baserlib.R_Generic):
......
414 418

  
415 419
  """
416 420
  def POST(self):
417
    """Evacuate all secondary instances off a node.
421
    """Evacuate all instances off a node.
418 422

  
419 423
    """
420
    node_name = self.items[0]
421
    remote_node = self._checkStringVariable("remote_node", default=None)
422
    iallocator = self._checkStringVariable("iallocator", default=None)
423
    early_r = bool(self._checkIntVariable("early_release", default=0))
424
    dry_run = bool(self.dryRun())
425

  
426
    cl = baserlib.GetClient()
427

  
428
    op = opcodes.OpNodeEvacStrategy(nodes=[node_name],
429
                                    iallocator=iallocator,
430
                                    remote_node=remote_node)
431

  
432
    job_id = baserlib.SubmitJob([op], cl)
433
    # we use custom feedback function, instead of print we log the status
434
    result = cli.PollJob(job_id, cl, feedback_fn=baserlib.FeedbackFn)
424
    op = baserlib.FillOpcode(opcodes.OpNodeEvacuate, self.request_body, {
425
      "node_name": self.items[0],
426
      "dry_run": self.dryRun(),
427
      })
435 428

  
436
    jobs = []
437
    for iname, node in result[0]:
438
      if dry_run:
439
        jid = None
440
      else:
441
        op = opcodes.OpInstanceReplaceDisks(instance_name=iname,
442
                                            remote_node=node, disks=[],
443
                                            mode=constants.REPLACE_DISK_CHG,
444
                                            early_release=early_r)
445
        jid = baserlib.SubmitJob([op])
446
      jobs.append((jid, iname, node))
447

  
448
    return jobs
429
    return baserlib.SubmitJob([op])
449 430

  
450 431

  
451 432
class R_2_nodes_name_migrate(baserlib.R_Generic):

Also available in: Unified diff