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. An OpenStack REST API to Heat.
""" """
import warnings from oslo_log import log as logging
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start " from heat.common.i18n import _LW
"any of the heat services.", DeprecationWarning)
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 os
import sys 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. AMQP RPC to implement them.
""" """
import warnings from oslo_log import log as logging
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start " from heat.common.i18n import _LW
"any of the heat services.", DeprecationWarning)
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 os
import sys import sys

View File

@ -20,10 +20,15 @@ into a native representation. It then calls the heat-engine via AMQP RPC to
implement them. implement them.
""" """
import warnings from oslo_log import log as logging
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start " from heat.common.i18n import _LW
"any of the heat services.", DeprecationWarning)
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 os
import sys import sys

View File

@ -20,10 +20,15 @@ Normal communications is done via the heat API which then calls into this
engine. engine.
""" """
import warnings from oslo_log import log as logging
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat binaries installed to start " from heat.common.i18n import _LW
"any of the heat services.", DeprecationWarning)
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 os
import sys import sys

View File

@ -13,9 +13,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import warnings from oslo_log import log as logging
warnings.warn("DEPRECATED: This script is deprecated. Please use the "
"system level heat-manage binary", DeprecationWarning) 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 os
import sys import sys

View File

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

View File

@ -17,7 +17,6 @@ import glob
import itertools import itertools
import os.path import os.path
import re import re
import warnings
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
@ -302,7 +301,7 @@ class ResourceRegistry(object):
if isinstance(info, ClassResourceInfo): if isinstance(info, ClassResourceInfo):
if info.value.support_status.status != support.SUPPORTED: if info.value.support_status.status != support.SUPPORTED:
if info.value.support_status.message is not None: 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.value.support_status.message))
info.user_resource = (self.global_registry is not None) info.user_resource = (self.global_registry is not None)

View File

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

View File

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

View File

@ -12,7 +12,6 @@
# under the License. # under the License.
import six import six
import warnings
from heat.common import exception from heat.common import exception
from heat.engine.cfn import functions as cfn_funcs from heat.engine.cfn import functions as cfn_funcs
@ -212,17 +211,8 @@ class ResourceDefinitionSnippetTest(common.HeatTestCase):
def test_resource_snippet(self): def test_resource_snippet(self):
rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType', **self.defn) 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 exp_result = {'Type': 'SomeType'}
getattr(rsrc_defn, '__warningregistry__', {}).clear() exp_result.update(self.expected)
exp_result = {'Type': 'SomeType'} self.assertEqual(exp_result, rd)
exp_result.update(self.expected)
self.assertEqual(exp_result, rd)
self.assertTrue(ws)
for warn in ws:
self.assertTrue(issubclass(warn.category, DeprecationWarning))