Fix testcase3 (peering subcase) for Apex 77/31877/1
authortomsou <soth@intracom-telecom.com>
Thu, 23 Mar 2017 13:50:00 +0000 (13:50 +0000)
committerNikolas Hermanns <nikolas.hermanns@ericsson.com>
Mon, 27 Mar 2017 07:50:29 +0000 (07:50 +0000)
 - Fix runnning bgp related commands on Karaf:
   update util.run_odl_cmd() in order to be able to
   run commands on karaf client. Otherwise karaf
   commands fail
 - Ensure zrpcd/bgpd to run on controller side properly:
   Add missing quagga run folder, change owner and
   add user quagga into quaggavt group, in case of apex
   installer
 - Update the way of handling br-ex information and
   parsing out the controller external ip and mask:
   In case we have multiple ip/netmask assigned on br-ex
   the separation was faulty and an extra line, containing
   the second ip address, was added into ext_net_mask variable

JIRA: SDNVPN-118

Change-Id: I62468c94fd945ba30e419bd30d9cd85502f28eeb
Signed-off-by: tomsou <soth@intracom-telecom.com>
(cherry picked from commit db1ce6276c443dd9766458c516cc58c7f2e098d5)

sdnvpn/lib/utils.py
sdnvpn/test/functest/testcase_3.py

index 5dcb8c1..90fce4a 100644 (file)
@@ -408,7 +408,8 @@ def run_odl_cmd(odl_node, cmd):
     that contains "ERROR" and run_cmd doesn't like that.
 
     '''
-    karaf_cmd = '/opt/opendaylight/bin/client "%s" 2>/dev/null' % cmd
+    karaf_cmd = ('/opt/opendaylight/bin/client -h 127.0.0.1 "%s"'
+                 ' 2>/dev/null' % cmd)
     return odl_node.run_cmd(karaf_cmd)
 
 
index 416af39..41f8f70 100644 (file)
@@ -1,4 +1,3 @@
-#
 # Copyright (c) 2017 All rights reserved
 # This program and the accompanying materials
 # are made available under the terms of the Apache License, Version 2.0
@@ -68,9 +67,21 @@ def main():
 
     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).split("/")
-    ext_net_mask = ext_net_cidr[1].split('\n')[0]
-    controller_ext_ip = ext_net_cidr[0]
+    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]
+
+    # TODO This code has to be adapted into Apex quagga rpm spec
+    installer_type = str(os.environ['INSTALLER_TYPE'].lower())
+    if installer_type == "apex":
+        add_quagga_user = 'sudo usermod -a -G quaggavt quagga'
+        test_utils.run_odl_cmd(controller, add_quagga_user)
+
+        create_quagga_run_folder = "sudo mkdir -p /var/run/quagga/"
+        test_utils.run_odl_cmd(controller, create_quagga_run_folder)
+
+        chown_quagga_folder = 'sudo chown quagga:quagga -R /var/run/quagga/'
+        test_utils.run_odl_cmd(controller, chown_quagga_folder)
 
     logger.info("Starting bgp speaker of controller at IP %s "
                 % controller_ext_ip)
@@ -167,7 +178,6 @@ def main():
         TESTCASE_CONFIG.quagga_subnet_cidr,
         TESTCASE_CONFIG.quagga_router_name)
 
-    installer_type = str(os.environ['INSTALLER_TYPE'].lower())
     if installer_type == "fuel":
         disk = 'raw'
     elif installer_type == "apex":