diff --git a/openstackclient/compute/v2/usage.py b/openstackclient/compute/v2/usage.py index 27f9335bb5..5d91358b97 100644 --- a/openstackclient/compute/v2/usage.py +++ b/openstackclient/compute/v2/usage.py @@ -153,7 +153,7 @@ class ListUsage(command.Lister): ) date_cli_format = "%Y-%m-%d" - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) if parsed_args.start: start = datetime.datetime.strptime( @@ -238,7 +238,7 @@ class ShowUsage(command.ShowOne): identity_client = self.app.client_manager.identity compute_client = self.app.client_manager.sdk_connection.compute date_cli_format = "%Y-%m-%d" - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) if parsed_args.start: start = datetime.datetime.strptime( diff --git a/openstackclient/tests/functional/identity/v3/test_application_credential.py b/openstackclient/tests/functional/identity/v3/test_application_credential.py index 4412592784..39c735b2bb 100644 --- a/openstackclient/tests/functional/identity/v3/test_application_credential.py +++ b/openstackclient/tests/functional/identity/v3/test_application_credential.py @@ -107,7 +107,8 @@ class ApplicationCredentialTests(common.IdentityTests): secret = data_utils.rand_name('secret') description = data_utils.rand_name('description') tomorrow = ( - datetime.datetime.utcnow() + datetime.timedelta(days=1) + datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + + datetime.timedelta(days=1) ).strftime('%Y-%m-%dT%H:%M:%S%z') role1, role2 = self._create_role_assignments() raw_output = self.openstack(