Move the install base type check to kolla-build

The install type is converted in kolla-build, so it will never
fail in dockerfile, move the check to kolla-build just above
the install type converting.

TrivialFix

Co-Authored-By: Jeffrey Zhang <jeffrey.zhang@99cloud.net>
Change-Id: I1500d3b47e909f94ea9f68c5245297733f63a70b
This commit is contained in:
Allen Gao 2016-02-01 20:08:57 +08:00 committed by Jeffrey Zhang
parent 1057dcd50a
commit db53ad1ddf
3 changed files with 41 additions and 22 deletions

View File

@ -3,28 +3,6 @@ MAINTAINER {{ maintainer }}
LABEL kolla_version="{{ kolla_version }}" LABEL kolla_version="{{ kolla_version }}"
{# Early failure for bases and types #}
{% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
{% if install_type not in ['source', 'binary', 'rdo', 'rhel'] %}
RUN echo 'ERROR: {{ install_type }} is unavailable for {{ base_distro }}' \
&& /bin/false
{% endif %}
{% elif base_distro in ['ubuntu', 'debian'] %}
{% if install_type not in ['source','binary'] %}
RUN echo 'ERROR: {{ install_type }} is unavailable for {{ base_distro }}' \
&& /bin/false
{% endif %}
{% else %}
RUN echo 'ERROR: The specified distro has no Kolla images to build: "{{ base_distro }}"' \
&& /bin/false
{% endif %}
{{ include_header }} {{ include_header }}

View File

@ -64,6 +64,10 @@ class KollaUnknownBuildTypeException(Exception):
pass pass
class KollaMismatchBaseTypeException(Exception):
pass
class KollaRpmSetupUnknownConfig(Exception): class KollaRpmSetupUnknownConfig(Exception):
pass pass
@ -322,6 +326,17 @@ class KollaWorker(object):
rpm_setup_config = filter(None, conf.rpm_setup_config) rpm_setup_config = filter(None, conf.rpm_setup_config)
self.rpm_setup = self.build_rpm_setup(rpm_setup_config) self.rpm_setup = self.build_rpm_setup(rpm_setup_config)
rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel']
rh_type = ['source', 'binary', 'rdo', 'rhos']
deb_base = ['ubuntu', 'debian']
deb_type = ['source', 'binary']
if not ((self.base in rh_base and self.install_type in rh_type) or
(self.base in deb_base and self.install_type in deb_type)):
raise KollaMismatchBaseTypeException(
'{} is unavailable for {}'.format(self.install_type, self.base)
)
if self.install_type == 'binary': if self.install_type == 'binary':
self.install_metatype = 'rdo' self.install_metatype = 'rdo'
elif self.install_type == 'source': elif self.install_type == 'source':

View File

@ -11,6 +11,7 @@
# limitations under the License. # limitations under the License.
import fixtures import fixtures
import itertools
import mock import mock
import os import os
@ -102,3 +103,28 @@ class WorkerThreadTest(base.TestCase):
path=FAKE_IMAGE['path'], tag=FAKE_IMAGE['fullname'], path=FAKE_IMAGE['path'], tag=FAKE_IMAGE['fullname'],
nocache=False, rm=True, pull=True, forcerm=True, nocache=False, rm=True, pull=True, forcerm=True,
buildargs=build_args) buildargs=build_args)
class KollaWorkerTest(base.TestCase):
def test_supported_base_type(self):
rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel']
rh_type = ['source', 'binary', 'rdo', 'rhos']
deb_base = ['ubuntu', 'debian']
deb_type = ['source', 'binary']
for base_distro, install_type in itertools.chain(
itertools.product(rh_base, rh_type),
itertools.product(deb_base, deb_type)):
self.conf.set_override('base', base_distro)
self.conf.set_override('install_type', install_type)
# should no exception raised
build.KollaWorker(self.conf)
def test_unsupported_base_type(self):
for base_distro, install_type in itertools.product(
['ubuntu', 'debian'], ['rdo', 'rhos']):
self.conf.set_override('base', base_distro)
self.conf.set_override('install_type', install_type)
self.assertRaises(build.KollaMismatchBaseTypeException,
build.KollaWorker, self.conf)