From 7f07e9788e84326d145620ae62f45c00b67c009a Mon Sep 17 00:00:00 2001 From: Dmitriy Uvarenkov Date: Fri, 15 Apr 2016 13:09:15 +0300 Subject: [PATCH] Fix stack deleting problem in magnum stacks In magnumclient/exceptions.py exceptions are imported from magnumclient.common.apiclient so exception class is not the same as expected in heat/engine/clients/os/magnum.py Closes-Bug: #1570781 Change-Id: Ie60a735470b9adc38675b613950e6480e28136ab --- heat/engine/clients/os/magnum.py | 7 ++++++- heat/tests/openstack/magnum/test_bay.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/heat/engine/clients/os/magnum.py b/heat/engine/clients/os/magnum.py index a6fb01e029..e632cd4af6 100644 --- a/heat/engine/clients/os/magnum.py +++ b/heat/engine/clients/os/magnum.py @@ -11,13 +11,18 @@ # License for the specific language governing permissions and limitations # under the License. -from magnumclient.openstack.common.apiclient import exceptions as mc_exc from magnumclient.v1 import client as magnum_client from heat.common import exception from heat.engine.clients import client_plugin from heat.engine import constraints +try: + from magnumclient.common.apiclient import exceptions as mc_exc +except ImportError: + # NOTE (duvarenkov): For magnumclient versions before 2.0.0. + from magnumclient.openstack.common.apiclient import exceptions as mc_exc + CLIENT_NAME = 'magnum' diff --git a/heat/tests/openstack/magnum/test_bay.py b/heat/tests/openstack/magnum/test_bay.py index cf3ecfe1a3..5a90d618c0 100644 --- a/heat/tests/openstack/magnum/test_bay.py +++ b/heat/tests/openstack/magnum/test_bay.py @@ -16,8 +16,6 @@ import mock from oslo_config import cfg import six -from magnumclient.openstack.common.apiclient import exceptions as mc_exc - from heat.common import exception from heat.common import template_format from heat.engine.clients.os import magnum as mc @@ -28,6 +26,12 @@ from heat.engine import template from heat.tests import common from heat.tests import utils +try: + from magnumclient.common.apiclient import exceptions as mc_exc +except ImportError: + # NOTE (duvarenkov): For magnumclient versions before 2.0.0. + from magnumclient.openstack.common.apiclient import exceptions as mc_exc + magnum_template = ''' heat_template_version: 2015-04-30