diff --git a/heat/engine/resource.py b/heat/engine/resource.py index ceaf5a72a3..621f562d2e 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -13,7 +13,6 @@ import collections import contextlib -import datetime as dt import itertools import pydoc import re @@ -24,6 +23,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import reflection +from oslo_utils import timeutils as oslo_timeutils from heat.common import exception from heat.common.i18n import _ @@ -58,8 +58,6 @@ cfg.CONF.import_opt('error_wait_time', 'heat.common.config') LOG = logging.getLogger(__name__) -datetime = dt.datetime - def _register_class(resource_type, resource_class): resources.global_env().register_class(resource_type, resource_class) @@ -1675,7 +1673,7 @@ class Resource(status.ResourceStatus): LOG.info('updating %s', self) - self.updated_time = datetime.utcnow() + self.updated_time = oslo_timeutils.utcnow() if new_requires is not None: self.requires = self.requires | new_requires diff --git a/heat/tests/aws/test_waitcondition.py b/heat/tests/aws/test_waitcondition.py index 0e31cf172f..faabaa9ed5 100644 --- a/heat/tests/aws/test_waitcondition.py +++ b/heat/tests/aws/test_waitcondition.py @@ -604,7 +604,7 @@ class WaitConditionUpdateTest(common.HeatTestCase): now = timeutils.utcnow() fake_clock = [now + datetime.timedelta(0, t) - for t in (0, 0.001, 0.1, 4.1, 5.1)] + for t in (0, 0, 0.001, 0.1, 4.1, 5.1, 5.1)] timeutils.set_time_override(fake_clock) self.addCleanup(timeutils.clear_time_override) diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index d4e893971e..a73cc4c58b 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -12,7 +12,6 @@ # under the License. import collections -import datetime import itertools import json import os @@ -22,6 +21,7 @@ import uuid import eventlet from oslo_config import cfg +from oslo_utils import timeutils as oslo_timeutils from heat.common import exception from heat.common.i18n import _ @@ -600,7 +600,7 @@ class ResourceTest(common.HeatTestCase): res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack) res.store() self.assertIsNone(res.updated_time) - res.updated_time = datetime.datetime.utcnow() + res.updated_time = oslo_timeutils.utcnow() res.store() self.assertIsNotNone(res.updated_time)