mirror of
https://github.com/clearlinux/clearstack.git
synced 2026-06-15 18:46:35 +00:00
Correctly find the current node ip based on the ips from answer file
Templates that need the nodes ips where using util.get_ip() which returns the IP assosiated with the default gateway but might not be the desired IP in nodes with multiple nics. This change introduces util.find_my_ip_from_config() which a template that is expected to run on a compute node can use to identify which of the nodes ip does match with one from CONFIG_COMPUTE_HOSTS
This commit is contained in:
@@ -190,6 +190,11 @@ def get_ip():
|
||||
return netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
|
||||
|
||||
|
||||
def find_my_ip_from_config(config_ips):
|
||||
ip = set(get_ips()) & set(config_ips)
|
||||
return ip.pop()
|
||||
|
||||
|
||||
def is_localhost(host):
|
||||
return (host == "localhost" or host == socket.gethostname()
|
||||
or host in get_ips())
|
||||
|
||||
@@ -83,13 +83,13 @@ class Neutron(OpenStackService):
|
||||
util.link_file('/etc/neutron/plugins/ml2/ml2_conf.ini',
|
||||
'/etc/neutron/plugin.ini')
|
||||
|
||||
def config_linux_bridge_agent(self):
|
||||
def config_linux_bridge_agent(self, local_ip):
|
||||
config = \
|
||||
"[linux_bridge]\n" + \
|
||||
"physical_interface_mappings = %s\n" % bridge_mappings + \
|
||||
"[vxlan]\n" + \
|
||||
"enable_vxlan = True\n" + \
|
||||
"local_ip = %s\n" % util.get_ip() + \
|
||||
"local_ip = %s\n" % local_ip + \
|
||||
"l2_population = True\n" + \
|
||||
"[agent]\n" + \
|
||||
"prevent_arp_spoofing = True\n" + \
|
||||
|
||||
@@ -23,6 +23,8 @@ from common import util
|
||||
|
||||
neutron = Neutron.get()
|
||||
config_file = "/etc/neutron/neutron.conf"
|
||||
ip_list = CONF['CONFIG_CONTROLLER_HOST'].split(',')
|
||||
local_ip = util.find_my_ip_from_config(ip_list)
|
||||
|
||||
# Install neutron controller
|
||||
neutron.install()
|
||||
@@ -38,7 +40,7 @@ neutron.config_auth(config_file)
|
||||
|
||||
neutron.config_nova(config_file)
|
||||
neutron.config_ml2_plugin()
|
||||
neutron.config_linux_bridge_agent()
|
||||
neutron.config_linux_bridge_agent(local_ip)
|
||||
neutron.config_l3_agent("/etc/neutron/l3_agent.ini")
|
||||
neutron.config_dhcp_agent("/etc/neutron/dhcp_agent.ini")
|
||||
neutron.config_metadata_agent("/etc/neutron/metadata_agent.ini")
|
||||
|
||||
@@ -24,12 +24,14 @@ from common import util
|
||||
neutron = Neutron.get()
|
||||
config_file = "/etc/neutron/neutron.conf"
|
||||
services = ['nova-compute', 'neutron-linuxbridge-agent']
|
||||
ip_list = CONF['CONFIG_COMPUTE_HOSTS'].split(',')
|
||||
local_ip = util.find_my_ip_from_config(ip_list)
|
||||
|
||||
neutron.install()
|
||||
neutron.config_debug(config_file)
|
||||
neutron.config_rabbitmq(config_file)
|
||||
neutron.config_auth(config_file)
|
||||
neutron.config_linux_bridge_agent()
|
||||
neutron.config_linux_bridge_agent(local_ip)
|
||||
neutron.config_neutron_on_nova('/etc/nova/nova.conf')
|
||||
|
||||
if util.str2bool(CONF['CONFIG_CEILOMETER_INSTALL']):
|
||||
|
||||
@@ -23,7 +23,8 @@ from common import util
|
||||
|
||||
nova = Nova.get()
|
||||
config_file = "/etc/nova/nova.conf"
|
||||
my_ip = util.get_ip()
|
||||
ip_list = CONF['CONFIG_CONTROLLER_HOST'].split(',')
|
||||
my_ip = util.find_my_ip_from_config(ip_list)
|
||||
|
||||
# Install nova controller
|
||||
nova.install()
|
||||
|
||||
@@ -28,7 +28,8 @@ from common import util
|
||||
nova = Nova.get()
|
||||
config_file = "/etc/nova/nova.conf"
|
||||
services = ['libvirtd.socket', 'nova-compute']
|
||||
my_ip = util.get_ip()
|
||||
ip_list = CONF['CONFIG_COMPUTE_HOSTS'].split(',')
|
||||
my_ip = util.find_my_ip_from_config(ip_list)
|
||||
|
||||
if CONF['CONFIG_HTTP_SERVICE'] == 'nginx':
|
||||
services.extend(['nginx', 'uwsgi@nova-metadata.socket'])
|
||||
|
||||
@@ -61,6 +61,7 @@ def run_recipe(recipe_file, recipe_src, hosts):
|
||||
_run_recipe_in_hosts(recipe_file, recipes_dir, hosts)
|
||||
return True
|
||||
|
||||
|
||||
def _run_recipe_local(recipe_file):
|
||||
if recipe_file.endswith('.py'):
|
||||
util.run_command("python3 {0}".format(recipe_file))
|
||||
|
||||
Reference in New Issue
Block a user