From 14de5d725e74cb885a48146217e2fc9d8f093df6 Mon Sep 17 00:00:00 2001 From: Ricardo Noriega Date: Tue, 7 Aug 2018 18:29:54 +0200 Subject: Enable SFC scenarios for Gambia - This patch will install OVS 2.9.2 including its kernel module which allows native NSH headers. - Fix Custom OVS due to bug: https://bugzilla.redhat.com/show_bug.cgi?id=1544892 - Tacker is disable for the time being, tacker-conductor needs to be enabled. JIRA: APEX-630 Change-Id: Ia410309fd7053602ce78eae919839d0f57c9742a Signed-off-by: Ricardo Noriega --- apex/builders/overcloud_builder.py | 37 +++++++++++++++++++++++++ apex/common/constants.py | 5 ++-- apex/deploy.py | 3 ++ apex/overcloud/deploy.py | 25 ++--------------- apex/tests/test_apex_overcloud_deploy.py | 30 ++++++++++++++++++++ apex/tests/test_apex_undercloud.py | 3 +- build/build_ovs_nsh.sh | 20 +++++++++++++ build/rpm_specs/opnfv-apex.spec | 4 +++ config/deploy/os-odl-sfc-ha.yaml | 8 ++++-- config/deploy/os-odl-sfc-noha.yaml | 8 ++++-- config/deploy/os-odl-sfc_queens-ha.yaml | 13 +++++++++ config/deploy/os-odl-sfc_queens-noha.yaml | 13 +++++++++ lib/ansible/playbooks/post_deploy_overcloud.yml | 9 ------ setup.cfg | 1 + 14 files changed, 138 insertions(+), 41 deletions(-) create mode 100644 build/build_ovs_nsh.sh create mode 100644 config/deploy/os-odl-sfc_queens-ha.yaml create mode 100644 config/deploy/os-odl-sfc_queens-noha.yaml diff --git a/apex/builders/overcloud_builder.py b/apex/builders/overcloud_builder.py index b8556456..a74ec252 100644 --- a/apex/builders/overcloud_builder.py +++ b/apex/builders/overcloud_builder.py @@ -87,6 +87,43 @@ def inject_quagga(image, tmp_dir): logging.info("Quagga injected into {}".format(image)) +def inject_ovs_nsh(image, tmp_dir): + """ + Downloads OpenVswitch, compiles it and installs it on the + overcloud image on the fly. + :param image: + :param tmp_dir: + :return: + """ + ovs_filename = os.path.basename(con.OVS_URL) + ovs_folder = ovs_filename.replace(".tar.gz", "") + utils.fetch_upstream_and_unpack(tmp_dir, + os.path.split(con.OVS_URL)[0] + "/", + [ovs_filename]) + (ovs_dist_name, ovs_version) = ovs_folder.split("-") + + virt_ops = [ + {con.VIRT_UPLOAD: "{}:/root/".format(tmp_dir + "/" + ovs_filename)}, + {con.VIRT_INSTALL: "rpm-build,autoconf,automake,libtool,openssl," + "openssl-devel,python,python-twisted-core,python-six,groff,graphviz," + "python-zope-interface,desktop-file-utils,procps-ng,PyQt4," + "libcap-ng,libcap-ng-devel,selinux-policy-devel,kernel-devel," + "kernel-headers,kernel-tools,rpmdevtools,systemd-units,python-devel," + "python-sphinx"}, + {con.VIRT_RUN_CMD: "cd /root/ && tar xzf {}".format(ovs_filename)}, + {con.VIRT_UPLOAD: + "{}/build_ovs_nsh.sh:/root/{}".format(tmp_dir, ovs_folder)}, + {con.VIRT_RUN_CMD: + "cd /root/{0} && chmod -R 777 * && chown -R root:root * && " + "./build_ovs_nsh.sh && rpm -Uhv --force rpm/rpmbuild/RPMS/x86_64/{0}" + "-1.el7.x86_64.rpm && rpm -Uhv --force rpm/rpmbuild/RPMS/x86_64" + "/openvswitch-kmod-{1}-1.el7.x86_64.rpm".format(ovs_folder, + ovs_version)} + ] + virt_utils.virt_customize(virt_ops, image) + logging.info("OVS injected into {}".format(image)) + + def build_dockerfile(service, tmp_dir, docker_cmds, src_image_uri): """ Builds docker file per service and stores it in a diff --git a/apex/common/constants.py b/apex/common/constants.py index 2ad22ad5..e9c99a34 100644 --- a/apex/common/constants.py +++ b/apex/common/constants.py @@ -64,12 +64,13 @@ VALID_DOCKER_SERVICES = { 'neutron-opendaylight-dpdk.yaml': None, 'neutron-opendaylight-sriov.yaml': None, 'neutron-bgpvpn-opendaylight.yaml': None, + 'neutron-sfc-opendaylight.yaml': None, 'neutron-ml2-ovn.yaml': 'neutron-ovn.yaml' } DOCKERHUB_OOO = 'https://registry.hub.docker.com/v2/repositories' \ '/tripleomaster/' KUBESPRAY_URL = 'https://github.com/kubernetes-incubator/kubespray.git' -CUSTOM_OVS = 'http://artifacts.opnfv.org/apex/random/openvswitch-2.9.0-9' \ - '.el7fdn.x86_64.rpm' QUAGGA_URL = "http://artifacts.opnfv.org/sdnvpn/quagga/quagga-4.tar.gz" + +OVS_URL = "http://openvswitch.org/releases/openvswitch-2.9.2.tar.gz" diff --git a/apex/deploy.py b/apex/deploy.py index 8065d5ca..9510de9d 100644 --- a/apex/deploy.py +++ b/apex/deploy.py @@ -420,6 +420,9 @@ def main(): else: net_data = False + shutil.copyfile(os.path.join(args.deploy_dir, 'build_ovs_nsh.sh'), + os.path.join(APEX_TEMP_DIR, 'build_ovs_nsh.sh')) + # TODO(trozet): Either fix opnfv env or default to use upstream env if args.env_file == 'opnfv-environment.yaml': # Override the env_file if it is defaulted to opnfv diff --git a/apex/overcloud/deploy.py b/apex/overcloud/deploy.py index e310fa21..2f75b40d 100644 --- a/apex/overcloud/deploy.py +++ b/apex/overcloud/deploy.py @@ -72,8 +72,6 @@ OVS_PERF_MAP = { 'NeutronDpdkMemoryChannels': 'memory_channels' } -OVS_NSH_KMOD_RPM = "openvswitch-kmod-2.6.1-1.el7.centos.x86_64.rpm" -OVS_NSH_RPM = "openvswitch-2.6.1-1.el7.centos.x86_64.rpm" ODL_NETVIRT_VPP_RPM = "/root/opendaylight-7.0.0-0.1.20170531snap665.el7" \ ".noarch.rpm" @@ -361,27 +359,8 @@ def prep_image(ds, ns, img, tmp_dir, root_pw=None, docker_tag=None, if dataplane == 'ovs': if ds_opts['sfc']: - virt_cmds.extend([ - {con.VIRT_RUN_CMD: "yum -y install " - "/root/ovs/rpm/rpmbuild/RPMS/x86_64/" - "{}".format(OVS_NSH_KMOD_RPM)}, - {con.VIRT_RUN_CMD: "yum downgrade -y " - "/root/ovs/rpm/rpmbuild/RPMS/x86_64/" - "{}".format(OVS_NSH_RPM)} - ]) - elif sdn == 'opendaylight': - # FIXME(trozet) remove this after RDO is updated with fix for - # https://bugzilla.redhat.com/show_bug.cgi?id=1544892 - ovs_file = os.path.basename(con.CUSTOM_OVS) - ovs_url = con.CUSTOM_OVS.replace(ovs_file, '') - utils.fetch_upstream_and_unpack(dest=tmp_dir, url=ovs_url, - targets=[ovs_file]) - virt_cmds.extend([ - {con.VIRT_UPLOAD: "{}:/root/".format(os.path.join(tmp_dir, - ovs_file))}, - {con.VIRT_RUN_CMD: "yum downgrade -y /root/{}".format( - ovs_file)} - ]) + oc_builder.inject_ovs_nsh(tmp_oc_image, tmp_dir) + if dataplane == 'fdio': # Patch neutron with using OVS external interface for router # and add generic linux NS interface driver diff --git a/apex/tests/test_apex_overcloud_deploy.py b/apex/tests/test_apex_overcloud_deploy.py index 9dd5289d..c2d17408 100644 --- a/apex/tests/test_apex_overcloud_deploy.py +++ b/apex/tests/test_apex_overcloud_deploy.py @@ -242,6 +242,7 @@ class TestOvercloudDeploy(unittest.TestCase): ds_opts = {'dataplane': 'ovs', 'sdn_controller': 'opendaylight', 'vpn': False, + 'sfc': False, 'odl_version': con.DEFAULT_ODL_VERSION, 'odl_vpp_netvirt': True} ds = {'deploy_options': MagicMock(), @@ -340,6 +341,7 @@ class TestOvercloudDeploy(unittest.TestCase): mock_virt_utils): ds_opts = {'dataplane': 'ovs', 'vpn': False, + 'sfc': False, 'sdn_controller': 'ovn'} ds = {'deploy_options': MagicMock(), 'global_params': MagicMock()} @@ -361,6 +363,7 @@ class TestOvercloudDeploy(unittest.TestCase): ds_opts = {'dataplane': 'ovs', 'sdn_controller': 'opendaylight', 'vpn': True, + 'sfc': False, 'odl_version': con.DEFAULT_ODL_VERSION, 'odl_vpp_netvirt': True} ds = {'deploy_options': MagicMock(), @@ -375,6 +378,33 @@ class TestOvercloudDeploy(unittest.TestCase): mock_inject_odl.assert_called() mock_inject_quagga.assert_called() + @patch('apex.builders.overcloud_builder.inject_ovs_nsh') + @patch('apex.builders.overcloud_builder.inject_opendaylight') + @patch('apex.overcloud.deploy.virt_utils') + @patch('apex.overcloud.deploy.shutil') + @patch('apex.overcloud.deploy.os.path') + @patch('builtins.open', mock_open()) + def test_prep_image_sdn_odl_sfc(self, mock_os_path, mock_shutil, + mock_virt_utils, mock_inject_odl, + mock_inject_ovs_nsh): + ds_opts = {'dataplane': 'ovs', + 'sdn_controller': 'opendaylight', + 'vpn': False, + 'sfc': True, + 'odl_version': con.DEFAULT_ODL_VERSION, + 'odl_vpp_netvirt': True} + ds = {'deploy_options': MagicMock(), + 'global_params': MagicMock()} + ds['deploy_options'].__getitem__.side_effect = \ + lambda i: ds_opts.get(i, MagicMock()) + ds['deploy_options'].__contains__.side_effect = \ + lambda i: True if i in ds_opts else MagicMock() + ns = MagicMock() + prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test') + mock_virt_utils.virt_customize.assert_called() + mock_inject_odl.assert_called() + mock_inject_ovs_nsh.assert_called() + @patch('apex.overcloud.deploy.os.path.isfile') def test_prep_image_no_image(self, mock_isfile): mock_isfile.return_value = False diff --git a/apex/tests/test_apex_undercloud.py b/apex/tests/test_apex_undercloud.py index 9bc91e51..5c33bf03 100644 --- a/apex/tests/test_apex_undercloud.py +++ b/apex/tests/test_apex_undercloud.py @@ -309,7 +309,8 @@ class TestUndercloud(unittest.TestCase): } ns.__getitem__.side_effect = ns_dict.__getitem__ ns.__contains__.side_effect = ns_dict.__contains__ - ds = {'global_params': {}} + ds = {'global_params': {}, + 'deploy_options': {}} Undercloud('img_path', 'tplt_path').generate_config(ns, ds) diff --git a/build/build_ovs_nsh.sh b/build/build_ovs_nsh.sh new file mode 100644 index 00000000..4e15c363 --- /dev/null +++ b/build/build_ovs_nsh.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +############################################################################## +# Copyright (c) 2016 Tim Rozet (Red Hat) and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -e + +./boot.sh +libtoolize --force +aclocal +autoheader +automake --force-missing --add-missing +autoconf +./configure +make rpm-fedora RPMBUILD_OPT="\"-D kversion `rpm -q kernel | rpmdev-sort | tail -n -1 | sed 's/^kernel-//'`\" --without check" +make rpm-fedora-kmod RPMBUILD_OPT="\"-D kversion `rpm -q kernel | rpmdev-sort | tail -n -1 | sed 's/^kernel-//'`\"" \ No newline at end of file diff --git a/build/rpm_specs/opnfv-apex.spec b/build/rpm_specs/opnfv-apex.spec index 0f6f1f84..de68b5a1 100644 --- a/build/rpm_specs/opnfv-apex.spec +++ b/build/rpm_specs/opnfv-apex.spec @@ -92,6 +92,8 @@ install config/inventory/pod_example_settings.yaml %{buildroot}%{_docdir}/opnfv/ %{_sysconfdir}/opnfv-apex/os-odl-bgpvpn_queens-noha.yaml %{_sysconfdir}/opnfv-apex/os-odl-sfc-ha.yaml %{_sysconfdir}/opnfv-apex/os-odl-sfc-noha.yaml +%{_sysconfdir}/opnfv-apex/os-odl-sfc_queens-ha.yaml +%{_sysconfdir}/opnfv-apex/os-odl-sfc_queens-noha.yaml %{_sysconfdir}/opnfv-apex/os-odl-fdio-noha.yaml %{_sysconfdir}/opnfv-apex/os-odl_netvirt-fdio-noha.yaml %{_sysconfdir}/opnfv-apex/os-odl-fdio-ha.yaml @@ -126,6 +128,8 @@ install config/inventory/pod_example_settings.yaml %{buildroot}%{_docdir}/opnfv/ %doc %{_docdir}/opnfv/inventory.yaml.example %changelog +* Tue Aug 21 2018 Ricardo Noriega - 7.0-6 + Enable SFC scenarios for Gambia * Tue Aug 14 2018 Tim Rozet - 7.0-5 Adds common patches file * Wed Jun 27 2018 Feng Pan - 7.0-4 diff --git a/config/deploy/os-odl-sfc-ha.yaml b/config/deploy/os-odl-sfc-ha.yaml index 3a87bfe3..e8df1170 100644 --- a/config/deploy/os-odl-sfc-ha.yaml +++ b/config/deploy/os-odl-sfc-ha.yaml @@ -3,9 +3,11 @@ global_params: ha_enabled: true deploy_options: + containers: true + os_version: master sdn_controller: opendaylight - odl_version: nitrogen - tacker: true - congress: true + odl_version: master + tacker: false + congress: false sfc: true vpn: false diff --git a/config/deploy/os-odl-sfc-noha.yaml b/config/deploy/os-odl-sfc-noha.yaml index 2b08af6c..3dac36fa 100644 --- a/config/deploy/os-odl-sfc-noha.yaml +++ b/config/deploy/os-odl-sfc-noha.yaml @@ -3,9 +3,11 @@ global_params: ha_enabled: false deploy_options: + containers: true + os_version: master sdn_controller: opendaylight - odl_version: nitrogen - tacker: true - congress: true + odl_version: master + tacker: false + congress: false sfc: true vpn: false diff --git a/config/deploy/os-odl-sfc_queens-ha.yaml b/config/deploy/os-odl-sfc_queens-ha.yaml new file mode 100644 index 00000000..0cd01466 --- /dev/null +++ b/config/deploy/os-odl-sfc_queens-ha.yaml @@ -0,0 +1,13 @@ +--- +global_params: + ha_enabled: true + +deploy_options: + containers: true + os_version: queens + sdn_controller: opendaylight + odl_version: master + tacker: false + congress: false + sfc: true + vpn: false diff --git a/config/deploy/os-odl-sfc_queens-noha.yaml b/config/deploy/os-odl-sfc_queens-noha.yaml new file mode 100644 index 00000000..d091b8cf --- /dev/null +++ b/config/deploy/os-odl-sfc_queens-noha.yaml @@ -0,0 +1,13 @@ +--- +global_params: + ha_enabled: false + +deploy_options: + containers: true + os_version: queens + sdn_controller: opendaylight + odl_version: master + tacker: false + congress: false + sfc: true + vpn: false diff --git a/lib/ansible/playbooks/post_deploy_overcloud.yml b/lib/ansible/playbooks/post_deploy_overcloud.yml index 08460a06..ff9895b0 100644 --- a/lib/ansible/playbooks/post_deploy_overcloud.yml +++ b/lib/ansible/playbooks/post_deploy_overcloud.yml @@ -13,15 +13,6 @@ - dataplane == 'ovs_dpdk' - "'compute' in ansible_hostname" - sdn == false - - name: SFC config workaround - file: - src: /etc/neutron/networking_sfc.conf - dest: /etc/neutron/conf.d/neutron-server/networking_sfc.conf - state: link - become: yes - when: - - sfc - - "'controller' in ansible_hostname" - name: Ensure ZRPCD is running shell: ps aux | grep zrpcd | grep -v grep ignore_errors: yes diff --git a/setup.cfg b/setup.cfg index f19bd035..5b394fb8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,6 +42,7 @@ data_files = build/virtual-environment.yaml build/baremetal-environment.yaml build/domain.xml + build/build_ovs_nsh.sh share/opnfv-apex/ansible = lib/ansible/* share/opnfv-apex/config = config/* share/opnfv-apex/docs = docs/* -- cgit 1.2.3-korg