Commit aafb303d authored by Guido Trotter's avatar Guido Trotter Committed by Iustin Pop
Browse files

Add cluster-init --no-etc-hosts parameter



If --no-etc-hosts is passed in at cluster init time we set a new
parameter in the cluster's object to false, and avoid adding nodes to
the hosts file. The UpgradeConfig function is used to set the value to
True, when upgrading from an old configuration version.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
(cherry picked from commit b86a6bcd)
parent d2d7d5c3
......@@ -126,7 +126,8 @@ def _InitGanetiServerSetup():
def InitCluster(cluster_name, mac_prefix, def_bridge,
master_netdev, file_storage_dir, candidate_pool_size,
secondary_ip=None, vg_name=None, beparams=None, hvparams=None,
enabled_hypervisors=None, default_hypervisor=None):
enabled_hypervisors=None, default_hypervisor=None,
modify_etc_hosts=True):
"""Initialise the cluster.
@type candidate_pool_size: int
......@@ -236,7 +237,9 @@ def InitCluster(cluster_name, mac_prefix, def_bridge,
f.close()
sshkey = sshline.split(" ")[1]
utils.AddHostToEtcHosts(hostname.name)
if modify_etc_hosts:
utils.AddHostToEtcHosts(hostname.name)
_InitSSHSetup()
# init of cluster config file
......@@ -258,6 +261,7 @@ def InitCluster(cluster_name, mac_prefix, def_bridge,
beparams={constants.BEGR_DEFAULT: beparams},
hvparams=hvparams,
candidate_pool_size=candidate_pool_size,
modify_etc_hosts=opts.modify_etc_hosts,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
......
......@@ -2378,7 +2378,8 @@ class LUAddNode(LogicalUnit):
" new node: %s" % msg)
# Add node to our /etc/hosts, and add key to known_hosts
utils.AddHostToEtcHosts(new_node.name)
if self.cfg.GetClusterInfo().modify_etc_hosts:
utils.AddHostToEtcHosts(new_node.name)
if new_node.secondary_ip != new_node.primary_ip:
result = self.rpc.call_node_has_ip_address(new_node.name,
......
......@@ -752,8 +752,16 @@ class Cluster(TaggableObject):
"hvparams",
"beparams",
"candidate_pool_size",
"modify_etc_hosts",
]
def UpgradeConfig(self):
"""Fill defaults for missing configuration values.
"""
if self.modify_etc_hosts is None:
self.modify_etc_hosts = True
def ToDict(self):
"""Custom function for cluster.
......
......@@ -105,6 +105,7 @@ def InitCluster(opts, args):
hvparams=hvparams,
beparams=beparams,
candidate_pool_size=opts.candidate_pool_size,
modify_etc_hosts=opts.modify_etc_hosts,
)
return 0
......@@ -582,6 +583,10 @@ commands = {
help="No support for lvm based instances"
" (cluster-wide)",
action="store_false", default=True,),
make_option("--no-etc-hosts", dest="modify_etc_hosts",
help="Don't modify /etc/hosts"
" (cluster-wide)",
action="store_false", default=True,),
make_option("--enabled-hypervisors", dest="enabled_hypervisors",
help="Comma-separated list of hypervisors",
type="string", default=None),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment