summaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-08-22 21:31:53 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-08-22 21:31:53 +0000
commit85a3c2e347c1555bf589a7574abd0b651196952f (patch)
tree729fcf5f04b6d0a7fe7e265df344c6a331f8a7ae /apex
parent25dd19618aecf69917720d10e0e9d7ba2925db14 (diff)
parent14de5d725e74cb885a48146217e2fc9d8f093df6 (diff)
Merge "Enable SFC scenarios for Gambia"
Diffstat (limited to 'apex')
-rw-r--r--apex/builders/overcloud_builder.py37
-rw-r--r--apex/common/constants.py5
-rw-r--r--apex/deploy.py3
-rw-r--r--apex/overcloud/deploy.py25
-rw-r--r--apex/tests/test_apex_overcloud_deploy.py30
-rw-r--r--apex/tests/test_apex_undercloud.py3
6 files changed, 77 insertions, 26 deletions
diff --git a/apex/builders/overcloud_builder.py b/apex/builders/overcloud_builder.py
index b855645..a74ec25 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 2ad22ad..e9c99a3 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 8065d5c..9510de9 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 a719dff..fcd7f0f 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 1ba5dd9..71ef80b 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 9bc91e5..5c33bf0 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)