Revision 19ddc57a lib/backend.py
b/lib/backend.py | ||
---|---|---|
350 | 350 |
result.cmd, result.exit_code, result.output) |
351 | 351 |
|
352 | 352 |
|
353 |
def EtcHostsModify(mode, host, ip): |
|
354 |
"""Modify a host entry in /etc/hosts. |
|
355 |
|
|
356 |
@param mode: The mode to operate. Either add or remove entry |
|
357 |
@param host: The host to operate on |
|
358 |
@param ip: The ip associated with the entry |
|
359 |
|
|
360 |
""" |
|
361 |
if mode == constants.ETC_HOSTS_ADD: |
|
362 |
if not ip: |
|
363 |
RPCFail("Mode 'add' needs 'ip' parameter, but parameter not" |
|
364 |
" present") |
|
365 |
utils.AddHostToEtcHosts(host, ip) |
|
366 |
elif mode == constants.ETC_HOSTS_REMOVE: |
|
367 |
if ip: |
|
368 |
RPCFail("Mode 'remove' does not allow 'ip' parameter, but" |
|
369 |
" parameter is present") |
|
370 |
utils.RemoveHostFromEtcHosts(host) |
|
371 |
else: |
|
372 |
RPCFail("Mode not supported") |
|
373 |
|
|
374 |
|
|
353 | 375 |
def LeaveCluster(modify_ssh_setup): |
354 | 376 |
"""Cleans up and remove the current node. |
355 | 377 |
|
Also available in: Unified diff