This is a fix for a minor bug. Currently, a failed Xen VM start results in a stale config file left behinf on the filesystem. This change introduces a clean-up step.
Signed-off-by: Balazs Lecz <[email protected]> --- lib/hypervisor/hv_xen.py | 3 +++ test/py/ganeti.hypervisor.hv_xen_unittest.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 1d0b587..b3e8cc4 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -482,6 +482,9 @@ class XenHypervisor(hv_base.BaseHypervisor): result = self._RunXen(cmd) if result.failed: + # Remove configuration file to avoid littering the filesystem with stale + # config files + self._RemoveConfigFile(instance.name) raise errors.HypervisorError("Failed to start instance %s: %s (%s)" % (instance.name, result.fail_reason, result.output)) diff --git a/test/py/ganeti.hypervisor.hv_xen_unittest.py b/test/py/ganeti.hypervisor.hv_xen_unittest.py index 3679de4..a1063e5 100755 --- a/test/py/ganeti.hypervisor.hv_xen_unittest.py +++ b/test/py/ganeti.hypervisor.hv_xen_unittest.py @@ -491,7 +491,6 @@ class _TestXenHypervisor(object): self.fail("Unhandled command: %s" % (cmd, )) return self._SuccessCommand(output, cmd) - #return self._FailingCommand(cmd) def _MakeInstance(self): # Copy default parameters @@ -537,11 +536,12 @@ class _TestXenHypervisor(object): if failcreate: self.assertRaises(errors.HypervisorError, hv.StartInstance, inst, disks, paused) + # Check whether a stale config file is left behind + self.assertFalse(os.path.exists(cfgfile)) else: hv.StartInstance(inst, disks, paused) - - # Check if configuration was updated - lines = utils.ReadFile(cfgfile).splitlines() + # Check if configuration was updated + lines = utils.ReadFile(cfgfile).splitlines() if constants.HV_VNC_PASSWORD_FILE in inst.hvparams: self.assertTrue(("vncpasswd = '%s'" % self.vncpw) in lines) -- 1.8.2.1
