Browse Source

Configure the route reflector to peer with compute nodes only, not all nodes

Change-Id: I24a81e0f3e000bce9209d4acba74a53375308628
tags/liberty-eol
Emma Gordon 4 years ago
parent
commit
85ddb63714

+ 3
- 3
deployment_scripts/calico_route_reflector.sh View File

@@ -7,9 +7,9 @@ set -x
7 7
 
8 8
 echo "Hi, I'm a route_reflector node!"
9 9
 
10
-this_node_address=$(grep `hostname` /etc/hosts | awk '{print $1;}')
10
+this_node_address=$(python get_node_ip.py `hostname`)
11 11
 
12
-all_nodes=$(grep node- /etc/hosts | awk '{print $1;}')
12
+bgp_peers=$(python get_rr_peers.py)
13 13
 
14 14
 # Generate basic config for a BIRD BGP route reflector.
15 15
 cat > /etc/bird/bird.conf <<EOF
@@ -39,7 +39,7 @@ protocol device {
39 39
 EOF
40 40
 
41 41
 # Add a BGP protocol stanza for each compute node.
42
-for node in $all_nodes; do
42
+for node in $bgp_peers; do
43 43
     if [ $node != $this_node_address ]; then
44 44
         cat >> /etc/bird/bird.conf <<EOF
45 45
 

+ 1
- 20
deployment_scripts/get_node_ip.py View File

@@ -1,31 +1,12 @@
1 1
 #!/usr/bin/env python
2 2
 # Copyright 2015 Metaswitch Networks
3 3
 
4
-import os
5 4
 import sys
6 5
 import yaml
6
+from pluginutils import get_config_file_for_node_type
7 7
 
8 8
 usage = "./get_node_ip.py <hostname>"
9 9
 
10
-PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
11
-CONTROLLER_CFG = "/etc/controller.yaml"
12
-COMPUTE_CFG = "/etc/compute.yaml"
13
-
14
-def 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
-
29 10
 def main(hostname):
30 11
     config_file = get_config_file_for_node_type()
31 12
 

+ 23
- 0
deployment_scripts/get_rr_peers.py View File

@@ -0,0 +1,23 @@
1
+#!/usr/bin/env python
2
+# Copyright 2015 Metaswitch Networks
3
+
4
+import yaml
5
+from pluginutils import get_config_file_for_node_type
6
+
7
+def 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
+
19
+if __name__ == "__main__":
20
+    peer_ips = main()
21
+    if peer_ips:
22
+        print " ".join(peer_ips)
23
+

+ 23
- 0
deployment_scripts/pluginutils.py View File

@@ -0,0 +1,23 @@
1
+#!/usr/bin/env python
2
+# Copyright 2015 Metaswitch Networks
3
+
4
+import os
5
+
6
+PRIMARY_CONTROLLER_CFG = "/etc/primary-controller.yaml"
7
+CONTROLLER_CFG = "/etc/controller.yaml"
8
+COMPUTE_CFG = "/etc/compute.yaml"
9
+
10
+def 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

Loading…
Cancel
Save