Revision e5b7c4ca

b/lib/rapi/baserlib.py
252 252
                                " '%s' parameter" % (name,))
253 253
    return val
254 254

  
255
  def _checkStringVariable(self, name, default=None):
256
    """Return the parsed value of an int argument.
257

  
258
    """
259
    val = self.queryargs.get(name, default)
260
    if isinstance(val, list):
261
      if val:
262
        val = val[0]
263
      else:
264
        val = default
265
    return val
266

  
255 267
  def getBodyParameter(self, name, *args):
256 268
    """Check and return the value for a given parameter.
257 269

  
b/lib/rapi/connector.py
163 163
  re.compile(r'^/2/instances/([\w\._-]+)/tags$'): rlib2.R_2_instances_name_tags,
164 164
  re.compile(r'^/2/instances/([\w\._-]+)/reboot$'):
165 165
      rlib2.R_2_instances_name_reboot,
166
  re.compile(r'^/2/instances/([\w\._-]+)/reinstall$'):
167
      rlib2.R_2_instances_name_reinstall,
166 168
  re.compile(r'^/2/instances/([\w\._-]+)/shutdown$'):
167 169
      rlib2.R_2_instances_name_shutdown,
168 170
  re.compile(r'^/2/instances/([\w\._-]+)/startup$'):
b/lib/rapi/rlib2.py
493 493
    return baserlib.SubmitJob([op])
494 494

  
495 495

  
496
class R_2_instances_name_reinstall(baserlib.R_Generic):
497
  """/2/instances/[instance_name]/reinstall resource.
498

  
499
  Implements an instance reinstall.
500

  
501
  """
502

  
503
  DOC_URI = "/2/instances/[instance_name]/reinstall"
504

  
505
  def POST(self):
506
    """Reinstall an instance.
507

  
508
    The URI takes os=name and nostartup=[0|1] optional
509
    parameters. By default, the instance will be started
510
    automatically.
511

  
512
    """
513
    instance_name = self.items[0]
514
    ostype = self._checkStringVariable('os')
515
    nostartup = self._checkIntVariable('nostartup')
516
    ops = [
517
      opcodes.OpShutdownInstance(instance_name=instance_name),
518
      opcodes.OpReinstallInstance(instance_name=instance_name, os_type=ostype),
519
      ]
520
    if not nostartup:
521
      ops.append(opcodes.OpStartupInstance(instance_name=instance_name,
522
                                           force=False))
523
    return baserlib.SubmitJob(ops)
524

  
525

  
496 526
class _R_Tags(baserlib.R_Generic):
497 527
  """ Quasiclass for tagging resources
498 528

  

Also available in: Unified diff