Configure the route reflector to peer with compute nodes only, not all nodes
Change-Id: I24a81e0f3e000bce9209d4acba74a53375308628
This commit is contained in:
parent
fb7b7a9f10
commit
85ddb63714
|
@ -7,9 +7,9 @@ set -x
|
|||
|
||||
echo "Hi, I'm a route_reflector node!"
|
||||
|
||||
this_node_address=$(grep `hostname` /etc/hosts | awk '{print $1;}')
|
||||
this_node_address=$(python get_node_ip.py `hostname`)
|
||||
|
||||
all_nodes=$(grep node- /etc/hosts | awk '{print $1;}')
|
||||
bgp_peers=$(python get_rr_peers.py)
|
||||
|
||||
# Generate basic config for a BIRD BGP route reflector.
|
||||
cat > /etc/bird/bird.conf <<EOF
|
||||
|
@ -39,7 +39,7 @@ protocol device {
|
|||
EOF
|
||||
|
||||
# Add a BGP protocol stanza for each compute node.
|
||||
for node in $all_nodes; do
|
||||
for node in $bgp_peers; do
|
||||
if [ $node != $this_node_address ]; then
|
||||
cat >> /etc/bird/bird.conf <<EOF
|
||||
|
||||
|
|
|
@ -1,31 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2015 Metaswitch Networks
|
||||
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
from pluginutils import get_config_file_for_node_type
|
||||
|
||||
usage = "./get_node_ip.py <hostname>"
|
||||
|
||||
PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
|
||||
CONTROLLER_CFG = "/etc/controller.yaml"
|
||||
COMPUTE_CFG = "/etc/compute.yaml"
|
||||
|
||||
def get_config_file_for_node_type():
|
||||
if os.path.isfile(PRIMARY_CONTROLLER_CFG):
|
||||
config_file = PRIMARY_CONTROLLER_CFG
|
||||
|
||||
elif os.path.isfile(CONTROLLER_CFG):
|
||||
config_file = CONTROLLER_CFG
|
||||
|
||||
elif os.path.isfile(COMPUTE_CFG):
|
||||
config_file = COMPUTE_CFG
|
||||
|
||||
else:
|
||||
raise Exception("Unrecognised node type - can't obtain config")
|
||||
|
||||
return config_file
|
||||
|
||||
def main(hostname):
|
||||
config_file = get_config_file_for_node_type()
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2015 Metaswitch Networks
|
||||
|
||||
import yaml
|
||||
from pluginutils import get_config_file_for_node_type
|
||||
|
||||
def main():
|
||||
config_file = get_config_file_for_node_type()
|
||||
|
||||
with open(config_file, "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
# The route reflector should only peer with compute nodes.
|
||||
peer_ips = [node["internal_address"] for node in config["nodes"]
|
||||
if node["role"] == "compute"]
|
||||
|
||||
return peer_ips
|
||||
|
||||
if __name__ == "__main__":
|
||||
peer_ips = main()
|
||||
if peer_ips:
|
||||
print " ".join(peer_ips)
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2015 Metaswitch Networks
|
||||
|
||||
import os
|
||||
|
||||
PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
|
||||
CONTROLLER_CFG = "/etc/controller.yaml"
|
||||
COMPUTE_CFG = "/etc/compute.yaml"
|
||||
|
||||
def get_config_file_for_node_type():
|
||||
if os.path.isfile(PRIMARY_CONTROLLER_CFG):
|
||||
config_file = PRIMARY_CONTROLLER_CFG
|
||||
|
||||
elif os.path.isfile(CONTROLLER_CFG):
|
||||
config_file = CONTROLLER_CFG
|
||||
|
||||
elif os.path.isfile(COMPUTE_CFG):
|
||||
config_file = COMPUTE_CFG
|
||||
|
||||
else:
|
||||
raise Exception("Unrecognised node type - can't obtain config")
|
||||
|
||||
return config_file
|
Loading…
Reference in New Issue