Revision b262a5c6
b/lib/backend.py | ||
---|---|---|
1934 | 1934 |
except Exception, err: # pylint: disable=W0703 |
1935 | 1935 |
_Fail("Failed to get migration status: %s", err, exc=True) |
1936 | 1936 |
|
1937 |
def HotplugDevice(instance, action, dev_type, device, extra, seq): |
|
1938 |
"""Hotplug a device |
|
1939 |
|
|
1940 |
Hotplug is currently supported only for KVM Hypervisor. |
|
1941 |
@type instance: L{objects.Instance} |
|
1942 |
@param instance: the instance to which we hotplug a device |
|
1943 |
@type action: string |
|
1944 |
@param action: the hotplug action to perform |
|
1945 |
@type dev_type: string |
|
1946 |
@param dev_type: the device type to hotplug |
|
1947 |
@type device: either L{objects.NIC} or L{objects.Disk} |
|
1948 |
@param device: the device object to hotplug |
|
1949 |
@type extra: string |
|
1950 |
@param extra: extra info used by hotplug code (e.g. disk link) |
|
1951 |
@type seq: int |
|
1952 |
@param seq: the index of the device from master perspective |
|
1953 |
@raise RPCFail: in case instance does not have KVM hypervisor |
|
1954 |
|
|
1955 |
""" |
|
1956 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1957 |
try: |
|
1958 |
getattr(hyper, "HotplugDevice") |
|
1959 |
except NameError: |
|
1960 |
_Fail("Hotplug is not supported for %s hypervisor", |
|
1961 |
instance.hypervisor, exc=True ) |
|
1962 |
return hyper.HotplugDevice(instance, action, dev_type, device, extra, seq) |
|
1937 | 1963 |
|
1938 | 1964 |
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor): |
1939 | 1965 |
"""Creates a block device for an instance. |
b/lib/rpc.py | ||
---|---|---|
820 | 820 |
rpc_defs.ED_INST_DICT_HVP_BEP_DP: self._InstDictHvpBepDp, |
821 | 821 |
rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp, |
822 | 822 |
rpc_defs.ED_NIC_DICT: self._NicDict, |
823 |
rpc_defs.ED_DEVICE_DICT: self._DeviceDict, |
|
823 | 824 |
|
824 | 825 |
# Encoders annotating disk parameters |
825 | 826 |
rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP, |
... | ... | |
858 | 859 |
n.netinfo = objects.Network.ToDict(nobj) |
859 | 860 |
return n.ToDict() |
860 | 861 |
|
862 |
def _DeviceDict(self, device): |
|
863 |
if isinstance(device, objects.NIC): |
|
864 |
return self._NicDict(device) |
|
865 |
elif isinstance(device, objects.Disk): |
|
866 |
return _ObjectToDict(device) |
|
867 |
|
|
861 | 868 |
def _InstDict(self, instance, hvp=None, bep=None, osp=None): |
862 | 869 |
"""Convert the given instance to a dict. |
863 | 870 |
|
b/lib/rpc_defs.py | ||
---|---|---|
72 | 72 |
ED_DISKS_DICT_DP, |
73 | 73 |
ED_MULTI_DISKS_DICT_DP, |
74 | 74 |
ED_SINGLE_DISK_DICT_DP, |
75 |
ED_NIC_DICT) = range(1, 16) |
|
75 |
ED_NIC_DICT, |
|
76 |
ED_DEVICE_DICT) = range(1, 17) |
|
76 | 77 |
|
77 | 78 |
|
78 | 79 |
def _Prepare(calls): |
... | ... | |
296 | 297 |
("reinstall", None, None), |
297 | 298 |
("debug", None, None), |
298 | 299 |
], None, None, "Starts an instance"), |
300 |
("hotplug_device", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
|
301 |
("instance", ED_INST_DICT, "Instance object"), |
|
302 |
("action", None, "Hotplug Action"), |
|
303 |
("dev_type", None, "Device type"), |
|
304 |
("device", ED_DEVICE_DICT, "Device dict"), |
|
305 |
("extra", None, "Extra info for device (dev_path for disk)"), |
|
306 |
("seq", None, "Device seq"), |
|
307 |
], None, None, "Hoplug a device to a running instance"), |
|
299 | 308 |
] |
300 | 309 |
|
301 | 310 |
_IMPEXP_CALLS = [ |
b/lib/server/noded.py | ||
---|---|---|
617 | 617 |
return backend.StartInstance(instance, startup_paused, trail) |
618 | 618 |
|
619 | 619 |
@staticmethod |
620 |
def perspective_hotplug_device(params): |
|
621 |
"""Hotplugs device to a running instance. |
|
622 |
|
|
623 |
""" |
|
624 |
(idict, action, dev_type, ddict, extra, seq) = params |
|
625 |
instance = objects.Instance.FromDict(idict) |
|
626 |
if dev_type == constants.HOTPLUG_DISK: |
|
627 |
device = objects.Disk.FromDict(ddict) |
|
628 |
elif dev_type == constants.HOTPLUG_NIC: |
|
629 |
device = objects.NIC.FromDict(ddict) |
|
630 |
return backend.HotplugDevice(instance, action, dev_type, device, extra, seq) |
|
631 |
|
|
632 |
@staticmethod |
|
620 | 633 |
def perspective_migration_info(params): |
621 | 634 |
"""Gather information about an instance to be migrated. |
622 | 635 |
|
Also available in: Unified diff