Revision 34754279 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
8719 | 8719 |
if hasattr(lu, 'hotplug_info'): |
8720 | 8720 |
info = lu.hotplug_info |
8721 | 8721 |
elif hasattr(lu, 'instance') and hasattr(lu.instance, 'hotplug_info'): |
8722 |
return lu.cfg.GetPCIInfo(lu.instance.name, dev_type) |
|
8722 |
idx, pci = lu.cfg.GetPCIInfo(lu.instance.name, dev_type) |
|
8723 |
lu.LogInfo("Choosing pci slot %d" % pci) |
|
8724 |
return idx, pci |
|
8723 | 8725 |
|
8724 | 8726 |
if info: |
8725 | 8727 |
idx = getattr(info, dev_type) |
8726 | 8728 |
setattr(info, dev_type, idx+1) |
8727 | 8729 |
pci = info.pci_pool.pop() |
8730 |
lu.LogInfo("Choosing pci slot %d" % pci) |
|
8728 | 8731 |
return idx, pci |
8729 | 8732 |
|
8733 |
lu.LogWarning("Hotplug not supported for this instance.") |
|
8730 | 8734 |
return None, None |
8731 | 8735 |
|
8732 | 8736 |
|
... | ... | |
9755 | 9759 |
|
9756 | 9760 |
self.hotplug_info = None |
9757 | 9761 |
if self.op.hotplug: |
9762 |
self.LogInfo("Enabling hotplug.") |
|
9758 | 9763 |
self.hotplug_info = objects.HotplugInfo(disks=0, nics=0, |
9759 | 9764 |
pci_pool=list(range(16,32))) |
9760 | 9765 |
# NIC buildup |
... | ... | |
12815 | 12820 |
disk.iv_name, disk, node, err) |
12816 | 12821 |
|
12817 | 12822 |
if self.op.hotplug and disk.pci: |
12823 |
self.LogInfo("Trying to hotplug device.") |
|
12818 | 12824 |
disk_ok, device_info = _AssembleInstanceDisks(self, self.instance, |
12819 | 12825 |
[disk], check=False) |
12820 | 12826 |
_, _, dev_path = device_info[0] |
... | ... | |
12847 | 12853 |
" without removing it with hotplug", |
12848 | 12854 |
errors.ECODE_INVAL) |
12849 | 12855 |
if self.op.hotplug and root.pci: |
12856 |
self.LogInfo("Trying to hotplug device.") |
|
12850 | 12857 |
self.rpc.call_hot_del_disk(self.instance.primary_node, |
12851 | 12858 |
self.instance, root, idx) |
12852 | 12859 |
_ShutdownInstanceDisks(self, self.instance, [root]) |
... | ... | |
12880 | 12887 |
# return changes |
12881 | 12888 |
if self.op.hotplug: |
12882 | 12889 |
nic_idx, pci = _GetPCIInfo(self, 'nics') |
12883 |
nic.idx = nic_idx |
|
12884 |
nic.pci = pci |
|
12885 |
result = self.rpc.call_hot_add_nic(self.instance.primary_node, |
|
12886 |
self.instance, nic, idx) |
|
12890 |
if pci is not None: |
|
12891 |
nic.idx = nic_idx |
|
12892 |
nic.pci = pci |
|
12893 |
result = self.rpc.call_hot_add_nic(self.instance.primary_node, |
|
12894 |
self.instance, nic, idx) |
|
12887 | 12895 |
desc = [ |
12888 | 12896 |
("nic.%d" % idx, |
12889 | 12897 |
"add:mac=%s,ip=%s,mode=%s,link=%s" % |
... | ... | |
12912 | 12920 |
#TODO: log warning in case hotplug is not possible |
12913 | 12921 |
# handle errors |
12914 | 12922 |
if self.op.hotplug and nic.pci: |
12923 |
self.LogInfo("Trying to hotplug device.") |
|
12915 | 12924 |
self.rpc.call_hot_del_nic(self.instance.primary_node, |
12916 | 12925 |
self.instance, nic, idx) |
12917 | 12926 |
result = self.rpc.call_hot_add_nic(self.instance.primary_node, |
... | ... | |
12926 | 12935 |
#TODO: log warning in case hotplug is not possible |
12927 | 12936 |
# handle errors |
12928 | 12937 |
if self.op.hotplug and nic.pci: |
12938 |
self.LogInfo("Trying to hotplug device.") |
|
12929 | 12939 |
self.rpc.call_hot_del_nic(self.instance.primary_node, |
12930 | 12940 |
self.instance, nic, idx) |
12931 | 12941 |
self.cfg.UpdatePCIInfo(self.instance.name, nic.pci) |
Also available in: Unified diff