Revision 5675cd1f
b/daemons/ganeti-masterd | ||
---|---|---|
265 | 265 |
object.__setattr__(self, name, value) |
266 | 266 |
|
267 | 267 |
|
268 |
def CheckMaster(debug): |
|
269 |
"""Checks the node setup. |
|
270 |
|
|
271 |
If this is the master, the function will return. Otherwise it will |
|
272 |
exit with an exit code based on the node status. |
|
273 |
|
|
274 |
""" |
|
275 |
try: |
|
276 |
ss = ssconf.SimpleStore() |
|
277 |
master_name = ss.GetMasterNode() |
|
278 |
except errors.ConfigurationError, err: |
|
279 |
print "Cluster configuration incomplete: '%s'" % str(err) |
|
280 |
sys.exit(EXIT_NODESETUP_ERROR) |
|
281 |
|
|
282 |
try: |
|
283 |
myself = utils.HostInfo() |
|
284 |
except errors.ResolverError, err: |
|
285 |
sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0]) |
|
286 |
sys.exit(EXIT_NODESETUP_ERROR) |
|
287 |
|
|
288 |
if myself.name != master_name: |
|
289 |
if debug: |
|
290 |
sys.stderr.write("Not master, exiting.\n") |
|
291 |
sys.exit(EXIT_NOTMASTER) |
|
292 |
|
|
293 |
|
|
294 | 268 |
def ParseOptions(): |
295 | 269 |
"""Parse the command line options. |
296 | 270 |
|
... | ... | |
320 | 294 |
utils.debug = options.debug |
321 | 295 |
utils.no_fork = True |
322 | 296 |
|
323 |
CheckMaster(options.debug) |
|
297 |
ssconf.CheckMaster(options.debug)
|
|
324 | 298 |
|
325 | 299 |
master = IOServer(constants.MASTER_SOCKET, ClientRqHandler, GanetiContext()) |
326 | 300 |
|
b/daemons/ganeti-rapi | ||
---|---|---|
31 | 31 |
from ganeti import errors |
32 | 32 |
from ganeti import http |
33 | 33 |
from ganeti import rpc |
34 |
from ganeti import ssconf |
|
34 | 35 |
from ganeti import utils |
35 | 36 |
from ganeti.rapi import connector |
36 | 37 |
|
... | ... | |
129 | 130 |
""" |
130 | 131 |
options, args = ParseOptions() |
131 | 132 |
|
133 |
ssconf.CheckMaster(options.debug) |
|
134 |
|
|
132 | 135 |
if options.fork: |
133 | 136 |
utils.Daemonize(logfile=constants.LOG_RAPISERVER) |
134 | 137 |
|
b/lib/ssconf.py | ||
---|---|---|
27 | 27 |
""" |
28 | 28 |
|
29 | 29 |
import socket |
30 |
import sys |
|
30 | 31 |
|
31 | 32 |
from ganeti import errors |
32 | 33 |
from ganeti import constants |
... | ... | |
199 | 200 |
utils.WriteFile(file_name, data="%s\n" % str(value), |
200 | 201 |
uid=0, gid=0, mode=0400) |
201 | 202 |
|
203 |
|
|
204 |
def CheckMaster(debug): |
|
205 |
"""Checks the node setup. |
|
206 |
|
|
207 |
If this is the master, the function will return. Otherwise it will |
|
208 |
exit with an exit code based on the node status. |
|
209 |
|
|
210 |
""" |
|
211 |
try: |
|
212 |
ss = SimpleStore() |
|
213 |
master_name = ss.GetMasterNode() |
|
214 |
except errors.ConfigurationError, err: |
|
215 |
print "Cluster configuration incomplete: '%s'" % str(err) |
|
216 |
sys.exit(constants.EXIT_NODESETUP_ERROR) |
|
217 |
|
|
218 |
try: |
|
219 |
myself = utils.HostInfo() |
|
220 |
except errors.ResolverError, err: |
|
221 |
sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0]) |
|
222 |
sys.exit(constants.EXIT_NODESETUP_ERROR) |
|
223 |
|
|
224 |
if myself.name != master_name: |
|
225 |
if debug: |
|
226 |
sys.stderr.write("Not master, exiting.\n") |
|
227 |
sys.exit(constants.EXIT_NOTMASTER) |
Also available in: Unified diff