summaryrefslogtreecommitdiffstats
path: root/sdnvpn/lib
diff options
context:
space:
mode:
authorNikolas Hermanns <nikolas.hermanns@ericsson.com>2017-03-16 12:49:50 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-16 12:49:50 +0000
commit6bb2eae86a0935443d8e65df0780c3df994a669b (patch)
treef55e1d22f16a9d8dcad4bc041aca879969531c00 /sdnvpn/lib
parent7efb216ca8357533dd040cccc49cb5effec42615 (diff)
parent6674049b09d02fe0dc7e11e007e710643cdd49ca (diff)
Merge "Fix most end-to-end issues with testcase 3 and reenable it"
Diffstat (limited to 'sdnvpn/lib')
-rw-r--r--sdnvpn/lib/quagga.py10
-rw-r--r--sdnvpn/lib/utils.py36
2 files changed, 40 insertions, 6 deletions
diff --git a/sdnvpn/lib/quagga.py b/sdnvpn/lib/quagga.py
index 9f8a4cd..dc80657 100644
--- a/sdnvpn/lib/quagga.py
+++ b/sdnvpn/lib/quagga.py
@@ -13,10 +13,14 @@ logger = ft_logger.Logger("sdnvpn-quagga").getLogger()
COMMON_CONFIG = config.CommonConfig()
-def odl_add_neighbor(neighbor_ip, controller):
+def odl_add_neighbor(neighbor_ip, controller_ip, controller):
+ # Explicitly pass controller_ip because controller.ip
+ # Might not be accessible from the Quagga instance
command = 'configure-bgp -op add-neighbor --as-num 200'
- command += ' --ip %s --use-source-ip %s' % (neighbor_ip, controller.ip)
+ command += ' --ip %s --use-source-ip %s' % (neighbor_ip, controller_ip)
success = run_odl_cmd(controller, command)
+ # The run_cmd api is really whimsical
+ logger.info("Maybe stdout of %s: %s", command, success)
return success
@@ -41,7 +45,7 @@ def gen_quagga_setup_script(controller_ip,
def check_for_peering(controller):
- cmd = 'show-bgp --cmd "ip bgp neighbors"'
+ cmd = 'show-bgp --cmd \\"ip bgp neighbors\\"'
tries = 20
neighbors = None
bgp_state_regex = re.compile("(BGP state =.*)")
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 0a77796..a047269 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -391,12 +391,42 @@ def check_odl_fib(ip, controller_ip):
def run_odl_cmd(odl_node, cmd):
- '''
- Run a command in the OpenDaylight Karaf shell
+ '''Run a command in the OpenDaylight Karaf shell
This is a bit flimsy because of shell quote escaping, make sure that
the cmd passed does not have any top level double quotes or this
function will break.
+
+ The /dev/null is used because client works, but outputs something
+ that contains "ERROR" and run_cmd doesn't like that.
+
'''
- karaf_cmd = '/opt/opendaylight/bin/client "%s" ' % cmd
+ karaf_cmd = '/opt/opendaylight/bin/client "%s" 2>/dev/null' % cmd
return odl_node.run_cmd(karaf_cmd)
+
+
+def wait_for_cloud_init(instance):
+ success = True
+ # ubuntu images take a long time to start
+ tries = 20
+ sleep_time = 30
+ while tries > 0:
+ instance_log = instance.get_console_output()
+ if "Failed to run module" in instance_log:
+ success = False
+ logger.error("Cloud init failed to run. Reason: %s",
+ instance_log)
+ break
+ if re.search(r"Cloud-init v. .+ finished at" in instance_log):
+ success = True
+ break
+ time.sleep(sleep_time)
+ tries = tries - 1
+
+ if tries == 0:
+ logger.error("Cloud init timed out"
+ ". Reason: %s",
+ instance_log)
+ success = False
+
+ return success