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: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
(cherry picked from commit
b86a6bcd476e420269a24a9b3d6289bebba69442)
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
f.close()
sshkey = sshline.split(" ")[1]
- utils.AddHostToEtcHosts(hostname.name)
+ if modify_etc_hosts:
+ utils.AddHostToEtcHosts(hostname.name)
+
_InitSSHSetup()
# init of cluster config file
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,
" 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,
"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.
hvparams=hvparams,
beparams=beparams,
candidate_pool_size=opts.candidate_pool_size,
+ modify_etc_hosts=opts.modify_etc_hosts,
)
return 0
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),