Revision 02f99608

b/lib/bootstrap.py
229 229
  master_node_config = objects.Node(name=hostname.name,
230 230
                                    primary_ip=hostname.ip,
231 231
                                    secondary_ip=secondary_ip)
232
  cfg = config.ConfigWriter()
233
  cfg.InitConfig(constants.CONFIG_VERSION, cluster_config, master_node_config)
234 232

  
233
  cfg = InitConfig(constants.CONFIG_VERSION,
234
                   cluster_config, master_node_config)
235 235
  ssh.WriteKnownHostsFile(cfg, constants.SSH_KNOWN_HOSTS_FILE)
236 236

  
237 237
  # start the master ip
......
239 239
  rpc.call_node_start_master(hostname.name, True)
240 240

  
241 241

  
242
def InitConfig(version, cluster_config, master_node_config,
243
               cfg_file=constants.CLUSTER_CONF_FILE):
244
    """Create the initial cluster configuration.
245

  
246
    It will contain the current node, which will also be the master
247
    node, and no instances.
248

  
249
    @type version: int
250
    @param version: Configuration version
251
    @type cluster_config: objects.Cluster
252
    @param cluster_config: Cluster configuration
253
    @type master_node_config: objects.Node
254
    @param master_node_config: Master node configuration
255
    @type file_name: string
256
    @param file_name: Configuration file path
257

  
258
    @rtype: ssconf.SimpleConfigWriter
259
    @returns: Initialized config instance
260

  
261
    """
262
    nodes = {
263
      master_node_config.name: master_node_config,
264
      }
265

  
266
    config_data = objects.ConfigData(version=version,
267
                                     cluster=cluster_config,
268
                                     nodes=nodes,
269
                                     instances={},
270
                                     serial_no=1)
271
    cfg = ssconf.SimpleConfigWriter.FromDict(config_data.ToDict(), cfg_file)
272
    cfg.Save()
273

  
274
    return cfg
275

  
276

  
242 277
def FinalizeClusterDestroy(master):
243 278
  """Execute the last steps of cluster destroy
244 279

  
b/lib/ssconf.py
35 35
from ganeti import serializer
36 36

  
37 37

  
38
class SimpleConfigReader:
38
class SimpleConfigReader(object):
39 39
  """Simple class to read configuration file.
40 40

  
41 41
  """
......
74 74
  def GetNodeList(self):
75 75
    return self._config_data["nodes"].keys()
76 76

  
77
  @classmethod
78
  def FromDict(cls, val, cfg_file=constants.CLUSTER_CONF_FILE):
79
    """Alternative construction from a dictionary.
80

  
81
    """
82
    obj = SimpleConfigReader.__new__(cls)
83
    obj._config_data = val
84
    obj._file_name = cfg_file
85
    return obj
86

  
77 87

  
78 88
class SimpleConfigWriter(SimpleConfigReader):
79 89
  """Simple class to write configuration file.

Also available in: Unified diff