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
4 changed files with 50 additions and 23 deletions
  1. +3
    -3
      deployment_scripts/calico_route_reflector.sh
  2. +1
    -20
      deployment_scripts/get_node_ip.py
  3. +23
    -0
      deployment_scripts/get_rr_peers.py
  4. +23
    -0
      deployment_scripts/pluginutils.py

+ 3
- 3
deployment_scripts/calico_route_reflector.sh View File

@@ -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
- 20
deployment_scripts/get_node_ip.py View File

@@ -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()


+ 23
- 0
deployment_scripts/get_rr_peers.py View File

@@ -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)


+ 23
- 0
deployment_scripts/pluginutils.py View File

@@ -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…
Cancel
Save