Previously '_create_instance' would initialize the config object every
time it would be called. This causes '_WriteConfig' to fail with
ConfigurationError: The configuration file has been modified since the
last write. Fix this by passing the config object to '_create_instance'
method.

Signed-off-by: Ilias Tsitsimpis <[email protected]>
---
 test/py/ganeti.config_unittest.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/py/ganeti.config_unittest.py 
b/test/py/ganeti.config_unittest.py
index 5eecf4c..f70bc31 100755
--- a/test/py/ganeti.config_unittest.py
+++ b/test/py/ganeti.config_unittest.py
@@ -104,13 +104,13 @@ class TestConfigRunner(unittest.TestCase):
     bootstrap.InitConfig(constants.CONFIG_VERSION,
                          cluster_config, master_node_config, self.cfg_file)
 
-  def _create_instance(self):
+  def _create_instance(self, cfg):
     """Create and return an instance object"""
     inst = objects.Instance(name="test.example.com",
                             uuid="test-uuid",
                             disks=[], nics=[],
                             disk_template=constants.DT_DISKLESS,
-                            primary_node=self._get_object().GetMasterNode(),
+                            primary_node=cfg.GetMasterNode(),
                             osparams_private=serializer.PrivateDict(),
                             beparams={})
     return inst
@@ -163,7 +163,7 @@ class TestConfigRunner(unittest.TestCase):
     """Test updates on one instance object"""
     cfg = self._get_object()
     # construct a fake instance
-    inst = self._create_instance()
+    inst = self._create_instance(cfg)
     fake_instance = objects.Instance()
     # fail if we didn't read the config
     self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_instance,
-- 
1.9.1

Reply via email to