diff --git a/manila/api/views/limits.py b/manila/api/views/limits.py index 6b9995acb2..d589b8989d 100644 --- a/manila/api/views/limits.py +++ b/manila/api/views/limits.py @@ -102,8 +102,9 @@ class ViewBuilder(common.ViewBuilder): return limits def _build_rate_limit(self, rate_limit): - _get_utc = datetime.datetime.utcfromtimestamp - next_avail = _get_utc(rate_limit["resetTime"]) + next_avail = datetime.datetime.fromtimestamp( + rate_limit["resetTime"], + tz=datetime.timezone.utc).replace(tzinfo=None) return { "verb": rate_limit["verb"], "value": rate_limit["value"], diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py index dfc3c5de56..99589713fa 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -2882,7 +2882,9 @@ class NetAppCmodeFileStorageLibrary(object): # than twice the replication schedule. if (last_update_timestamp and (timeutils.is_older_than( - datetime.datetime.utcfromtimestamp(last_update_timestamp) + datetime.datetime.fromtimestamp( + last_update_timestamp, + tz=datetime.timezone.utc).replace(tzinfo=None) .isoformat(), (2 * self._snapmirror_schedule)))): return constants.REPLICA_STATE_OUT_OF_SYNC diff --git a/manila/tests/message/test_api.py b/manila/tests/message/test_api.py index 7ea0182a90..bc94ca0f27 100644 --- a/manila/tests/message/test_api.py +++ b/manila/tests/message/test_api.py @@ -37,7 +37,7 @@ class MessageApiTest(test.TestCase): @mock.patch.object(timeutils, 'utcnow') def test_create(self, mock_utcnow): CONF.set_override('message_ttl', 300) - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) mock_utcnow.return_value = now expected_expires_at = now + datetime.timedelta( seconds=300) diff --git a/manila/tests/share/test_api.py b/manila/tests/share/test_api.py index f7ea02f3e1..d664051bfc 100644 --- a/manila/tests/share/test_api.py +++ b/manila/tests/share/test_api.py @@ -120,7 +120,7 @@ class ShareAPITestCase(test.TestCase): self.mock_object(quota.QUOTAS, 'reserve', lambda *args, **kwargs: None) - self.dt_utc = datetime.datetime.utcnow() + self.dt_utc = timeutils.utcnow() self.mock_object(timeutils, 'utcnow', mock.Mock(return_value=self.dt_utc)) self.mock_object(share_api.policy, 'check_policy') diff --git a/manila/tests/share_group/test_api.py b/manila/tests/share_group/test_api.py index 48e18c15ec..c73c87aabf 100644 --- a/manila/tests/share_group/test_api.py +++ b/manila/tests/share_group/test_api.py @@ -93,7 +93,7 @@ class ShareGroupsAPITestCase(test.TestCase): self.mock_object(self.api, 'share_api', self.share_api) self.mock_object(self.api, 'scheduler_rpcapi', self.scheduler_rpcapi) - dt_utc = datetime.datetime.utcnow() + dt_utc = timeutils.utcnow() self.mock_object(timeutils, 'utcnow', mock.Mock(return_value=dt_utc)) self.fake_share_type = { 'name': 'default', diff --git a/manila/tests/test_service.py b/manila/tests/test_service.py index 09031da87a..b47189daa0 100644 --- a/manila/tests/test_service.py +++ b/manila/tests/test_service.py @@ -21,13 +21,13 @@ Unit Tests for remote procedure calls using queue """ -from datetime import datetime from datetime import timedelta from unittest import mock import ddt from oslo_config import cfg from oslo_service import wsgi +from oslo_utils import timeutils from manila import context from manila import db @@ -300,9 +300,9 @@ class ServiceTestCase(test.TestCase): if cleanup_interval_done: service_ref_stopped['updated_at'] = ( - datetime.utcnow() - timedelta(minutes=10)) + timeutils.utcnow() - timedelta(minutes=10)) else: - service_ref_stopped['updated_at'] = datetime.utcnow() + service_ref_stopped['updated_at'] = timeutils.utcnow() mock_db.service_get_all_by_topic.return_value = [ service_ref_stopped] serv.stop() diff --git a/requirements.txt b/requirements.txt index e0c5f83199..ba2038c668 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ oslo.rootwrap>=6.2.0 # Apache-2.0 oslo.serialization>=4.0.1 # Apache-2.0 oslo.service>=2.4.0 # Apache-2.0 oslo.upgradecheck>=1.3.0 # Apache-2.0 -oslo.utils>=4.7.0 # Apache-2.0 +oslo.utils>=7.0.0 # Apache-2.0 oslo.concurrency>=4.3.0 # Apache-2.0 osprofiler>=3.4.0 # Apache-2.0 paramiko>=2.7.2 # LGPLv2.1+