diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-11-16 10:30:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-11-16 10:30:11 +0000 |
| commit | 7b3feb612ba979d585e423ca824bfd0c2222e2a5 (patch) | |
| tree | 146f361e4fb2c7e1d526b0684676c21f30fc2834 | |
| parent | e284d4fbeac8b54c6b69d047167a375605f3eb83 (diff) | |
| parent | f6a525ed85fa31d05c1450e936a2dd3d20a77be6 (diff) | |
| download | kolla-7b3feb612ba979d585e423ca824bfd0c2222e2a5.tar.gz kolla-7b3feb612ba979d585e423ca824bfd0c2222e2a5.zip | |
Merge "Extract kolla exceptions into a single exception.py file"
| -rw-r--r-- | kolla/exception.py | 29 | ||||
| -rw-r--r-- | kolla/image/build.py | 27 | ||||
| -rw-r--r-- | kolla/tests/test_build.py | 3 |
3 files changed, 37 insertions, 22 deletions
diff --git a/kolla/exception.py b/kolla/exception.py new file mode 100644 index 000000000..a495ba844 --- /dev/null +++ b/kolla/exception.py @@ -0,0 +1,29 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Kolla exception subclasses""" + + +class KollaDirNotFoundException(Exception): + pass + + +class KollaUnknownBuildTypeException(Exception): + pass + + +class KollaMismatchBaseTypeException(Exception): + pass + + +class KollaRpmSetupUnknownConfig(Exception): + pass diff --git a/kolla/image/build.py b/kolla/image/build.py index 4c4c9f643..55ff7a11e 100644 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -47,6 +47,7 @@ if PROJECT_ROOT not in sys.path: from kolla.common import config as common_config from kolla.common import task +from kolla import exception from kolla.template import filters as jinja_filters from kolla.template import methods as jinja_methods from kolla import version @@ -75,23 +76,6 @@ def make_a_logger(conf=None, image_name=None): LOG = make_a_logger() - -class KollaDirNotFoundException(Exception): - pass - - -class KollaUnknownBuildTypeException(Exception): - pass - - -class KollaMismatchBaseTypeException(Exception): - pass - - -class KollaRpmSetupUnknownConfig(Exception): - pass - - # Image status constants. # # TODO(harlowja): use enum lib in the future?? @@ -521,7 +505,7 @@ class KollaWorker(object): 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( + raise exception.KollaMismatchBaseTypeException( '{} is unavailable for {}'.format(self.install_type, self.base) ) @@ -536,7 +520,7 @@ class KollaWorker(object): self.install_type = 'binary' self.install_metatype = 'rhos' else: - raise KollaUnknownBuildTypeException( + raise exception.KollaUnknownBuildTypeException( 'Unknown install type' ) @@ -565,7 +549,8 @@ class KollaWorker(object): LOG.info('Found the docker image folder at %s', image_path) return image_path else: - raise KollaDirNotFoundException('Image dir can not be found') + raise exception.KollaDirNotFoundException('Image dir can not ' + 'be found') def build_rpm_setup(self, rpm_setup_config): """Generates a list of docker commands based on provided configuration. @@ -589,7 +574,7 @@ class KollaWorker(object): # Copy .repo file from filesystem cmd = "COPY {} /etc/yum.repos.d/".format(config) else: - raise KollaRpmSetupUnknownConfig( + raise exception.KollaRpmSetupUnknownConfig( 'RPM setup must be provided as .rpm or .repo files.' ' Attempted configuration was {}'.format(config) ) diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index 980413468..62e107972 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -17,6 +17,7 @@ import os import requests from kolla.cmd import build as build_cmd +from kolla import exception from kolla.image import build from kolla.tests import base @@ -170,7 +171,7 @@ class KollaWorkerTest(base.TestCase): ['ubuntu', 'debian'], ['rdo', 'rhos']): self.conf.set_override('base', base_distro) self.conf.set_override('install_type', install_type) - self.assertRaises(build.KollaMismatchBaseTypeException, + self.assertRaises(exception.KollaMismatchBaseTypeException, build.KollaWorker, self.conf) def test_build_image_list_adds_plugins(self): |
