summaryrefslogtreecommitdiffstats
path: root/sdnvpn/lib/utils.py
diff options
context:
space:
mode:
authorRomanos Skiadas <rski@intracom-telecom.com>2016-09-08 16:23:40 +0300
committerRomanos Skiadas <rski@intracom-telecom.com>2017-03-02 15:54:33 +0200
commitbe5cd25ed85bb42f4115b49aec13ddfec20c1b97 (patch)
tree656520216279d026ad7c1bd3c8eb013deb810648 /sdnvpn/lib/utils.py
parent71273a2b8d51725be2743010fb65fb46229dd10c (diff)
Implement quagga peering
- Create an openstack instance - Assign it a floating IP - Execute a quagga bootstrap script using cloud init - Tell ODL to peer with the instance - Start an instance in a VPN - make sure the route was exchanged between the peered quagga and ODL Change-Id: I73bcaec5425df2b953c2bceaca7d4f09ff28f3d0 Signed-off-by: Romanos Skiadas <rski@intracom-telecom.com>
Diffstat (limited to 'sdnvpn/lib/utils.py')
-rw-r--r--sdnvpn/lib/utils.py62
1 files changed, 61 insertions, 1 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 00d0fa7..149a37e 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -9,10 +9,12 @@
#
import sys
import time
+import requests
+import re
+import subprocess
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
-import re
from sdnvpn.lib import config as sdnvpn_config
@@ -20,6 +22,9 @@ logger = ft_logger.Logger("sndvpn_test_utils").getLogger()
common_config = sdnvpn_config.CommonConfig()
+ODL_USER = 'admin'
+ODL_PASS = 'admin'
+
def create_net(neutron_client, name):
logger.debug("Creating network %s", name)
@@ -301,3 +306,58 @@ def open_icmp_ssh(neutron_client, security_group_id):
security_group_id,
'tcp',
80, 80)
+
+
+def open_bgp_port(neutron_client, security_group_id):
+ os_utils.create_secgroup_rule(neutron_client,
+ security_group_id,
+ 'tcp',
+ 179, 179)
+
+
+def exec_cmd(cmd, verbose):
+ success = True
+ logger.debug("Executing '%s'" % cmd)
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ output = ""
+ for line in iter(p.stdout.readline, b''):
+ output += line
+
+ if verbose:
+ logger.debug(output)
+
+ p.stdout.close()
+ returncode = p.wait()
+ if returncode != 0:
+ logger.error("Command %s failed to execute." % cmd)
+ success = False
+
+ return output, success
+
+
+def check_odl_fib(ip, controller_ip):
+ """Check that there is an entry in the ODL Fib for `ip`"""
+ url = "http://" + controller_ip + \
+ ":8181/restconf/config/odl-fib:fibEntries/"
+ logger.debug("Querring '%s' for FIB entries", url)
+ res = requests.get(url, auth=(ODL_USER, ODL_PASS))
+ if res.status_code != 200:
+ logger.error("OpenDaylight response status code: %s", res.status_code)
+ return False
+ logger.debug("Checking whether '%s' is in the OpenDaylight FIB"
+ % controller_ip)
+ logger.debug("OpenDaylight FIB: \n%s" % res.text)
+ return ip in res.text
+
+
+def run_odl_cmd(odl_node, cmd):
+ '''
+ 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.
+ '''
+ karaf_cmd = '/opt/opendaylight/bin/client "%s" ' % cmd
+ return odl_node.run_cmd(karaf_cmd)