Revision 91492e57 lib/backend.py
b/lib/backend.py | ||
---|---|---|
242 | 242 |
def StartMaster(start_daemons, no_voting): |
243 | 243 |
"""Activate local node as master node. |
244 | 244 |
|
245 |
The function will always try activate the IP address of the master
|
|
246 |
(unless someone else has it). It will also start the master daemons,
|
|
247 |
based on the start_daemons parameter.
|
|
245 |
The function will either try activate the IP address of the master
|
|
246 |
(unless someone else has it) or also start the master daemons, based
|
|
247 |
on the start_daemons parameter. |
|
248 | 248 |
|
249 | 249 |
@type start_daemons: boolean |
250 |
@param start_daemons: whether to also start the master |
|
251 |
daemons (ganeti-masterd and ganeti-rapi) |
|
250 |
@param start_daemons: whether to start the master daemons |
|
251 |
(ganeti-masterd and ganeti-rapi), or (if false) activate the |
|
252 |
master ip |
|
252 | 253 |
@type no_voting: boolean |
253 | 254 |
@param no_voting: whether to start ganeti-masterd without a node vote |
254 | 255 |
(if start_daemons is True), but still non-interactively |
... | ... | |
259 | 260 |
master_netdev, master_ip, _ = GetMasterInfo() |
260 | 261 |
|
261 | 262 |
err_msgs = [] |
262 |
if netutils.TcpPing(master_ip, constants.DEFAULT_NODED_PORT): |
|
263 |
if netutils.OwnIpAddress(master_ip): |
|
264 |
# we already have the ip: |
|
265 |
logging.debug("Master IP already configured, doing nothing") |
|
266 |
else: |
|
267 |
msg = "Someone else has the master ip, not activating" |
|
268 |
logging.error(msg) |
|
269 |
err_msgs.append(msg) |
|
270 |
else: |
|
271 |
result = utils.RunCmd(["ip", "address", "add", "%s/32" % master_ip, |
|
272 |
"dev", master_netdev, "label", |
|
273 |
"%s:0" % master_netdev]) |
|
274 |
if result.failed: |
|
275 |
msg = "Can't activate master IP: %s" % result.output |
|
276 |
logging.error(msg) |
|
277 |
err_msgs.append(msg) |
|
278 |
|
|
279 |
result = utils.RunCmd(["arping", "-q", "-U", "-c 3", "-I", master_netdev, |
|
280 |
"-s", master_ip, master_ip]) |
|
281 |
# we'll ignore the exit code of arping |
|
282 |
|
|
283 |
# and now start the master and rapi daemons |
|
263 |
# either start the master and rapi daemons |
|
284 | 264 |
if start_daemons: |
285 | 265 |
if no_voting: |
286 | 266 |
masterd_args = "--no-voting --yes-do-it" |
... | ... | |
296 | 276 |
msg = "Can't start Ganeti master: %s" % result.output |
297 | 277 |
logging.error(msg) |
298 | 278 |
err_msgs.append(msg) |
279 |
# or activate the IP |
|
280 |
else: |
|
281 |
if netutils.TcpPing(master_ip, constants.DEFAULT_NODED_PORT): |
|
282 |
if netutils.OwnIpAddress(master_ip): |
|
283 |
# we already have the ip: |
|
284 |
logging.debug("Master IP already configured, doing nothing") |
|
285 |
else: |
|
286 |
msg = "Someone else has the master ip, not activating" |
|
287 |
logging.error(msg) |
|
288 |
err_msgs.append(msg) |
|
289 |
else: |
|
290 |
result = utils.RunCmd(["ip", "address", "add", "%s/32" % master_ip, |
|
291 |
"dev", master_netdev, "label", |
|
292 |
"%s:0" % master_netdev]) |
|
293 |
if result.failed: |
|
294 |
msg = "Can't activate master IP: %s" % result.output |
|
295 |
logging.error(msg) |
|
296 |
err_msgs.append(msg) |
|
297 |
|
|
298 |
result = utils.RunCmd(["arping", "-q", "-U", "-c 3", "-I", master_netdev, |
|
299 |
"-s", master_ip, master_ip]) |
|
300 |
# we'll ignore the exit code of arping |
|
299 | 301 |
|
300 | 302 |
if err_msgs: |
301 | 303 |
_Fail("; ".join(err_msgs)) |
Also available in: Unified diff