Skip to content

Commit 9385113

Browse files
emontystephenfin
authored andcommitted
Remove oslo.utils
Oslo things are really server-side oriented and are heavy-weight for client things. Remove oslo.utils and just use iso8601 and importlib directly. It's not actually a bad library, but pulling it and its other deps in just for a couple of wrapper methods is a bit much here. oslo.i18n, fwiw, is lightweight and helpful. Change-Id: I463993170c03a1d98c47ab6a3c19131b7fca1099
1 parent a48c05b commit 9385113

6 files changed

Lines changed: 19 additions & 17 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import logging
2222
import os
2323

24+
import iso8601
2425
from novaclient import api_versions
2526
from novaclient.v2 import servers
2627
from openstack import exceptions as sdk_exceptions
@@ -29,7 +30,6 @@
2930
from osc_lib.command import command
3031
from osc_lib import exceptions
3132
from osc_lib import utils
32-
from oslo_utils import timeutils
3333

3434
from openstackclient.i18n import _
3535
from openstackclient.identity import common as identity_common
@@ -1404,17 +1404,17 @@ def take_action(self, parsed_args):
14041404
raise exceptions.CommandError(msg)
14051405

14061406
try:
1407-
timeutils.parse_isotime(search_opts['changes-before'])
1408-
except ValueError:
1407+
iso8601.parse_date(search_opts['changes-before'])
1408+
except (TypeError, iso8601.ParseError):
14091409
raise exceptions.CommandError(
14101410
_('Invalid changes-before value: %s') %
14111411
search_opts['changes-before']
14121412
)
14131413

14141414
if search_opts['changes-since']:
14151415
try:
1416-
timeutils.parse_isotime(search_opts['changes-since'])
1417-
except ValueError:
1416+
iso8601.parse_date(search_opts['changes-since'])
1417+
except (TypeError, iso8601.ParseError):
14181418
raise exceptions.CommandError(
14191419
_('Invalid changes-since value: %s') %
14201420
search_opts['changes-since']

openstackclient/compute/v2/server_backup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
"""Compute v2 Server action implementations"""
1717

18+
import importlib
19+
1820
from osc_lib.command import command
1921
from osc_lib import exceptions
2022
from osc_lib import utils
21-
from oslo_utils import importutils
2223

2324
from openstackclient.i18n import _
2425

@@ -119,7 +120,7 @@ def _show_progress(progress):
119120
info['properties'] = utils.format_dict(info.get('properties', {}))
120121
else:
121122
# Get the right image module to format the output
122-
image_module = importutils.import_module(
123+
image_module = importlib.import_module(
123124
self.IMAGE_API_VERSIONS[
124125
self.app.client_manager._api_version['image']
125126
]

openstackclient/compute/v2/server_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
"""Compute v2 Server action implementations"""
1717

18+
import importlib
1819
import logging
1920

2021
from osc_lib.command import command
2122
from osc_lib import exceptions
2223
from osc_lib import utils
23-
from oslo_utils import importutils
2424

2525
from openstackclient.i18n import _
2626

@@ -99,7 +99,7 @@ def _show_progress(progress):
9999
info['properties'] = utils.format_dict(info.get('properties', {}))
100100
else:
101101
# Get the right image module to format the output
102-
image_module = importutils.import_module(
102+
image_module = importlib.import_module(
103103
self.IMAGE_API_VERSIONS[
104104
self.app.client_manager._api_version['image']
105105
]

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
from unittest import mock
2020
from unittest.mock import call
2121

22+
import iso8601
2223
from novaclient import api_versions
2324
from openstack import exceptions as sdk_exceptions
2425
from osc_lib import exceptions
2526
from osc_lib import utils as common_utils
26-
from oslo_utils import timeutils
2727

2828
from openstackclient.compute.v2 import server
2929
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
@@ -2945,7 +2945,7 @@ def test_server_list_with_changes_since(self):
29452945
self.assertEqual(self.columns, columns)
29462946
self.assertEqual(tuple(self.data), tuple(data))
29472947

2948-
@mock.patch.object(timeutils, 'parse_isotime', side_effect=ValueError)
2948+
@mock.patch.object(iso8601, 'parse_date', side_effect=iso8601.ParseError)
29492949
def test_server_list_with_invalid_changes_since(self, mock_parse_isotime):
29502950

29512951
arglist = [
@@ -2988,7 +2988,7 @@ def test_server_list_v266_with_changes_before(self):
29882988
self.assertEqual(self.columns, columns)
29892989
self.assertEqual(tuple(self.data), tuple(data))
29902990

2991-
@mock.patch.object(timeutils, 'parse_isotime', side_effect=ValueError)
2991+
@mock.patch.object(iso8601, 'parse_date', side_effect=iso8601.ParseError)
29922992
def test_server_list_v266_with_invalid_changes_before(
29932993
self, mock_parse_isotime):
29942994
self.app.client_manager.compute.api_version = (

openstackclient/tests/unit/test_shell.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# under the License.
1414
#
1515

16+
import importlib
1617
import os
1718
import sys
1819
from unittest import mock
1920

2021
from osc_lib.tests import utils as osc_lib_test_utils
21-
from oslo_utils import importutils
2222
import wrapt
2323

2424
from openstackclient import shell
@@ -151,12 +151,13 @@ def setUp(self):
151151
super(TestShell, self).setUp()
152152
# TODO(dtroyer): remove this once the shell_class_patch patch is
153153
# released in osc-lib
154-
self.shell_class = importutils.import_class(self.shell_class_name)
154+
mod_str, _sep, class_str = self.shell_class_name.rpartition('.')
155+
self.shell_class = getattr(importlib.import_module(mod_str), class_str)
155156

156157
def _assert_admin_token_auth(self, cmd_options, default_args):
157158
with mock.patch(
158-
self.shell_class_name + ".initialize_app",
159-
self.app,
159+
self.shell_class_name + ".initialize_app",
160+
self.app,
160161
):
161162
_shell = osc_lib_test_utils.make_shell(
162163
shell_class=self.shell_class,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
pbr!=2.1.0,>=2.0.0 # Apache-2.0
55

66
cliff!=2.9.0,>=2.8.0 # Apache-2.0
7+
iso8601>=0.1.11 # MIT
78
openstacksdk>=0.48.0 # Apache-2.0
89
osc-lib>=2.0.0 # Apache-2.0
910
oslo.i18n>=3.15.3 # Apache-2.0
10-
oslo.utils>=3.33.0 # Apache-2.0
1111
python-keystoneclient>=3.22.0 # Apache-2.0
1212
python-novaclient>=15.1.0 # Apache-2.0
1313
python-cinderclient>=3.3.0 # Apache-2.0

0 commit comments

Comments
 (0)