Revision 860bf930 lib/backend.py

b/lib/backend.py
1626 1626
    _Fail("Failed to get migration status: %s", err, exc=True)
1627 1627

  
1628 1628

  
1629
def HotplugDevice(instance, action, dev_type, device, extra, seq):
1630
  """Hotplug a device
1631

  
1632
  Hotplug is currently supported only for KVM Hypervisor.
1633
  @type instance: L{objects.Instance}
1634
  @param instance: the instance to which we hotplug a device
1635
  @type action: string
1636
  @param action: the hotplug action to perform
1637
  @type dev_type: string
1638
  @param dev_type: the device type to hotplug
1639
  @type device: either L{objects.NIC} or L{objects.Disk}
1640
  @param device: the device object to hotplug
1641
  @type extra: string
1642
  @param extra: extra info used by hotplug code (e.g. disk link)
1643
  @type seq: int
1644
  @param seq: the index of the device from master perspective
1645
  @raise RPCFail: in case instance does not have KVM hypervisor
1646

  
1647
  """
1648
  hyper = hypervisor.GetHypervisor(instance.hypervisor)
1649
  try:
1650
    hyper.HotplugSupported(instance, action, dev_type)
1651
  except (errors.HotplugError, errors.HypervisorError), err:
1652
    _Fail("Hotplug is not supported: %s", err)
1653

  
1654
  if action == constants.HOTPLUG_ACTION_ADD:
1655
    fn = hyper.HotAddDevice
1656
  elif action == constants.HOTPLUG_ACTION_REMOVE:
1657
    fn = hyper.HotDelDevice
1658
  elif action == constants.HOTPLUG_ACTION_MODIFY:
1659
    fn = hyper.HotModDevice
1660
  else:
1661
    assert action in constants.HOTPLUG_ALL_ACTIONS
1662

  
1663
  return fn(instance, dev_type, device, extra, seq)
1664

  
1665

  
1629 1666
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor):
1630 1667
  """Creates a block device for an instance.
1631 1668

  

Also available in: Unified diff