Revision 0c223ea9

b/lib/constants.py
88 88
# daemon is started (this takes care of RUN_DIR being tmpfs)
89 89
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
90 90
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
91
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
91 92
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
92 93
SSL_CERT_FILE = DATA_DIR + "/server.pem"
93 94
WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
b/lib/ssconf.py
26 26

  
27 27
"""
28 28

  
29
import socket
30 29
import sys
31 30

  
32 31
from ganeti import errors
......
35 34
from ganeti import serializer
36 35

  
37 36

  
37
SSCONF_LOCK_TIMEOUT = 10
38

  
39

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

  
......
107 109
                    mode=0600)
108 110

  
109 111

  
112
def _SsconfPath(name):
113
  return "%s/ssconf_%s" % (constants.DATA_DIR, name)
114

  
115

  
116
def WriteSsconfFiles(file_name):
117
  """Writes legacy ssconf files to be used by external scripts.
118

  
119
  @type file_name: string
120
  @param file_name: Path to configuration file
121

  
122
  """
123
  ssconf_lock = utils.FileLock(constants.SSCONF_LOCK_FILE)
124

  
125
  # Read config
126
  cfg = SimpleConfigReader(file_name=file_name)
127

  
128
  # Get lock while writing files
129
  ssconf_lock.Exclusive(blocking=True, timeout=SSCONF_LOCK_TIMEOUT)
130
  try:
131
    utils.WriteFile(_SsconfPath("cluster_name"),
132
                    data="%s\n" % cfg.GetClusterName())
133

  
134
    utils.WriteFile(_SsconfPath("master_ip"),
135
                    data="%s\n" % cfg.GetMasterIP())
136

  
137
    utils.WriteFile(_SsconfPath("master_netdev"),
138
                    data="%s\n" % cfg.GetMasterNetdev())
139

  
140
    utils.WriteFile(_SsconfPath("master_node"),
141
                    data="%s\n" % cfg.GetMasterNode())
142
  finally:
143
    ssconf_lock.Unlock()
144

  
145

  
110 146
def GetMasterAndMyself(ss=None):
111 147
  """Get the master node and my own hostname.
112 148

  

Also available in: Unified diff