Revision b33e986b lib/ssconf.py
b/lib/ssconf.py | ||
---|---|---|
201 | 201 |
uid=0, gid=0, mode=0400) |
202 | 202 |
|
203 | 203 |
|
204 |
def CheckMaster(debug): |
|
204 |
def GetMasterAndMyself(ss=None): |
|
205 |
"""Get the master node and my own hostname. |
|
206 |
|
|
207 |
This can be either used for a 'soft' check (compared to CheckMaster, |
|
208 |
which exits) or just for computing both at the same time. |
|
209 |
|
|
210 |
The function does not handle any errors, these should be handled in |
|
211 |
the caller (errors.ConfigurationError, errors.ResolverError). |
|
212 |
|
|
213 |
""" |
|
214 |
if ss is None: |
|
215 |
ss = SimpleStore() |
|
216 |
return ss.GetMasterNode(), utils.HostInfo().name |
|
217 |
|
|
218 |
def CheckMaster(debug, ss=None): |
|
205 | 219 |
"""Checks the node setup. |
206 | 220 |
|
207 | 221 |
If this is the master, the function will return. Otherwise it will |
... | ... | |
209 | 223 |
|
210 | 224 |
""" |
211 | 225 |
try: |
212 |
ss = SimpleStore() |
|
213 |
master_name = ss.GetMasterNode() |
|
226 |
master_name, myself = GetMasterAndMyself(ss) |
|
214 | 227 |
except errors.ConfigurationError, err: |
215 | 228 |
print "Cluster configuration incomplete: '%s'" % str(err) |
216 | 229 |
sys.exit(constants.EXIT_NODESETUP_ERROR) |
217 |
|
|
218 |
try: |
|
219 |
myself = utils.HostInfo() |
|
220 | 230 |
except errors.ResolverError, err: |
221 | 231 |
sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0]) |
222 | 232 |
sys.exit(constants.EXIT_NODESETUP_ERROR) |
223 | 233 |
|
224 |
if myself.name != master_name:
|
|
234 |
if myself != master_name: |
|
225 | 235 |
if debug: |
226 | 236 |
sys.stderr.write("Not master, exiting.\n") |
227 | 237 |
sys.exit(constants.EXIT_NOTMASTER) |
Also available in: Unified diff