summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimitris.tsiolakis <dmts@intracom-telecom.com>2018-10-16 10:01:28 +0300
committerStamatis Katsaounis <mokats@intracom-telecom.com>2018-11-06 12:47:10 +0200
commit092e15806c6825affdc6810e602be702799928c7 (patch)
treeb05a91064ff2cffc5b5be36b2977301781decbdb
parent95dad3f4a73a22988c7a9b4694ce0d7e90cd8147 (diff)
Find the ODL owner of the BGP entity in the
cluster in TC 3 After new Apex release Opendaylight run in container. This fix finds the ODL owner of the BGP entity in the cluster for containerised installations. JIRA: SDNVPN-238 JIRA: SDNVPN-234 Change-Id: Iec1abfe3e0be899ab51fe52057b394a4fa15cc49 Signed-off-by: dimitris.tsiolakis <dmts@intracom-telecom.com> (cherry picked from commit 9d550e5108399bc1f85186956dabc6cbe3a3ec85)
-rw-r--r--sdnvpn/lib/utils.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 135501c..1b39c31 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -910,6 +910,16 @@ def get_ovs_flows(compute_node_list, ovs_br_list, of_protocol="OpenFlow13"):
return cmd_out_lines
+def get_node_ip_and_netmask(node, iface):
+ cmd = "ip a | grep {iface} | grep inet | awk '{{print $2}}'"\
+ .format(iface=iface)
+ mgmt_net_cidr = node.run_cmd(cmd).strip().split('\n')
+ mgmt_ip = mgmt_net_cidr[0].split('/')[0]
+ mgmt_netmask = mgmt_net_cidr[0].split('/')[1]
+
+ return mgmt_ip, mgmt_netmask
+
+
def get_odl_bgp_entity_owner(controllers):
""" Finds the ODL owner of the BGP entity in the cluster.
@@ -922,9 +932,18 @@ def get_odl_bgp_entity_owner(controllers):
if len(controllers) == 1:
return controllers[0]
else:
- url = ('http://admin:admin@{ip}:8081/restconf/'
+ installer_type = str(os.environ['INSTALLER_TYPE'].lower())
+ if installer_type in ['fuel']:
+ ip, _ = get_node_ip_and_netmask(controllers[0], 'br-ctl')
+ port = 8282
+ odl_pass = 'admin'
+ else:
+ ip = controllers[0].ip
+ port = 8081
+ odl_pass = os.environ['SDN_CONTROLLER_PASSWORD']
+ url = ('http://{user}:{password}@{ip}:{port}/restconf/'
'operational/entity-owners:entity-owners/entity-type/bgp'
- .format(ip=controllers[0].ip))
+ .format(user='admin', password=odl_pass, ip=ip, port=port))
remote_odl_akka_conf = ('/opt/opendaylight/configuration/'
'initial/akka.conf')
@@ -938,10 +957,13 @@ def get_odl_bgp_entity_owner(controllers):
return None
odl_bgp_owner = json_output['entity-type'][0]['entity'][0]['owner']
+ get_odl_id_cmd = "sudo docker ps -qf name=opendaylight_api"
for controller in controllers:
-
- controller.run_cmd('sudo cp {0} /home/heat-admin/'
- .format(remote_odl_akka_conf))
+ odl_id = controller.run_cmd(get_odl_id_cmd)
+ controller.run_cmd('sudo docker cp {container_id}:{odl_akka_conf} '
+ '/home/heat-admin/'
+ .format(container_id=odl_id,
+ odl_akka_conf=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)