Revision 9440aeab lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
163 | 163 |
return {}, [], [] |
164 | 164 |
|
165 | 165 |
|
166 |
def _AddHostToEtcHosts(hostname): |
|
167 |
"""Wrapper around utils.SetEtcHostsEntry. |
|
168 |
|
|
169 |
""" |
|
170 |
hi = utils.HostInfo(name=hostname) |
|
171 |
utils.SetEtcHostsEntry(constants.ETC_HOSTS, hi.ip, hi.name, [hi.ShortName()]) |
|
172 |
|
|
173 |
|
|
166 | 174 |
def _RemoveHostFromEtcHosts(hostname): |
167 |
"""Wrapper around utils.RemoteEtcHostsEntry.
|
|
175 |
"""Wrapper around utils.RemoveEtcHostsEntry.
|
|
168 | 176 |
|
169 | 177 |
""" |
170 | 178 |
hi = utils.HostInfo(name=hostname) |
... | ... | |
574 | 582 |
f.close() |
575 | 583 |
sshkey = sshline.split(" ")[1] |
576 | 584 |
|
577 |
hi = utils.HostInfo(name=hostname.name) |
|
578 |
utils.AddEtcHostsEntry(constants.ETC_HOSTS, hostname.name, hi.ip) |
|
579 |
utils.AddEtcHostsEntry(constants.ETC_HOSTS, hi.ShortName(), hi.ip) |
|
580 |
del hi |
|
585 |
_AddHostToEtcHosts(hostname.name) |
|
581 | 586 |
|
582 | 587 |
_UpdateKnownHosts(hostname.name, hostname.ip, sshkey) |
583 | 588 |
|
... | ... | |
1484 | 1489 |
raise errors.OpExecError("Cannot transfer ssh keys to the new node") |
1485 | 1490 |
|
1486 | 1491 |
# Add node to our /etc/hosts, and add key to known_hosts |
1487 |
hi = utils.HostInfo(name=new_node.name) |
|
1488 |
utils.AddEtcHostsEntry(constants.ETC_HOSTS, new_node.name, hi.ip) |
|
1489 |
utils.AddEtcHostsEntry(constants.ETC_HOSTS, hi.ShortName(), hi.ip) |
|
1490 |
del hi |
|
1492 |
_AddHostToEtcHosts(new_node.name) |
|
1491 | 1493 |
|
1492 | 1494 |
_UpdateKnownHosts(new_node.name, new_node.primary_ip, |
1493 | 1495 |
self.cfg.GetHostKey()) |
Also available in: Unified diff