Fix a couple of epydoc warnings
[ganeti-local] / test / ganeti.config_unittest.py
index 36188fa..37bcb20 100755 (executable)
@@ -29,9 +29,10 @@ import tempfile
 import os.path
 import socket
 
-from ganeti import errors
-from ganeti import constants
+from ganeti import bootstrap
 from ganeti import config
+from ganeti import constants
+from ganeti import errors
 from ganeti import objects
 from ganeti import utils
 
@@ -41,6 +42,7 @@ class TestConfigRunner(unittest.TestCase):
   def setUp(self):
     fd, self.cfg_file = tempfile.mkstemp()
     os.close(fd)
+    self._init_cluster(self.cfg_file)
 
   def tearDown(self):
     try:
@@ -66,7 +68,8 @@ class TestConfigRunner(unittest.TestCase):
       volume_group_name="xenvg",
       default_bridge=constants.DEFAULT_BRIDGE,
       tcpudp_port_pool=set(),
-      hypervisor=constants.HT_FAKE,
+      default_hypervisor=constants.HT_FAKE,
+      enabled_hypervisors=[constants.HT_FAKE],
       master_node=me.name,
       master_ip="127.0.0.1",
       master_netdev=constants.DEFAULT_BRIDGE,
@@ -76,15 +79,18 @@ class TestConfigRunner(unittest.TestCase):
 
     master_node_config = objects.Node(name=me.name,
                                       primary_ip=me.ip,
-                                      secondary_ip=ip)
+                                      secondary_ip=ip,
+                                      serial_no=1,
+                                      master_candidate=True)
 
-    cfg.InitConfig(constants.CONFIG_VERSION,
-                   cluster_config, master_node_config)
+    bootstrap.InitConfig(constants.CONFIG_VERSION,
+                         cluster_config, master_node_config, self.cfg_file)
 
   def _create_instance(self):
     """Create and return an instance object"""
-    inst = objects.Instance(name="test.example.com", disks=[],
-                            disk_template=constants.DT_DISKLESS)
+    inst = objects.Instance(name="test.example.com", disks=[], nics=[],
+                            disk_template=constants.DT_DISKLESS,
+                            primary_node=self._get_object().GetMasterNode())
     return inst
 
   def testEmpty(self):
@@ -94,7 +100,6 @@ class TestConfigRunner(unittest.TestCase):
   def testInit(self):
     """Test initialize the config file"""
     cfg = self._get_object()
-    self._init_cluster(cfg)
     self.failUnlessEqual(1, len(cfg.GetNodeList()))
     self.failUnlessEqual(0, len(cfg.GetInstanceList()))
 
@@ -104,9 +109,8 @@ class TestConfigRunner(unittest.TestCase):
     # construct a fake cluster object
     fake_cl = objects.Cluster()
     # fail if we didn't read the config
-    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_cl)
+    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_cl)
 
-    self._init_cluster(cfg)
     cl = cfg.GetClusterInfo()
     # first pass, must not fail
     cfg.Update(cl)
@@ -121,9 +125,8 @@ class TestConfigRunner(unittest.TestCase):
     # construct a fake node
     fake_node = objects.Node()
     # fail if we didn't read the config
-    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_node)
+    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_node)
 
-    self._init_cluster(cfg)
     node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
     # first pass, must not fail
     cfg.Update(node)
@@ -139,9 +142,8 @@ class TestConfigRunner(unittest.TestCase):
     inst = self._create_instance()
     fake_instance = objects.Instance()
     # fail if we didn't read the config
-    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_instance)
+    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_instance)
 
-    self._init_cluster(cfg)
     cfg.AddInstance(inst)
     instance = cfg.GetInstanceInfo(cfg.GetInstanceList()[0])
     # first pass, must not fail