Skip to content
Snippets Groups Projects
Commit 34754279 authored by Dimitris Aragriorgs's avatar Dimitris Aragriorgs
Browse files

Add logging in case of hotplug


Signed-off-by: default avatarDimitris Aragriorgs <dimara@grnet.gr>
parent 61f46231
No related branches found
No related tags found
No related merge requests found
...@@ -8719,14 +8719,18 @@ def _GetPCIInfo(lu, dev_type): ...@@ -8719,14 +8719,18 @@ def _GetPCIInfo(lu, dev_type):
if hasattr(lu, 'hotplug_info'): if hasattr(lu, 'hotplug_info'):
info = lu.hotplug_info info = lu.hotplug_info
elif hasattr(lu, 'instance') and hasattr(lu.instance, 'hotplug_info'): elif hasattr(lu, 'instance') and hasattr(lu.instance, 'hotplug_info'):
return lu.cfg.GetPCIInfo(lu.instance.name, dev_type) idx, pci = lu.cfg.GetPCIInfo(lu.instance.name, dev_type)
lu.LogInfo("Choosing pci slot %d" % pci)
return idx, pci
   
if info: if info:
idx = getattr(info, dev_type) idx = getattr(info, dev_type)
setattr(info, dev_type, idx+1) setattr(info, dev_type, idx+1)
pci = info.pci_pool.pop() pci = info.pci_pool.pop()
lu.LogInfo("Choosing pci slot %d" % pci)
return idx, pci return idx, pci
   
lu.LogWarning("Hotplug not supported for this instance.")
return None, None return None, None
   
   
...@@ -9755,6 +9759,7 @@ class LUInstanceCreate(LogicalUnit): ...@@ -9755,6 +9759,7 @@ class LUInstanceCreate(LogicalUnit):
   
self.hotplug_info = None self.hotplug_info = None
if self.op.hotplug: if self.op.hotplug:
self.LogInfo("Enabling hotplug.")
self.hotplug_info = objects.HotplugInfo(disks=0, nics=0, self.hotplug_info = objects.HotplugInfo(disks=0, nics=0,
pci_pool=list(range(16,32))) pci_pool=list(range(16,32)))
# NIC buildup # NIC buildup
...@@ -12815,6 +12820,7 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -12815,6 +12820,7 @@ class LUInstanceSetParams(LogicalUnit):
disk.iv_name, disk, node, err) disk.iv_name, disk, node, err)
   
if self.op.hotplug and disk.pci: if self.op.hotplug and disk.pci:
self.LogInfo("Trying to hotplug device.")
disk_ok, device_info = _AssembleInstanceDisks(self, self.instance, disk_ok, device_info = _AssembleInstanceDisks(self, self.instance,
[disk], check=False) [disk], check=False)
_, _, dev_path = device_info[0] _, _, dev_path = device_info[0]
...@@ -12847,6 +12853,7 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -12847,6 +12853,7 @@ class LUInstanceSetParams(LogicalUnit):
" without removing it with hotplug", " without removing it with hotplug",
errors.ECODE_INVAL) errors.ECODE_INVAL)
if self.op.hotplug and root.pci: if self.op.hotplug and root.pci:
self.LogInfo("Trying to hotplug device.")
self.rpc.call_hot_del_disk(self.instance.primary_node, self.rpc.call_hot_del_disk(self.instance.primary_node,
self.instance, root, idx) self.instance, root, idx)
_ShutdownInstanceDisks(self, self.instance, [root]) _ShutdownInstanceDisks(self, self.instance, [root])
...@@ -12880,10 +12887,11 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -12880,10 +12887,11 @@ class LUInstanceSetParams(LogicalUnit):
# return changes # return changes
if self.op.hotplug: if self.op.hotplug:
nic_idx, pci = _GetPCIInfo(self, 'nics') nic_idx, pci = _GetPCIInfo(self, 'nics')
nic.idx = nic_idx if pci is not None:
nic.pci = pci nic.idx = nic_idx
result = self.rpc.call_hot_add_nic(self.instance.primary_node, nic.pci = pci
self.instance, nic, idx) result = self.rpc.call_hot_add_nic(self.instance.primary_node,
self.instance, nic, idx)
desc = [ desc = [
("nic.%d" % idx, ("nic.%d" % idx,
"add:mac=%s,ip=%s,mode=%s,link=%s" % "add:mac=%s,ip=%s,mode=%s,link=%s" %
...@@ -12912,6 +12920,7 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -12912,6 +12920,7 @@ class LUInstanceSetParams(LogicalUnit):
#TODO: log warning in case hotplug is not possible #TODO: log warning in case hotplug is not possible
# handle errors # handle errors
if self.op.hotplug and nic.pci: if self.op.hotplug and nic.pci:
self.LogInfo("Trying to hotplug device.")
self.rpc.call_hot_del_nic(self.instance.primary_node, self.rpc.call_hot_del_nic(self.instance.primary_node,
self.instance, nic, idx) self.instance, nic, idx)
result = self.rpc.call_hot_add_nic(self.instance.primary_node, result = self.rpc.call_hot_add_nic(self.instance.primary_node,
...@@ -12926,6 +12935,7 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -12926,6 +12935,7 @@ class LUInstanceSetParams(LogicalUnit):
#TODO: log warning in case hotplug is not possible #TODO: log warning in case hotplug is not possible
# handle errors # handle errors
if self.op.hotplug and nic.pci: if self.op.hotplug and nic.pci:
self.LogInfo("Trying to hotplug device.")
self.rpc.call_hot_del_nic(self.instance.primary_node, self.rpc.call_hot_del_nic(self.instance.primary_node,
self.instance, nic, idx) self.instance, nic, idx)
self.cfg.UpdatePCIInfo(self.instance.name, nic.pci) self.cfg.UpdatePCIInfo(self.instance.name, nic.pci)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment