Merge "Remove warnings in heat"

This commit is contained in:
Jenkins 2016-01-25 10:25:39 +00:00 committed by Gerrit Code Review
commit 7106e622aa
11 changed files with 67 additions and 68 deletions

View File

@ -18,10 +18,15 @@
An OpenStack REST API to Heat.
"""
import warnings
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start "
"any of the heat services.", DeprecationWarning)
from oslo_log import log as logging
from heat.common.i18n import _LW
LOG = logging.getLogger(__name__)
LOG.warning(_LW('DEPRECATED: `heat-api` script is deprecated. Please use the '
'system level heat binaries installed to start '
'any of the heat services.'))
import os
import sys

View File

@ -20,10 +20,15 @@ translates it into a native representation. It then calls the heat-engine via
AMQP RPC to implement them.
"""
import warnings
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start "
"any of the heat services.", DeprecationWarning)
from oslo_log import log as logging
from heat.common.i18n import _LW
LOG = logging.getLogger(__name__)
LOG.warning(_LW('DEPRECATED: `heat-api-cfn` script is deprecated. Please use '
'the system level heat binaries installed to start '
'any of the heat services.'))
import os
import sys

View File

@ -20,10 +20,15 @@ into a native representation. It then calls the heat-engine via AMQP RPC to
implement them.
"""
import warnings
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start "
"any of the heat services.", DeprecationWarning)
from oslo_log import log as logging
from heat.common.i18n import _LW
LOG = logging.getLogger(__name__)
LOG.warning(_LW('DEPRECATED: `heat-api-cloudwatch` script is deprecated. '
'Please use the system level heat binaries installed to '
'start any of the heat services.'))
import os
import sys

View File

@ -20,10 +20,15 @@ Normal communications is done via the heat API which then calls into this
engine.
"""
import warnings
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start "
"any of the heat services.", DeprecationWarning)
from oslo_log import log as logging
from heat.common.i18n import _LW
LOG = logging.getLogger(__name__)
LOG.warning(_LW('DEPRECATED: `heat-engine` script is deprecated. '
'Please use the system level heat binaries installed to '
'start any of the heat services.'))
import os
import sys

View File

@ -13,9 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import warnings
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat-manage binary", DeprecationWarning)
from oslo_log import log as logging
from heat.common.i18n import _LW
LOG = logging.getLogger(__name__)
LOG.warning(_LW('DEPRECATED: `heat-manage` script is deprecated. Please use '
'the system level heat-manage binary.'))
import os
import sys

View File

