summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitrios Markou <mardim@intracom-telecom.com>2018-06-06 14:14:15 +0300
committerDimitrios Markou <mardim@intracom-telecom.com>2018-06-14 12:41:12 +0300
commit84a643211a012a965888403d500ee34e14865777 (patch)
tree8cbe16858c418c619d38ebce9107656fd1bde335
parent96d17e018f0b4b4547689a31fb0e4f4af1d65a07 (diff)
[Bug Fix] Determine the BGP entity owner in ODL Cluster
In HA deployments is essential to determine which is the ODL BGP entity owner and transform that ODL to BGP speaker. This is necessary because of this bug [0] in netvirt. So we can consider this as a workaround for the testcase_3. Note: This patch is dependent on this task resolution [1] for master branch. Note: This patch works fine in stable/fraser branch. [0] https://jira.opendaylight.org/browse/NETVIRT-1308 [1] https://jira.opnfv.org/browse/SDNVPN-217 Jira: SDNVPN-214 Change-Id: I383987e650da45400a3a6437dbdaaea904db9265 Signed-off-by: Dimitrios Markou <mardim@intracom-telecom.com>
-rw-r--r--sdnvpn/lib/utils.py42
-rw-r--r--sdnvpn/test/functest/testcase_3.py57
2 files changed, 80 insertions, 19 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 0748803..33ff594 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -900,3 +900,45 @@ def get_ovs_flows(compute_node_list, ovs_br_list, of_protocol="OpenFlow13"):
cmd_out_lines += (compute_node.run_cmd(ovs_flows_cmd).strip().
split("\n"))
return cmd_out_lines
+
+
+def get_odl_bgp_entity_owner(controllers):
+ """ Finds the ODL owner of the BGP entity in the cluster.
+
+ When ODL runs in clustering mode we need to execute the BGP speaker
+ related commands to that ODL which is the owner of the BGP entity.
+
+ :param controllers: list of OS controllers
+ :return controller: OS controller in which ODL BGP entity owner runs
+ """
+ if len(controllers) == 1:
+ return controllers[0]
+ else:
+ url = ('http://admin:admin@{ip}:8081/restconf/'
+ 'operational/entity-owners:entity-owners/entity-type/bgp'
+ .format(ip=controllers[0].ip))
+
+ remote_odl_akka_conf = ('/opt/opendaylight/configuration/'
+ 'initial/akka.conf')
+ remote_odl_home_akka_conf = '/home/heat-admin/akka.conf'
+ local_tmp_akka_conf = '/tmp/akka.conf'
+ try:
+ json_output = requests.get(url).json()
+ except Exception:
+ logger.error('Failed to find the ODL BGP '
+ 'entity owner through REST')
+ return None
+ odl_bgp_owner = json_output['entity-type'][0]['entity'][0]['owner']
+
+ for controller in controllers:
+
+ controller.run_cmd('sudo cp {0} /home/heat-admin/'
+ .format(remote_odl_akka_conf))
+ controller.run_cmd('sudo chmod 777 {0}'
+ .format(remote_odl_home_akka_conf))
+ controller.get_file(remote_odl_home_akka_conf, local_tmp_akka_conf)
+
+ for line in open(local_tmp_akka_conf):
+ if re.search(odl_bgp_owner, line):
+ return controller
+ return None
diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py
index 95023c6..b7fe642 100644
--- a/sdnvpn/test/functest/testcase_3.py
+++ b/sdnvpn/test/functest/testcase_3.py
@@ -17,6 +17,7 @@
import logging
import os
import sys
+import time
from sdnvpn.lib import quagga
from sdnvpn.lib import openstack_utils as os_utils
@@ -60,33 +61,48 @@ def main():
logger.info(msg)
results.add_success(msg)
- controller = controllers[0] # We don't handle HA well
- get_ext_ip_cmd = "sudo ip a | grep br-ex | grep inet | awk '{print $2}'"
- ext_net_cidr = controller.run_cmd(get_ext_ip_cmd).strip().split('\n')
- ext_net_mask = ext_net_cidr[0].split('/')[1]
- controller_ext_ip = ext_net_cidr[0].split('/')[0]
-
- logger.info("Starting bgp speaker of controller at IP %s "
- % controller_ext_ip)
logger.info("Checking if zrpcd is "
- "running on the controller node")
-
- output_zrpcd = controller.run_cmd("ps --no-headers -C "
- "zrpcd -o state")
- states = output_zrpcd.split()
- running = any([s != 'Z' for s in states])
+ "running on the controller nodes")
+
+ for controller in controllers:
+ output_zrpcd = controller.run_cmd("ps --no-headers -C "
+ "zrpcd -o state")
+ states = output_zrpcd.split()
+ running = any([s != 'Z' for s in states])
+ msg = ("zrpcd is running in {name}".format(name=controller.name))
+
+ if not running:
+ logger.info("zrpcd is not running on the controller node {name}"
+ .format(name=controller.name))
+ results.add_failure(msg)
+ else:
+ logger.info("zrpcd is running on the controller node {name}"
+ .format(name=controller.name))
+ results.add_success(msg)
- msg = ("zrpcd is running")
+ results.add_to_summary(0, "-")
- if not running:
- logger.info("zrpcd is not running on the controller node")
+ # Find the BGP entity owner in ODL because of this bug:
+ # https://jira.opendaylight.org/browse/NETVIRT-1308
+ msg = ("Found BGP entity owner")
+ controller = test_utils.get_odl_bgp_entity_owner(controllers)
+ if controller is None:
+ logger.error("Failed to find the BGP entity owner")
results.add_failure(msg)
else:
- logger.info("zrpcd is running on the controller node")
+ logger.info('BGP entity owner is {name}'
+ .format(name=controller.name))
results.add_success(msg)
-
results.add_to_summary(0, "-")
+ get_ext_ip_cmd = "sudo ip a | grep br-ex | grep inet | awk '{print $2}'"
+ ext_net_cidr = controller.run_cmd(get_ext_ip_cmd).strip().split('\n')
+ ext_net_mask = ext_net_cidr[0].split('/')[1]
+ controller_ext_ip = ext_net_cidr[0].split('/')[0]
+
+ logger.info("Starting bgp speaker of controller at IP %s "
+ % controller_ext_ip)
+
# Ensure that ZRPCD ip & port are well configured within ODL
add_client_conn_to_bgp = "bgp-connect -p 7644 -h 127.0.0.1 add"
test_utils.run_odl_cmd(controller, add_client_conn_to_bgp)
@@ -96,6 +112,9 @@ def main():
"--as-num 100 --router-id {0}".format(controller_ext_ip)
test_utils.run_odl_cmd(controller, start_quagga)
+ # we need to wait a bit until the bgpd is up
+ time.sleep(5)
+
logger.info("Checking if bgpd is running"
" on the controller node")