Revision 58e356a9 lib/hypervisor/hv_xen.py

b/lib/hypervisor/hv_xen.py
358 358

  
359 359
    return cmd
360 360

  
361
  def _RunXen(self, args):
361
  def _RunXen(self, args, hvparams=None):
362 362
    """Wrapper around L{utils.process.RunCmd} to run Xen command.
363 363

  
364
    @type hvparams: dict of strings
365
    @param hvparams: dictionary of hypervisor params
364 366
    @see: L{utils.process.RunCmd}
365 367

  
366 368
    """
367
    cmd = [self._GetCommand()]
369
    cmd = [self._GetCommand(hvparams=hvparams)]
368 370
    cmd.extend(args)
369 371

  
370 372
    return self._run_cmd_fn(cmd)
......
433 435
    utils.RenameFile(old_filename, new_filename)
434 436
    return new_filename
435 437

  
436
  def _GetInstanceList(self, include_node):
438
  def _GetInstanceList(self, include_node, hvparams=None):
437 439
    """Wrapper around module level L{_GetInstanceList}.
438 440

  
439 441
    """
440
    return _GetInstanceList(lambda: self._RunXen(["list"]), include_node)
442
    return _GetInstanceList(lambda: self._RunXen(["list"], hvparams=hvparams),
443
                            include_node)
441 444

  
442
  def ListInstances(self):
445
  def ListInstances(self, hvparams=None):
443 446
    """Get the list of running instances.
444 447

  
445 448
    """
446
    instance_list = self._GetInstanceList(False)
449
    instance_list = self._GetInstanceList(False, hvparams=hvparams)
447 450
    names = [info[0] for info in instance_list]
448 451
    return names
449 452

  
......
498 501
      cmd.append("-p")
499 502
    cmd.append(self._ConfigFileName(instance.name))
500 503

  
501
    result = self._RunXen(cmd)
504
    result = self._RunXen(cmd, hvparams=instance.hvparams)
502 505
    if result.failed:
503 506
      # Move the Xen configuration file to the log directory to avoid
504 507
      # leaving a stale config file behind.
......
515 518
    if name is None:
516 519
      name = instance.name
517 520

  
518
    return self._StopInstance(name, force)
521
    return self._StopInstance(name, force, instance.hvparams)
519 522

  
520
  def _StopInstance(self, name, force):
523
  def _StopInstance(self, name, force, hvparams):
521 524
    """Stop an instance.
522 525

  
526
    @type name: string
527
    @param name: name of the instance to be shutdown
528
    @type force: boolean
529
    @param force: flag specifying whether shutdown should be forced
530
    @type hvparams: dict of string
531
    @param hvparams: hypervisor parameters of the instance
532

  
523 533
    """
524 534
    if force:
525 535
      action = "destroy"
526 536
    else:
527 537
      action = "shutdown"
528 538

  
529
    result = self._RunXen([action, name])
539
    result = self._RunXen([action, name], hvparams=hvparams)
530 540
    if result.failed:
531 541
      raise errors.HypervisorError("Failed to stop instance %s: %s, %s" %
532 542
                                   (name, result.fail_reason, result.output))
......
544 554
      raise errors.HypervisorError("Failed to reboot instance %s,"
545 555
                                   " not running" % instance.name)
546 556

  
547
    result = self._RunXen(["reboot", instance.name])
557
    result = self._RunXen(["reboot", instance.name], hvparams=instance.hvparams)
548 558
    if result.failed:
549 559
      raise errors.HypervisorError("Failed to reboot instance %s: %s, %s" %
550 560
                                   (instance.name, result.fail_reason,
......
577 587
    @param mem: actual memory size to use for instance runtime
578 588

  
579 589
    """
580
    result = self._RunXen(["mem-set", instance.name, mem])
590
    result = self._RunXen(["mem-set", instance.name, mem],
591
                          hvparams=instance.hvparams)
581 592
    if result.failed:
582 593
      raise errors.HypervisorError("Failed to balloon instance %s: %s (%s)" %
583 594
                                   (instance.name, result.fail_reason,
......
731 742

  
732 743
    args.extend([instance_name, target])
733 744

  
734
    result = self._RunXen(args)
745
    result = self._RunXen(args, hvparams=hvparams)
735 746
    if result.failed:
736 747
      raise errors.HypervisorError("Failed to migrate instance %s: %s" %
737 748
                                   (instance_name, result.output))

Also available in: Unified diff