summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomanos Skiadas <rski@intracom-telecom.com>2017-03-17 10:55:28 +0200
committertomsou <soth@intracom-telecom.com>2017-03-22 15:04:11 +0000
commitb5b2a3abd74f84943cf3fab7ca7da591d326661c (patch)
treeea7824d4f69c514f5142354194bbcea5ff92c562
parentf7a6f2593a1b99a0bd0459093d606dd4bdbb999a (diff)
Testcase 3 Apex compatibility fixes
- Workaround a bug releng in getting opedaylight nodes - Add some sudo commands because the path is not properly set otherwise it seems - remove needless command that gets ip information from the compute, since that is already available from when the command was ran on the controller - Handle attaching the quagga instance to Apex's br-ex ovs bridge Change-Id: I870f1049d9cce696ec26376a09db5f9e9bac0bf9 Signed-off-by: Romanos Skiadas <rski@intracom-telecom.com>
-rw-r--r--sdnvpn/artifacts/quagga_setup.sh23
-rw-r--r--sdnvpn/lib/utils.py27
-rw-r--r--sdnvpn/test/functest/testcase_3.py37
3 files changed, 68 insertions, 19 deletions
diff --git a/sdnvpn/artifacts/quagga_setup.sh b/sdnvpn/artifacts/quagga_setup.sh
index 96d7374..6e61d9a 100644
--- a/sdnvpn/artifacts/quagga_setup.sh
+++ b/sdnvpn/artifacts/quagga_setup.sh
@@ -20,8 +20,27 @@ OWN_IP=%s
# directly access the instance from the external net without NAT
EXT_NET_MASK=%s
-ip link set ens7 up
-ip addr add $OWN_IP/$EXT_NET_MASK dev ens7
+if [[ $(getent hosts | awk '{print $2}') != *"$(cat /etc/hostname | awk '{print $1}')"* ]]
+then
+echo "127.0.1.1 $(cat /etc/hostname | awk '{print $1}')" | tee -a /etc/hosts
+fi
+
+quagga_int=''
+for net_int in $(netstat -ia | awk 'NR>2{print $1}');
+do
+if [ -z "$(ifconfig | grep $net_int)" ]
+then
+quagga_int=$net_int
+break
+fi
+done
+if [ -z "$quagga_int" ]
+then
+echo 'No available network interface'
+fi
+
+ip link set $quagga_int up
+ip addr add $OWN_IP/$EXT_NET_MASK dev $quagga_int
ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 27fd5b3..5dcb8c1 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -437,3 +437,30 @@ def wait_for_cloud_init(instance):
success = False
return success
+
+
+def attach_instance_to_ext_br(instance, compute_node):
+ libvirt_instance_name = getattr(instance, "OS-EXT-SRV-ATTR:instance_name")
+ installer_type = str(os.environ['INSTALLER_TYPE'].lower())
+ if installer_type == "fuel":
+ bridge = "br-ex"
+ elif installer_type == "apex":
+ # In Apex, br-ex is an ovs bridge and virsh attach-interface
+ # won't just work. We work around it by creating a linux
+ # bridge, attaching that to br-ex with a veth pair
+ # and virsh-attaching the instance to the linux-bridge
+ bridge = "br-quagga"
+ cmd = """
+ set -xe
+ sudo brctl addbr {bridge} &&
+ sudo ip link set {bridge} up &&
+ sudo ip link add quagga-tap type veth peer name ovs-quagga-tap &&
+ sudo ip link set dev ovs-quagga-tap up &&
+ sudo ip link set dev quagga-tap up &&
+ sudo ovs-vsctl add-port br-ex ovs-quagga-tap &&
+ sudo brctl addif {bridge} quagga-tap
+ """
+ compute_node.run_cmd(cmd.format(bridge=bridge))
+
+ compute_node.run_cmd("sudo virsh attach-interface %s"
+ " bridge %s" % (libvirt_instance_name, bridge))
diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py
index cc0f6b0..416af39 100644
--- a/sdnvpn/test/functest/testcase_3.py
+++ b/sdnvpn/test/functest/testcase_3.py
@@ -47,8 +47,11 @@ def main():
openstack_nodes = test_utils.get_nodes()
+ # node.is_odl() doesn't work in Apex
+ # https://jira.opnfv.org/browse/RELENG-192
controllers = [node for node in openstack_nodes
- if node.is_odl()]
+ if "running" in
+ node.run_cmd("sudo systemctl status opendaylight")]
computes = [node for node in openstack_nodes if node.is_compute()]
msg = ("Verify that OpenDaylight can start/communicate with zrpcd/Quagga")
results.record_action(msg)
@@ -64,8 +67,11 @@ def main():
results.add_success(msg)
controller = controllers[0] # We don't handle HA well
- get_ext_ip_cmd = "ip a | grep br-ex | grep inet | awk '{print $2}'"
- controller_ext_ip = controller.run_cmd(get_ext_ip_cmd).split("/")[0]
+ 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]
+
logger.info("Starting bgp speaker of controller at IP %s "
% controller_ext_ip)
logger.info("Checking if zrpcd is "
@@ -161,11 +167,19 @@ 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":
+ disk = 'qcow2'
+ else:
+ logger.error("Incompatible installer type")
+
ubuntu_image_id = os_utils.create_glance_image(
glance_client,
COMMON_CONFIG.ubuntu_image_name,
COMMON_CONFIG.ubuntu_image_path,
- disk="raw",
+ disk,
container="bare",
public="public")
@@ -188,13 +202,9 @@ def main():
# Map the hypervisor used above to a compute handle
# returned by releng's manager
for comp in computes:
- if compute_node.host_ip in comp.run_cmd("ip a"):
+ if compute_node.host_ip in comp.run_cmd("sudo ip a"):
compute = comp
break
- # Get the mask of ext net of the compute where quagga is running
- # TODO check this works on apex
- ext_cidr = compute.run_cmd(get_ext_ip_cmd).split("/")
- ext_net_mask = ext_cidr[1]
quagga_bootstrap_script = quagga.gen_quagga_setup_script(
controller_ext_ip,
fake_fip['fip_addr'],
@@ -223,14 +233,7 @@ def main():
else:
results.add_failure(msg)
- # This part works around NAT
- # What we do is attach the instance directly to the OpenStack
- # external network. This way is is directly accessible from the
- # controller without NAT. We assign a floating IP for this
- # to make sure no overlaps happen.
- libvirt_instance_name = getattr(quagga_vm, "OS-EXT-SRV-ATTR:instance_name")
- compute.run_cmd("virsh attach-interface %s"
- " bridge br-ex" % libvirt_instance_name)
+ test_utils.attach_instance_to_ext_br(quagga_vm, compute)
testcase = "Bootstrap quagga inside an OpenStack instance"
cloud_init_success = test_utils.wait_for_cloud_init(quagga_vm)