diff options
author | Dimitrios Markou <mardim@intracom-telecom.com> | 2018-06-06 14:14:15 +0300 |
---|---|---|
committer | Dimitrios Markou <mardim@intracom-telecom.com> | 2018-06-15 12:56:43 +0000 |
commit | 88bf65b1250fb3ad84b027a57c4fc5ee077ff3de (patch) | |
tree | e6c7f52a41e27dae56a8f4c000204010c82cdb0d /sdnvpn/lib/utils.py | |
parent | 9ce4e2db4f6ace34dbd4a6308983589e8e810471 (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>
Diffstat (limited to 'sdnvpn/lib/utils.py')
-rw-r--r-- | sdnvpn/lib/utils.py | 42 |
1 files changed, 42 insertions, 0 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 |