Merge "Use oslo.utils.reflection to extract class name"
This commit is contained in:
commit
9345e1648f
@ -14,6 +14,7 @@
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
@ -103,8 +104,9 @@ class CloudNetworkTest(common.HeatTestCase):
|
||||
cloudnetworks.CloudNetwork)
|
||||
|
||||
def _parse_stack(self):
|
||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
self.stack = utils.parse_stack(self._template,
|
||||
stack_name=self.__class__.__name__)
|
||||
stack_name=class_name)
|
||||
|
||||
def _setup_stack(self, mock_client, *args):
|
||||
self.fake_cnw = FakeClient(*args)
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
"""Heat API exception subclasses - maps API response errors to AWS Errors."""
|
||||
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
@ -317,7 +318,7 @@ def map_remote_error(ex):
|
||||
invalid_action_errors = ('ActionInProgress',)
|
||||
request_limit_exceeded = ('RequestLimitExceeded')
|
||||
|
||||
ex_type = ex.__class__.__name__
|
||||
ex_type = reflection.get_class_name(ex, fully_qualified=False)
|
||||
|
||||
if ex_type.endswith('_Remote'):
|
||||
ex_type = ex_type[:-len('_Remote')]
|
||||
|
@ -18,12 +18,13 @@
|
||||
|
||||
Inspired by Cinder's faultwrapper.
|
||||
"""
|
||||
import six
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
import webob
|
||||
|
||||
from heat.common import exception
|
||||
@ -116,7 +117,7 @@ class FaultWrapper(wsgi.Middleware):
|
||||
ex = ex.exc
|
||||
webob_exc = ex
|
||||
|
||||
ex_type = ex.__class__.__name__
|
||||
ex_type = reflection.get_class_name(ex, fully_qualified=False)
|
||||
|
||||
is_remote = ex_type.endswith('_Remote')
|
||||
if is_remote:
|
||||
|
@ -18,6 +18,7 @@ import re
|
||||
from oslo_cache import core
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import reflection
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
@ -616,8 +617,8 @@ class BaseCustomConstraint(object):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
cache_value_prefix = "{0}:{1}".format(self.__class__.__name__,
|
||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
cache_value_prefix = "{0}:{1}".format(class_name,
|
||||
six.text_type(context.tenant_id))
|
||||
validation_result = check_cache_or_validate_value(
|
||||
cache_value_prefix, value)
|
||||
|
@ -19,6 +19,7 @@ import weakref
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
@ -543,16 +544,17 @@ class Resource(object):
|
||||
return dict((k, after_props.get(k)) for k in changed_properties_set)
|
||||
|
||||
def __str__(self):
|
||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
if self.stack.id:
|
||||
if self.resource_id:
|
||||
text = '%s "%s" [%s] %s' % (self.__class__.__name__, self.name,
|
||||
text = '%s "%s" [%s] %s' % (class_name, self.name,
|
||||
self.resource_id,
|
||||
six.text_type(self.stack))
|
||||
else:
|
||||
text = '%s "%s" %s' % (self.__class__.__name__, self.name,
|
||||
text = '%s "%s" %s' % (class_name, self.name,
|
||||
six.text_type(self.stack))
|
||||
else:
|
||||
text = '%s "%s"' % (self.__class__.__name__, self.name)
|
||||
text = '%s "%s"' % (class_name, self.name)
|
||||
return six.text_type(text)
|
||||
|
||||
def dep_attrs(self, resource_name):
|
||||
|
@ -16,6 +16,7 @@ import json
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
@ -174,8 +175,8 @@ class StackResource(resource.Resource):
|
||||
child_template = self.child_template()
|
||||
params = self.child_params()
|
||||
except NotImplementedError:
|
||||
LOG.warning(_LW("Preview of '%s' not yet implemented"),
|
||||
self.__class__.__name__)
|
||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
LOG.warning(_LW("Preview of '%s' not yet implemented"), class_name)
|
||||
return self
|
||||
|
||||
name = "%s-%s" % (self.stack.name, self.name)
|
||||
@ -324,7 +325,8 @@ class StackResource(resource.Resource):
|
||||
# finish
|
||||
return
|
||||
|
||||
if not ex.__class__.__name__.endswith('_Remote'):
|
||||
class_name = reflection.get_class_name(ex, fully_qualified=False)
|
||||
if not class_name.endswith('_Remote'):
|
||||
raise ex
|
||||
|
||||
full_message = six.text_type(ex)
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
"""Client side of the heat engine RPC API."""
|
||||
|
||||
from oslo_utils import reflection
|
||||
|
||||
from heat.common import messaging
|
||||
from heat.rpc import api as rpc_api
|
||||
|
||||
@ -79,7 +81,7 @@ class EngineClient(object):
|
||||
|
||||
:param error: Remote raised error to derive the name from.
|
||||
"""
|
||||
error_name = error.__class__.__name__
|
||||
error_name = reflection.get_class_name(error, fully_qualified=False)
|
||||
return error_name.split('_Remote')[0]
|
||||
|
||||
def ignore_error_named(self, error, name):
|
||||
|
@ -11,6 +11,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import reflection
|
||||
|
||||
import heat.api.openstack.v1 as api_v1
|
||||
from heat.tests import common
|
||||
|
||||
@ -23,8 +25,9 @@ class RoutesTest(common.HeatTestCase):
|
||||
route = mapper.match(path, {'REQUEST_METHOD': method})
|
||||
self.assertIsNotNone(route)
|
||||
self.assertEqual(action, route['action'])
|
||||
self.assertEqual(
|
||||
controller, route['controller'].controller.__class__.__name__)
|
||||
class_name = reflection.get_class_name(route['controller'].controller,
|
||||
fully_qualified=False)
|
||||
self.assertEqual(controller, class_name)
|
||||
del(route['action'])
|
||||
del(route['controller'])
|
||||
self.assertEqual(params, route)
|
||||
|
@ -22,6 +22,7 @@ import copy
|
||||
import mock
|
||||
from mox import stubout
|
||||
from oslo_messaging._drivers import common as rpc_common
|
||||
from oslo_utils import reflection
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import identifier
|
||||
@ -53,7 +54,8 @@ class EngineRpcAPITestCase(common.HeatTestCase):
|
||||
self.assertEqual('NotFound', self.rpcapi.local_error_name(ex))
|
||||
|
||||
exr = self._to_remote_error(ex)
|
||||
self.assertEqual('NotFound_Remote', exr.__class__.__name__)
|
||||
self.assertEqual('NotFound_Remote',
|
||||
reflection.get_class_name(exr, fully_qualified=False))
|
||||
self.assertEqual('NotFound', self.rpcapi.local_error_name(exr))
|
||||
|
||||
def test_ignore_error_named(self):
|
||||
|
@ -10,6 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import reflection
|
||||
|
||||
from heat_integrationtests.common import test
|
||||
|
||||
|
||||
@ -21,7 +23,7 @@ class FunctionalTestsBase(test.HeatIntegrationTest):
|
||||
self.client = self.orchestration_client
|
||||
|
||||
def check_skip(self):
|
||||
test_cls_name = self.__class__.__name__
|
||||
test_cls_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
test_method_name = '.'.join([test_cls_name, self._testMethodName])
|
||||
test_skipped = (self.conf.skip_functional_test_list and (
|
||||
test_cls_name in self.conf.skip_functional_test_list or
|
||||
|
@ -10,6 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import reflection
|
||||
|
||||
from heat_integrationtests.common import test
|
||||
|
||||
|
||||
@ -59,7 +61,7 @@ class ScenarioTestsBase(test.HeatIntegrationTest):
|
||||
return stack_id
|
||||
|
||||
def check_skip(self):
|
||||
test_cls_name = self.__class__.__name__
|
||||
test_cls_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
test_method_name = '.'.join([test_cls_name, self._testMethodName])
|
||||
test_skipped = (self.conf.skip_scenario_test_list and (
|
||||
test_cls_name in self.conf.skip_scenario_test_list or
|
||||
|
Loading…
Reference in New Issue
Block a user