Removed start, end time format. Before fix, openstack usage list command resulted 'str' object has no attribute 'isoformat' error.

story: 2010943
task: 48951
Change-Id: I9ee3384cc6df9ca768ac664f01472244dd8e3267
This commit is contained in:
cw0306-lee 2023-10-30 14:17:39 +09:00
parent 53e7d713f0
commit 6b9f40576d
2 changed files with 9 additions and 10 deletions

View File

@ -153,7 +153,6 @@ class ListUsage(command.Lister):
)
date_cli_format = "%Y-%m-%d"
date_api_format = "%Y-%m-%dT%H:%M:%S"
now = datetime.datetime.utcnow()
if parsed_args.start:
@ -170,8 +169,8 @@ class ListUsage(command.Lister):
usage_list = list(
compute_client.usages(
start=start.strftime(date_api_format),
end=end.strftime(date_api_format),
start=start,
end=end,
detailed=True,
)
)
@ -239,7 +238,6 @@ 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"
date_api_format = "%Y-%m-%dT%H:%M:%S"
now = datetime.datetime.utcnow()
if parsed_args.start:
@ -265,8 +263,8 @@ class ShowUsage(command.ShowOne):
usage = compute_client.get_usage(
project=project,
start=start.strftime(date_api_format),
end=end.strftime(date_api_format),
start=start,
end=end,
)
if parsed_args.formatter == 'table':

View File

@ -11,6 +11,7 @@
# under the License.
#
import datetime
from unittest import mock
from openstackclient.compute.v2 import usage as usage_cmds
@ -94,8 +95,8 @@ class TestUsageList(TestUsage):
self.projects_mock.list.assert_called_with()
self.compute_sdk_client.usages.assert_called_with(
start='2016-11-11T00:00:00',
end='2016-12-20T00:00:00',
start=datetime.datetime(2016, 11, 11, 0, 0),
end=datetime.datetime(2016, 12, 20, 0, 0),
detailed=True,
)
@ -190,8 +191,8 @@ class TestUsageShow(TestUsage):
self.compute_sdk_client.get_usage.assert_called_with(
project=self.project.id,
start='2016-11-11T00:00:00',
end='2016-12-20T00:00:00',
start=datetime.datetime(2016, 11, 11, 0, 0),
end=datetime.datetime(2016, 12, 20, 0, 0),
)
self.assertEqual(self.columns, columns)