From: Michael Hanselmann Date: Thu, 24 Jan 2013 14:10:11 +0000 (+0100) Subject: hv_xen: Test removing config from "auto" directory X-Git-Tag: v2.8.0beta1~478 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/7610d88418b07919924def0e47fa0a5f32c3e39b hv_xen: Test removing config from "auto" directory Test whether any existing configuration file named after the instance is removed from Xen's “auto” directory. Signed-off-by: Michael Hanselmann Reviewed-by: Helga Velroyen --- diff --git a/test/py/ganeti.hypervisor.hv_xen_unittest.py b/test/py/ganeti.hypervisor.hv_xen_unittest.py index d226d10..61c7085 100755 --- a/test/py/ganeti.hypervisor.hv_xen_unittest.py +++ b/test/py/ganeti.hypervisor.hv_xen_unittest.py @@ -26,6 +26,7 @@ import unittest import tempfile import shutil import random +import os from ganeti import constants from ganeti import objects @@ -365,6 +366,23 @@ class _TestXenHypervisor(object): "", "This command failed", None, NotImplemented, NotImplemented) + def testRemovingAutoConfigFile(self): + name = "inst8206.example.com" + cfgfile = utils.PathJoin(self.tmpdir, name) + autodir = utils.PathJoin(self.tmpdir, "auto") + autocfgfile = utils.PathJoin(autodir, name) + + os.mkdir(autodir) + + utils.WriteFile(autocfgfile, data="") + + hv = self._GetHv() + + self.assertTrue(os.path.isfile(autocfgfile)) + hv._WriteConfigFile(name, "content") + self.assertFalse(os.path.exists(autocfgfile)) + self.assertEqual(utils.ReadFile(cfgfile), "content") + def _MakeTestClass(cls, cmd): """Makes a class for testing.