From b1dc704d104201c3a2f5c031d449e2acfd20a107 Mon Sep 17 00:00:00 2001 From: Janki Chhatbar Date: Mon, 28 Aug 2017 14:34:24 +0530 Subject: [PATCH] Add ODL container images to TripleO-common. This patch implements a logic to render images based on the neutron-driver specified. ODL image rendering is under if-else logic because ODL is not enabled by default in overcloud and in case when no env file are specified, ODL image will be pulled by prepare command Change-Id: Ia44fca9b5075de622f8390f329050a20b5bddc7a Partial-Bug: #1713685 Depends-On: I3e395986ad777b1d6b057bb33fac8d5ed2d3d26a --- container-images/overcloud_containers.yaml | 2 + container-images/overcloud_containers.yaml.j2 | 24 ++++++++++++ .../tests/image/test_kolla_builder.py | 37 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/container-images/overcloud_containers.yaml b/container-images/overcloud_containers.yaml index eae2294a6..becdded05 100644 --- a/container-images/overcloud_containers.yaml +++ b/container-images/overcloud_containers.yaml @@ -52,6 +52,7 @@ container_images: - imagename: tripleoupstream/centos-binary-neutron-openvswitch-agent:latest - imagename: tripleoupstream/centos-binary-neutron-sriov-agent:latest - imagename: tripleoupstream/centos-binary-neutron-server:latest +- imagename: tripleoupstream/centos-binary-neutron-server-opendaylight:latest - imagename: tripleoupstream/centos-binary-neutron-server-ovn:latest - imagename: tripleoupstream/centos-binary-nova-api:latest - imagename: tripleoupstream/centos-binary-nova-compute-ironic:latest @@ -67,6 +68,7 @@ container_images: - imagename: tripleoupstream/centos-binary-octavia-health-manager:latest - imagename: tripleoupstream/centos-binary-octavia-housekeeping:latest - imagename: tripleoupstream/centos-binary-octavia-worker:latest +- imagename: tripleoupstream/centos-binary-opendaylight:latest - imagename: tripleoupstream/centos-binary-ovn-base:latest - imagename: tripleoupstream/centos-binary-ovn-controller:latest - imagename: tripleoupstream/centos-binary-ovn-nb-db-server:latest diff --git a/container-images/overcloud_containers.yaml.j2 b/container-images/overcloud_containers.yaml.j2 index 29bdc65ec..e750c81da 100644 --- a/container-images/overcloud_containers.yaml.j2 +++ b/container-images/overcloud_containers.yaml.j2 @@ -17,6 +17,7 @@ {% endif %} {% set tag=tag or "latest" %} +{% set neutron_driver=neutron_driver or "None" %} container_images_template: - imagename: "{{namespace}}/{{name_prefix}}aodh-api{{name_suffix}}:{{tag}}" @@ -388,6 +389,19 @@ container_images_template: services: - OS::TripleO::Services::NeutronSriovAgent +{% if neutron_driver == "odl" %} +- imagename: "{{namespace}}/{{name_prefix}}neutron-server-opendaylight{{name_suffix}}:{{tag}}" + params: + - DockerNeutronApiImage + - DockerNeutronConfigImage + services: + - OS::TripleO::Services::NeutronApi + - OS::TripleO::Services::NeutronDhcpAgent + - OS::TripleO::Services::NeutronMetadataAgent + - OS::TripleO::Services::NeutronServer + - OS::TripleO::Services::OpenDaylightApi + +{% else %} - imagename: "{{namespace}}/{{name_prefix}}neutron-server{{name_suffix}}:{{tag}}" params: - DockerNeutronApiImage @@ -402,6 +416,7 @@ container_images_template: - OS::TripleO::Services::NeutronOvsAgent - OS::TripleO::Services::NeutronServer - OS::TripleO::Services::NeutronSriovAgent +{% endif %} - imagename: "{{namespace}}/{{name_prefix}}neutron-server-ovn{{name_suffix}}:{{tag}}" params: @@ -504,6 +519,15 @@ container_images_template: services: - OS::TripleO::Services::OctaviaWorker +{% if neutron_driver == "odl" %} +- imagename: "{{namespace}}/{{name_prefix}}opendaylight{{name_suffix}}:{{tag}}" + params: + - DockerOpendaylightApiImage + - DockerOpendaylightConfigImage + services: + - OS::TripleO::Services::OpenDaylightApi +{% endif %} + - imagename: "{{namespace}}/{{name_prefix}}ovn-base{{name_suffix}}:{{tag}}" - imagename: "{{namespace}}/{{name_prefix}}ovn-controller{{name_suffix}}:{{tag}}" diff --git a/tripleo_common/tests/image/test_kolla_builder.py b/tripleo_common/tests/image/test_kolla_builder.py index 2d7a3efe0..78935fd39 100644 --- a/tripleo_common/tests/image/test_kolla_builder.py +++ b/tripleo_common/tests/image/test_kolla_builder.py @@ -216,4 +216,41 @@ class TestKollaImageBuilderTemplate(base.TestCase): yaml_builder = kb.KollaImageBuilder([oc_yaml_file]) container_images = yaml_builder.load_config_files( yaml_builder.CONTAINER_IMAGES) + # remove odl related image references from overcloud_containers.yaml + container_images.remove({'imagename': 'tripleoupstream/centos-binary' + '-neutron-server-opendaylight:' + 'latest'}) + container_images.remove({'imagename': 'tripleoupstream/centos-binary' + '-opendaylight:latest'}) + self.assertSequenceEqual(container_images, result) + + def test_container_images_yaml_in_sync_for_odl(self): + '''Confirm overcloud_containers.tpl.yaml equals overcloud_containers.yaml + + TODO(sbaker) remove when overcloud_containers.yaml is deleted + ''' + mod_dir = os.path.dirname(sys.modules[__name__].__file__) + project_dir = os.path.abspath(os.path.join(mod_dir, '../../../')) + files_dir = os.path.join(project_dir, 'container-images') + + oc_tmpl_file = os.path.join(files_dir, 'overcloud_containers.yaml.j2') + tmpl_builder = kb.KollaImageBuilder([oc_tmpl_file]) + + def ffunc(entry): + if 'params' in entry: + del(entry['params']) + if 'services' in entry: + del(entry['services']) + return entry + + result = tmpl_builder.container_images_from_template( + neutron_driver='odl', filter=ffunc) + + oc_yaml_file = os.path.join(files_dir, 'overcloud_containers.yaml') + yaml_builder = kb.KollaImageBuilder([oc_yaml_file]) + container_images = yaml_builder.load_config_files( + yaml_builder.CONTAINER_IMAGES) + # remove neutron-server image reference from overcloud_containers.yaml + container_images.remove({'imagename': 'tripleoupstream/centos-binary' + '-neutron-server:latest'}) self.assertSequenceEqual(container_images, result)