Handle any error from libvirt operations
A review of the helper code which wraps libvirtmod's compiled module which implements the libvirt wrapper for Python, which we refer to and call as libvirt or python-libvirt, reveals that it appears possible for AttributeError and KeyError to be raised up to the intermediate library level. While everything else refers to libvirtError, it still seems possible, albeit remote, that the generated code and interactions may still raise exceptions besides libvirtError which previously would result in unexpected behavior. What we sometimes see on the ipmitool side is a generic "Error: Unable to establish IPMI v2 / RMCP+ session" error which is generated in many cases, including when no response is received. So, since libvirtError is based on an Exception class, changes exception handling to just catch and log based upon Exception. Change-Id: I8159f5d1de2acb0678e7c85306413fab6999e615
This commit is contained in:
parent
c1b75e0a25
commit
8fa7e1f9d8
@ -115,7 +115,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
boot_element.set('dev', device)
|
boot_element.set('dev', device)
|
||||||
|
|
||||||
conn.defineXML(ET.tostring(tree, encoding="unicode"))
|
conn.defineXML(ET.tostring(tree, encoding="unicode"))
|
||||||
except libvirt.libvirtError:
|
except Exception:
|
||||||
LOG.error('Failed setting the boot device %(bootdev)s for '
|
LOG.error('Failed setting the boot device %(bootdev)s for '
|
||||||
'domain %(domain)s', {'bootdev': device,
|
'domain %(domain)s', {'bootdev': device,
|
||||||
'domain': self.domain_name})
|
'domain': self.domain_name})
|
||||||
@ -130,7 +130,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if domain.isActive():
|
if domain.isActive():
|
||||||
return POWERON
|
return POWERON
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
msg = ('Error getting the power state of domain %(domain)s. '
|
msg = ('Error getting the power state of domain %(domain)s. '
|
||||||
'Error: %(error)s' % {'domain': self.domain_name,
|
'Error: %(error)s' % {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
@ -147,7 +147,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if domain.isActive():
|
if domain.isActive():
|
||||||
domain.injectNMI()
|
domain.injectNMI()
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
LOG.error('Error powering diag the domain %(domain)s. '
|
LOG.error('Error powering diag the domain %(domain)s. '
|
||||||
'Error: %(error)s', {'domain': self.domain_name,
|
'Error: %(error)s', {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
@ -162,7 +162,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if domain.isActive():
|
if domain.isActive():
|
||||||
domain.destroy()
|
domain.destroy()
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
LOG.error('Error powering off the domain %(domain)s. '
|
LOG.error('Error powering off the domain %(domain)s. '
|
||||||
'Error: %(error)s', {'domain': self.domain_name,
|
'Error: %(error)s', {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
@ -177,7 +177,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if not domain.isActive():
|
if not domain.isActive():
|
||||||
domain.create()
|
domain.create()
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
LOG.error('Error powering on the domain %(domain)s. '
|
LOG.error('Error powering on the domain %(domain)s. '
|
||||||
'Error: %(error)s', {'domain': self.domain_name,
|
'Error: %(error)s', {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
@ -192,7 +192,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if domain.isActive():
|
if domain.isActive():
|
||||||
domain.shutdown()
|
domain.shutdown()
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
LOG.error('Error soft powering off the domain %(domain)s. '
|
LOG.error('Error soft powering off the domain %(domain)s. '
|
||||||
'Error: %(error)s', {'domain': self.domain_name,
|
'Error: %(error)s', {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
@ -207,7 +207,7 @@ class VirtualBMC(bmc.Bmc):
|
|||||||
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
domain = utils.get_libvirt_domain(conn, self.domain_name)
|
||||||
if domain.isActive():
|
if domain.isActive():
|
||||||
domain.reset()
|
domain.reset()
|
||||||
except libvirt.libvirtError as e:
|
except Exception as e:
|
||||||
LOG.error('Error reseting the domain %(domain)s. '
|
LOG.error('Error reseting the domain %(domain)s. '
|
||||||
'Error: %(error)s', {'domain': self.domain_name,
|
'Error: %(error)s', {'domain': self.domain_name,
|
||||||
'error': e})
|
'error': e})
|
||||||
|
Loading…
Reference in New Issue
Block a user