Merge "Check for keystoneauth exceptions in mistral client plugin"
This commit is contained in:
commit
816155a1f3
|
@ -11,6 +11,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from keystoneauth1.exceptions import http as ka_exceptions
|
||||
from mistralclient.api import base as mistral_base
|
||||
from mistralclient.api import client as mistral_client
|
||||
|
||||
|
@ -39,16 +40,28 @@ class MistralClientPlugin(client_plugin.ClientPlugin):
|
|||
return client
|
||||
|
||||
def is_not_found(self, ex):
|
||||
return (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 404)
|
||||
# check for keystoneauth exceptions till requirements change
|
||||
# to python-mistralclient > 3.1.2
|
||||
ka_not_found = isinstance(ex, ka_exceptions.NotFound)
|
||||
mistral_not_found = (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 404)
|
||||
return ka_not_found or mistral_not_found
|
||||
|
||||
def is_over_limit(self, ex):
|
||||
return (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 413)
|
||||
# check for keystoneauth exceptions till requirements change
|
||||
# to python-mistralclient > 3.1.2
|
||||
ka_overlimit = isinstance(ex, ka_exceptions.RequestEntityTooLarge)
|
||||
mistral_overlimit = (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 413)
|
||||
return ka_overlimit or mistral_overlimit
|
||||
|
||||
def is_conflict(self, ex):
|
||||
return (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 409)
|
||||
# check for keystoneauth exceptions till requirements change
|
||||
# to python-mistralclient > 3.1.2
|
||||
ka_conflict = isinstance(ex, ka_exceptions.Conflict)
|
||||
mistral_conflict = (isinstance(ex, mistral_base.APIException) and
|
||||
ex.error_code == 409)
|
||||
return ka_conflict or mistral_conflict
|
||||
|
||||
def get_workflow_by_identifier(self, workflow_identifier):
|
||||
try:
|
||||
|
|
|
@ -20,6 +20,7 @@ from heatclient import exc as heat_exc
|
|||
from keystoneauth1 import exceptions as keystone_exc
|
||||
from keystoneauth1.identity import generic
|
||||
from manilaclient import exceptions as manila_exc
|
||||
from mistralclient.api import base as mistral_base
|
||||
import mock
|
||||
from neutronclient.common import exceptions as neutron_exc
|
||||
from openstack import exceptions
|
||||
|
@ -792,6 +793,22 @@ class TestIsNotFound(common.HeatTestCase):
|
|||
plugin='manila',
|
||||
exception=lambda: manila_exc.Conflict(),
|
||||
)),
|
||||
('mistral_not_found1', dict(
|
||||
is_not_found=True,
|
||||
is_over_limit=False,
|
||||
is_client_exception=False,
|
||||
is_conflict=False,
|
||||
plugin='mistral',
|
||||
exception=lambda: mistral_base.APIException(404),
|
||||
)),
|
||||
('mistral_not_found2', dict(
|
||||
is_not_found=True,
|
||||
is_over_limit=False,
|
||||
is_client_exception=False,
|
||||
is_conflict=False,
|
||||
plugin='mistral',
|
||||
exception=lambda: keystone_exc.NotFound(),
|
||||
)),
|
||||
]
|
||||
|
||||
def test_is_not_found(self):
|
||||
|
|
Loading…
Reference in New Issue