summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Gordon <emma@projectcalico.org>2015-07-08 17:45:41 +0100
committerEmma Gordon <emma@projectcalico.org>2015-07-14 15:06:36 +0100
commit85ddb637143e884ae0b2989badd5a7b2f65df9ae (patch)
tree5f4cd495d2a194a62a0f5e369c70a49df6b25dbf
parentfb7b7a9f10131ecac1baf19f6d02f712b882497b (diff)
Configure the route reflector to peer with compute nodes only, not all nodes
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Neil Jerram <Neil.Jerram@metaswitch.com> Workflow+1: Neil Jerram <Neil.Jerram@metaswitch.com> Submitted-by: Jenkins Submitted-at: Tue, 14 Jul 2015 16:15:29 +0000 Reviewed-on: https://review.openstack.org/199647 Project: stackforge/fuel-plugin-calico Branch: refs/heads/master
-rwxr-xr-xdeployment_scripts/calico_route_reflector.sh6
-rwxr-xr-xdeployment_scripts/get_node_ip.py21
-rwxr-xr-xdeployment_scripts/get_rr_peers.py23
-rwxr-xr-xdeployment_scripts/pluginutils.py23
4 files changed, 50 insertions, 23 deletions
diff --git a/deployment_scripts/calico_route_reflector.sh b/deployment_scripts/calico_route_reflector.sh
index 301d5e0..a04982a 100755
--- a/deployment_scripts/calico_route_reflector.sh
+++ b/deployment_scripts/calico_route_reflector.sh
@@ -7,9 +7,9 @@ set -x
7 7
8echo "Hi, I'm a route_reflector node!" 8echo "Hi, I'm a route_reflector node!"
9 9
10this_node_address=$(grep `hostname` /etc/hosts | awk '{print $1;}') 10this_node_address=$(python get_node_ip.py `hostname`)
11 11
12all_nodes=$(grep node- /etc/hosts | awk '{print $1;}') 12bgp_peers=$(python get_rr_peers.py)
13 13
14# Generate basic config for a BIRD BGP route reflector. 14# Generate basic config for a BIRD BGP route reflector.
15cat > /etc/bird/bird.conf <<EOF 15cat > /etc/bird/bird.conf <<EOF
@@ -39,7 +39,7 @@ protocol device {
39EOF 39EOF
40 40
41# Add a BGP protocol stanza for each compute node. 41# Add a BGP protocol stanza for each compute node.
42for node in $all_nodes; do 42for node in $bgp_peers; do
43 if [ $node != $this_node_address ]; then 43 if [ $node != $this_node_address ]; then
44 cat >> /etc/bird/bird.conf <<EOF 44 cat >> /etc/bird/bird.conf <<EOF
45 45
diff --git a/deployment_scripts/get_node_ip.py b/deployment_scripts/get_node_ip.py
index ffcb328..2b47fb5 100755
--- a/deployment_scripts/get_node_ip.py
+++ b/deployment_scripts/get_node_ip.py
@@ -1,31 +1,12 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# Copyright 2015 Metaswitch Networks 2# Copyright 2015 Metaswitch Networks
3 3
4import os
5import sys 4import sys
6import yaml 5import yaml
6from pluginutils import get_config_file_for_node_type
7 7
8usage = "./get_node_ip.py <hostname>" 8usage = "./get_node_ip.py <hostname>"
9 9
10PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
11CONTROLLER_CFG = "/etc/controller.yaml"
12COMPUTE_CFG = "/etc/compute.yaml"
13
14def get_config_file_for_node_type():
15 if os.path.isfile(PRIMARY_CONTROLLER_CFG):
16 config_file = PRIMARY_CONTROLLER_CFG
17
18 elif os.path.isfile(CONTROLLER_CFG):
19 config_file = CONTROLLER_CFG
20
21 elif os.path.isfile(COMPUTE_CFG):
22 config_file = COMPUTE_CFG
23
24 else:
25 raise Exception("Unrecognised node type - can't obtain config")
26
27 return config_file
28
29def main(hostname): 10def main(hostname):
30 config_file = get_config_file_for_node_type() 11 config_file = get_config_file_for_node_type()
31 12
diff --git a/deployment_scripts/get_rr_peers.py b/deployment_scripts/get_rr_peers.py
new file mode 100755
index 0000000..9ee1ef7
--- /dev/null
+++ b/deployment_scripts/get_rr_peers.py
@@ -0,0 +1,23 @@
1#!/usr/bin/env python
2# Copyright 2015 Metaswitch Networks
3
4import yaml
5from pluginutils import get_config_file_for_node_type
6
7def main():
8 config_file = get_config_file_for_node_type()
9
10 with open(config_file, "r") as f:
11 config = yaml.safe_load(f)
12
13 # The route reflector should only peer with compute nodes.
14 peer_ips = [node["internal_address"] for node in config["nodes"]
15 if node["role"] == "compute"]
16
17 return peer_ips
18
19if __name__ == "__main__":
20 peer_ips = main()
21 if peer_ips:
22 print " ".join(peer_ips)
23
diff --git a/deployment_scripts/pluginutils.py b/deployment_scripts/pluginutils.py
new file mode 100755
index 0000000..ae8c0db
--- /dev/null
+++ b/deployment_scripts/pluginutils.py
@@ -0,0 +1,23 @@
1#!/usr/bin/env python
2# Copyright 2015 Metaswitch Networks
3
4import os
5
6PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
7CONTROLLER_CFG = "/etc/controller.yaml"
8COMPUTE_CFG = "/etc/compute.yaml"
9
10def get_config_file_for_node_type():
11 if os.path.isfile(PRIMARY_CONTROLLER_CFG):
12 config_file = PRIMARY_CONTROLLER_CFG
13
14 elif os.path.isfile(CONTROLLER_CFG):
15 config_file = CONTROLLER_CFG
16
17 elif os.path.isfile(COMPUTE_CFG):
18 config_file = COMPUTE_CFG
19
20 else:
21 raise Exception("Unrecognised node type - can't obtain config")
22
23 return config_file