summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-25 10:25:39 +0000
committerGerrit Code Review <review@openstack.org>2016-01-25 10:25:39 +0000
commit7106e622aa6ca884aa45487a85c2697574db0746 (patch)
tree83cc1aa3e9183826f0054f47917e0bae36612e53
parent5692e9b6bd7a898a19b1159bfddb02521b727617 (diff)
parent4188c40bebe1ab50e7b029584ab8a0fee8d5725e (diff)
downloadheat-7106e622aa6ca884aa45487a85c2697574db0746.tar.gz
Merge "Remove warnings in heat"
-rwxr-xr-xbin/heat-api13
-rwxr-xr-xbin/heat-api-cfn13
-rwxr-xr-xbin/heat-api-cloudwatch13
-rwxr-xr-xbin/heat-engine13
-rwxr-xr-xbin/heat-manage11
-rw-r--r--heat/engine/constraints.py9
-rw-r--r--heat/engine/environment.py3
-rw-r--r--heat/engine/rsrc_defn.py15
-rw-r--r--heat/engine/service.py12
-rw-r--r--heat/tests/test_constraints.py17
-rw-r--r--heat/tests/test_rsrc_defn.py16
11 files changed, 67 insertions, 68 deletions
diff --git a/bin/heat-api b/bin/heat-api
index f08228f13..85dafb2bf 100755
--- a/bin/heat-api
+++ b/bin/heat-api
@@ -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
diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn
index 8e6571c68..810f1184d 100755
--- a/bin/heat-api-cfn
+++ b/bin/heat-api-cfn
@@ -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
diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch
index 2cd5dcaf0..01c55ee04 100755
--- a/bin/heat-api-cloudwatch
+++ b/bin/heat-api-cloudwatch
@@ -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
diff --git a/bin/heat-engine b/bin/heat-engine
index 9f1c577c8..f4d9cb0bc 100755
--- a/bin/heat-engine
+++ b/bin/heat-engine
@@ -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
diff --git a/bin/heat-manage b/bin/heat-manage
index 3a7f42f57..ccf970d97 100755
--- a/bin/heat-manage
+++ b/bin/heat-manage
@@ -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
diff --git a/heat/engine/constraints.py b/heat/engine/constraints.py
index f5a61e876..619a52872 100644
--- a/heat/engine/constraints.py
+++ b/heat/engine/constraints.py
@@ -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
diff --git a/heat/engine/environment.py b/heat/engine/environment.py
index 2aed132f4..b3db5e481 100644
--- a/heat/engine/environment.py
+++ b/heat/engine/environment.py
@@ -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)
diff --git a/heat/engine/rsrc_defn.py b/heat/engine/rsrc_defn.py
index 4b6084f87..be5bfa353 100644
--- a/heat/engine/rsrc_defn.py
+++ b/heat/engine/rsrc_defn.py
@@ -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)))
diff --git a/heat/engine/service.py b/heat/engine/service.py
index 5fc02cf57..ede249380 100644
--- a/heat/engine/service.py
+++ b/heat/engine/service.py
@@ -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())
diff --git a/heat/tests/test_constraints.py b/heat/tests/test_constraints.py
index 292b544c7..00280199b 100644
--- a/heat/tests/test_constraints.py
+++ b/heat/tests/test_constraints.py
@@ -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')
diff --git a/heat/tests/test_rsrc_defn.py b/heat/tests/test_rsrc_defn.py
index 140f3e478..5a5573d5d 100644
--- a/heat/tests/test_rsrc_defn.py
+++ b/heat/tests/test_rsrc_defn.py
@@ -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)