Revision c666722f

b/test/ganeti.config_unittest.py
29 29
import os.path
30 30
import socket
31 31

  
32
from ganeti import errors
33
from ganeti import constants
32
from ganeti import bootstrap
34 33
from ganeti import config
34
from ganeti import constants
35
from ganeti import errors
35 36
from ganeti import objects
36 37
from ganeti import utils
37 38

  
......
41 42
  def setUp(self):
42 43
    fd, self.cfg_file = tempfile.mkstemp()
43 44
    os.close(fd)
45
    self._init_cluster(self.cfg_file)
44 46

  
45 47
  def tearDown(self):
46 48
    try:
......
79 81
                                      secondary_ip=ip,
80 82
                                      serial_no=1)
81 83

  
82
    cfg.InitConfig(constants.CONFIG_VERSION,
83
                   cluster_config, master_node_config)
84
    bootstrap.InitConfig(constants.CONFIG_VERSION,
85
                         cluster_config, master_node_config, self.cfg_file)
84 86

  
85 87
  def _create_instance(self):
86 88
    """Create and return an instance object"""
......
95 97
  def testInit(self):
96 98
    """Test initialize the config file"""
97 99
    cfg = self._get_object()
98
    self._init_cluster(cfg)
99 100
    self.failUnlessEqual(1, len(cfg.GetNodeList()))
100 101
    self.failUnlessEqual(0, len(cfg.GetInstanceList()))
101 102

  
......
105 106
    # construct a fake cluster object
106 107
    fake_cl = objects.Cluster()
107 108
    # fail if we didn't read the config
108
    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_cl)
109
    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_cl)
109 110

  
110
    self._init_cluster(cfg)
111 111
    cl = cfg.GetClusterInfo()
112 112
    # first pass, must not fail
113 113
    cfg.Update(cl)
......
122 122
    # construct a fake node
123 123
    fake_node = objects.Node()
124 124
    # fail if we didn't read the config
125
    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_node)
125
    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_node)
126 126

  
127
    self._init_cluster(cfg)
128 127
    node = cfg.GetNodeInfo(cfg.GetNodeList()[0])
129 128
    # first pass, must not fail
130 129
    cfg.Update(node)
......
140 139
    inst = self._create_instance()
141 140
    fake_instance = objects.Instance()
142 141
    # fail if we didn't read the config
143
    self.failUnlessRaises(errors.ProgrammerError, cfg.Update, fake_instance)
142
    self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_instance)
144 143

  
145
    self._init_cluster(cfg)
146 144
    cfg.AddInstance(inst)
147 145
    instance = cfg.GetInstanceInfo(cfg.GetInstanceList()[0])
148 146
    # first pass, must not fail

Also available in: Unified diff