Revision ea8ac9c9
b/lib/bootstrap.py | ||
---|---|---|
348 | 348 |
sshkey = sshline.split(" ")[1] |
349 | 349 |
|
350 | 350 |
if modify_etc_hosts: |
351 |
utils.AddHostToEtcHosts(hostname) |
|
351 |
utils.AddHostToEtcHosts(hostname.name, hostname.ip)
|
|
352 | 352 |
|
353 | 353 |
if modify_ssh_setup: |
354 | 354 |
_InitSSHSetup() |
b/lib/cmdlib.py | ||
---|---|---|
3272 | 3272 |
|
3273 | 3273 |
# Remove node from our /etc/hosts |
3274 | 3274 |
if self.cfg.GetClusterInfo().modify_etc_hosts: |
3275 |
# FIXME: this should be done via an rpc call to node daemon |
|
3276 |
utils.RemoveHostFromEtcHosts(node.name) |
|
3275 |
master_node = self.cfg.GetMasterNode() |
|
3276 |
result = self.rpc.call_etc_hosts_modify(master_node, |
|
3277 |
constants.ETC_HOSTS_REMOVE, |
|
3278 |
node.name, None) |
|
3279 |
result.Raise("Can't update hosts file with new host data") |
|
3277 | 3280 |
_RedistributeAncillaryFiles(self) |
3278 | 3281 |
|
3279 | 3282 |
|
... | ... | |
3829 | 3832 |
|
3830 | 3833 |
# Add node to our /etc/hosts, and add key to known_hosts |
3831 | 3834 |
if self.cfg.GetClusterInfo().modify_etc_hosts: |
3832 |
# FIXME: this should be done via an rpc call to node daemon |
|
3833 |
utils.AddHostToEtcHosts(self.hostname) |
|
3835 |
master_node = self.cfg.GetMasterNode() |
|
3836 |
result = self.rpc.call_etc_hosts_modify(master_node, |
|
3837 |
constants.ETC_HOSTS_ADD, |
|
3838 |
self.hostname.name, |
|
3839 |
self.hostname.ip) |
|
3840 |
result.Raise("Can't update hosts file with new host data") |
|
3834 | 3841 |
|
3835 | 3842 |
if new_node.secondary_ip != new_node.primary_ip: |
3836 | 3843 |
result = self.rpc.call_node_has_ip_address(new_node.name, |
b/lib/utils.py | ||
---|---|---|
1462 | 1462 |
WriteFile(file_name, fn=_WriteEtcHosts, mode=0644) |
1463 | 1463 |
|
1464 | 1464 |
|
1465 |
def AddHostToEtcHosts(hostname): |
|
1465 |
def AddHostToEtcHosts(hostname, ip):
|
|
1466 | 1466 |
"""Wrapper around SetEtcHostsEntry. |
1467 | 1467 |
|
1468 | 1468 |
@type hostname: str |
1469 | 1469 |
@param hostname: a hostname that will be resolved and added to |
1470 | 1470 |
L{constants.ETC_HOSTS} |
1471 |
@type ip: str |
|
1472 |
@param ip: The ip address of the host |
|
1471 | 1473 |
|
1472 | 1474 |
""" |
1473 |
SetEtcHostsEntry(constants.ETC_HOSTS, hostname.ip, hostname.name, |
|
1474 |
[hostname.name.split(".")[0]]) |
|
1475 |
SetEtcHostsEntry(constants.ETC_HOSTS, ip, hostname, [hostname.split(".")[0]]) |
|
1475 | 1476 |
|
1476 | 1477 |
|
1477 | 1478 |
def RemoveEtcHostsEntry(file_name, hostname): |
Also available in: Unified diff