@ -14,16 +14,17 @@
import collections
import numbers
import re
import warnings
from oslo_cache import core
from oslo_config import cfg
from oslo_log import log
from oslo_utils import strutils
import six
from heat.common import cache
from heat.common import exception
from heat.common.i18n import _
from heat.common.i18n import _LW
from heat.engine import resources
# decorator that allows to cache the value
@ -32,6 +33,8 @@ MEMOIZE = core.get_memoization_decorator(conf=cfg.CONF,
region=cache.get_cache_region(),
group="constraint_validation_cache")
LOG = log.getLogger(__name__)
class Schema(collections.Mapping):
"""Schema base class for validating properties or parameters.
@ -94,8 +97,8 @@ class Schema(collections.Mapping):
message=_('Invalid type (%s)') % self.type)
if required and default is not None:
warnings.warn("Option 'required=True' should not be used with "
"any 'default' value ({0})".format(default))
LOG.warning(_LW("Option 'required=True' should not be used with "
"any 'default' value (%s)") % default)
self.description = description
self.required = required

View File

@ -17,7 +17,6 @@ import glob
import itertools
import os.path
import re
import warnings
from oslo_config import cfg
from oslo_log import log
@ -302,7 +301,7 @@ class ResourceRegistry(object):
if isinstance(info, ClassResourceInfo):
if info.value.support_status.status != support.SUPPORTED:
if info.value.support_status.message is not None:
warnings.warn(six.text_type(
LOG.warning(_LW("%s"), six.text_type(
info.value.support_status.message))
info.user_resource = (self.global_registry is not None)

View File

@ -14,14 +14,15 @@ import collections
import copy
import itertools
import operator
import warnings
from oslo_log import log
import six
from heat.common import exception
from heat.common.i18n import _LW
from heat.engine import function
from heat.engine import properties
LOG = log.getLogger(__name__)
__all__ = ['ResourceDefinition']
@ -292,7 +293,7 @@ class ResourceDefinition(ResourceDefinitionCore, collections.Mapping):
ResourceDefinitionCore as soon as M release.
"""
_deprecation_msg = (
_deprecation_msg = _LW(
'Reading the ResourceDefinition as if it were a snippet of a '
'CloudFormation template is deprecated, and the ability to treat it '
'as such will be removed in the future. Resource plugins should use '
@ -325,7 +326,7 @@ class ResourceDefinition(ResourceDefinitionCore, collections.Mapping):
This is for backwards compatibility with existing code that expects a
parsed-JSON template snippet.
"""
warnings.warn(self._deprecation_msg, DeprecationWarning)
LOG.warning(self._deprecation_msg)
yield TYPE
if self._properties is not None:
@ -347,7 +348,7 @@ class ResourceDefinition(ResourceDefinitionCore, collections.Mapping):
This is for backwards compatibility with existing code that expects a
parsed-JSON template snippet.
"""
warnings.warn(self._deprecation_msg, DeprecationWarning)
LOG.warning(self._deprecation_msg)
if key == TYPE:
return self.resource_type
@ -376,7 +377,7 @@ class ResourceDefinition(ResourceDefinitionCore, collections.Mapping):
def __hash__(self):
"""Return a hash of the ResourceDefinition object."""
warnings.warn(self._deprecation_msg, DeprecationWarning)
LOG.warning(self._deprecation_msg)
return super(ResourceDefinition, self).__hash__()
def __len__(self):
@ -385,7 +386,7 @@ class ResourceDefinition(ResourceDefinitionCore, collections.Mapping):
This is for backwards compatibility with existing code that expects a
parsed-JSON template snippet.
"""
warnings.warn(self._deprecation_msg, DeprecationWarning)
LOG.warning(self._deprecation_msg)
return len(list(iter(self)))

View File

@ -16,7 +16,6 @@ import datetime
import itertools
import os
import socket
import warnings
import eventlet
from oslo_config import cfg
@ -318,12 +317,11 @@ class EngineService(service.Service):
self.resource_enforcer = policy.ResourceEnforcer()
if cfg.CONF.trusts_delegated_roles:
warnings.warn('The default value of "trusts_delegated_roles" '
'option in heat.conf is changed to [] in Kilo '
'and heat will delegate all roles of trustor. '
'Please keep the same if you do not want to '
'delegate subset roles when upgrading.',
Warning)
LOG.warning(_LW('The default value of "trusts_delegated_roles" '
'option in heat.conf is changed to [] in Kilo '
'and heat will delegate all roles of trustor. '
'Please keep the same if you do not want to '
'delegate subset roles when upgrading.'))
def create_periodic_tasks(self):
LOG.debug("Starting periodic watch tasks pid=%s" % os.getpid())

View File

@ -20,23 +20,6 @@ from heat.tests import common
class SchemaTest(common.HeatTestCase):
def test_warn_required_with_default(self):
msg = ("Option 'required=True' should not be used with any 'default' "
"value \(wibble\)")
with self.assertWarnsRegex(UserWarning, msg):
constraints.Schema(constraints.Schema.STRING, 'A string',
default='wibble', required=True)
def test_without_warn_only_default(self):
constraints.Schema(constraints.Schema.STRING, 'A string',
default='wibble')
self.assertEqual(0, len(self.warnings.captures))
def test_without_warn_only_required(self):
constraints.Schema(constraints.Schema.STRING, 'A string',
required=True)
self.assertEqual(0, len(self.warnings.captures))
def test_range_schema(self):
d = {'range': {'min': 5, 'max': 10}, 'description': 'a range'}
r = constraints.Range(5, 10, description='a range')

View File

@ -12,7 +12,6 @@
# under the License.
import six
import warnings
from heat.common import exception
from heat.engine.cfn import functions as cfn_funcs
@ -212,17 +211,8 @@ class ResourceDefinitionSnippetTest(common.HeatTestCase):
def test_resource_snippet(self):
rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType', **self.defn)
with warnings.catch_warnings(record=True) as ws:
warnings.filterwarnings('always')
# Work around http://bugs.python.org/issue4180
getattr(rsrc_defn, '__warningregistry__', {}).clear()
exp_result = {'Type': 'SomeType'}
exp_result.update(self.expected)
exp_result = {'Type': 'SomeType'}
exp_result.update(self.expected)
self.assertEqual(exp_result, rd)
self.assertTrue(ws)
for warn in ws:
self.assertTrue(issubclass(warn.category, DeprecationWarning))
self.assertEqual(exp_result, rd)