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
This commit is contained in:
parent
a48c05b90a
commit
9385113d40
openstackclient
requirements.txt@ -21,6 +21,7 @@ import io
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import iso8601
|
||||||
from novaclient import api_versions
|
from novaclient import api_versions
|
||||||
from novaclient.v2 import servers
|
from novaclient.v2 import servers
|
||||||
from openstack import exceptions as sdk_exceptions
|
from openstack import exceptions as sdk_exceptions
|
||||||
@ -29,7 +30,6 @@ from osc_lib.cli import parseractions
|
|||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from oslo_utils import timeutils
|
|
||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
from openstackclient.identity import common as identity_common
|
from openstackclient.identity import common as identity_common
|
||||||
@ -1404,8 +1404,8 @@ class ListServer(command.Lister):
|
|||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
timeutils.parse_isotime(search_opts['changes-before'])
|
iso8601.parse_date(search_opts['changes-before'])
|
||||||
except ValueError:
|
except (TypeError, iso8601.ParseError):
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
_('Invalid changes-before value: %s') %
|
_('Invalid changes-before value: %s') %
|
||||||
search_opts['changes-before']
|
search_opts['changes-before']
|
||||||
@ -1413,8 +1413,8 @@ class ListServer(command.Lister):
|
|||||||
|
|
||||||
if search_opts['changes-since']:
|
if search_opts['changes-since']:
|
||||||
try:
|
try:
|
||||||
timeutils.parse_isotime(search_opts['changes-since'])
|
iso8601.parse_date(search_opts['changes-since'])
|
||||||
except ValueError:
|
except (TypeError, iso8601.ParseError):
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
_('Invalid changes-since value: %s') %
|
_('Invalid changes-since value: %s') %
|
||||||
search_opts['changes-since']
|
search_opts['changes-since']
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
|
|
||||||
"""Compute v2 Server action implementations"""
|
"""Compute v2 Server action implementations"""
|
||||||
|
|
||||||
|
import importlib
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from oslo_utils import importutils
|
|
||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ class CreateServerBackup(command.ShowOne):
|
|||||||
info['properties'] = utils.format_dict(info.get('properties', {}))
|
info['properties'] = utils.format_dict(info.get('properties', {}))
|
||||||
else:
|
else:
|
||||||
# Get the right image module to format the output
|
# Get the right image module to format the output
|
||||||
image_module = importutils.import_module(
|
image_module = importlib.import_module(
|
||||||
self.IMAGE_API_VERSIONS[
|
self.IMAGE_API_VERSIONS[
|
||||||
self.app.client_manager._api_version['image']
|
self.app.client_manager._api_version['image']
|
||||||
]
|
]
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
"""Compute v2 Server action implementations"""
|
"""Compute v2 Server action implementations"""
|
||||||
|
|
||||||
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from oslo_utils import importutils
|
|
||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class CreateServerImage(command.ShowOne):
|
|||||||
info['properties'] = utils.format_dict(info.get('properties', {}))
|
info['properties'] = utils.format_dict(info.get('properties', {}))
|
||||||
else:
|
else:
|
||||||
# Get the right image module to format the output
|
# Get the right image module to format the output
|
||||||
image_module = importutils.import_module(
|
image_module = importlib.import_module(
|
||||||
self.IMAGE_API_VERSIONS[
|
self.IMAGE_API_VERSIONS[
|
||||||
self.app.client_manager._api_version['image']
|
self.app.client_manager._api_version['image']
|
||||||
]
|
]
|
||||||
|
@ -19,11 +19,11 @@ import getpass
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import call
|
from unittest.mock import call
|
||||||
|
|
||||||
|
import iso8601
|
||||||
from novaclient import api_versions
|
from novaclient import api_versions
|
||||||
from openstack import exceptions as sdk_exceptions
|
from openstack import exceptions as sdk_exceptions
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils as common_utils
|
from osc_lib import utils as common_utils
|
||||||
from oslo_utils import timeutils
|
|
||||||
|
|
||||||
from openstackclient.compute.v2 import server
|
from openstackclient.compute.v2 import server
|
||||||
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
||||||
@ -2945,7 +2945,7 @@ class TestServerList(TestServer):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(tuple(self.data), tuple(data))
|
self.assertEqual(tuple(self.data), tuple(data))
|
||||||
|
|
||||||
@mock.patch.object(timeutils, 'parse_isotime', side_effect=ValueError)
|
@mock.patch.object(iso8601, 'parse_date', side_effect=iso8601.ParseError)
|
||||||
def test_server_list_with_invalid_changes_since(self, mock_parse_isotime):
|
def test_server_list_with_invalid_changes_since(self, mock_parse_isotime):
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
@ -2988,7 +2988,7 @@ class TestServerList(TestServer):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(tuple(self.data), tuple(data))
|
self.assertEqual(tuple(self.data), tuple(data))
|
||||||
|
|
||||||
@mock.patch.object(timeutils, 'parse_isotime', side_effect=ValueError)
|
@mock.patch.object(iso8601, 'parse_date', side_effect=iso8601.ParseError)
|
||||||
def test_server_list_v266_with_invalid_changes_before(
|
def test_server_list_v266_with_invalid_changes_before(
|
||||||
self, mock_parse_isotime):
|
self, mock_parse_isotime):
|
||||||
self.app.client_manager.compute.api_version = (
|
self.app.client_manager.compute.api_version = (
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import importlib
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from osc_lib.tests import utils as osc_lib_test_utils
|
from osc_lib.tests import utils as osc_lib_test_utils
|
||||||
from oslo_utils import importutils
|
|
||||||
import wrapt
|
import wrapt
|
||||||
|
|
||||||
from openstackclient import shell
|
from openstackclient import shell
|
||||||
@ -151,12 +151,13 @@ class TestShell(osc_lib_test_utils.TestShell):
|
|||||||
super(TestShell, self).setUp()
|
super(TestShell, self).setUp()
|
||||||
# TODO(dtroyer): remove this once the shell_class_patch patch is
|
# TODO(dtroyer): remove this once the shell_class_patch patch is
|
||||||
# released in osc-lib
|
# released in osc-lib
|
||||||
self.shell_class = importutils.import_class(self.shell_class_name)
|
mod_str, _sep, class_str = self.shell_class_name.rpartition('.')
|
||||||
|
self.shell_class = getattr(importlib.import_module(mod_str), class_str)
|
||||||
|
|
||||||
def _assert_admin_token_auth(self, cmd_options, default_args):
|
def _assert_admin_token_auth(self, cmd_options, default_args):
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
self.shell_class_name + ".initialize_app",
|
self.shell_class_name + ".initialize_app",
|
||||||
self.app,
|
self.app,
|
||||||
):
|
):
|
||||||
_shell = osc_lib_test_utils.make_shell(
|
_shell = osc_lib_test_utils.make_shell(
|
||||||
shell_class=self.shell_class,
|
shell_class=self.shell_class,
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
|
|
||||||
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
||||||
|
iso8601>=0.1.11 # MIT
|
||||||
openstacksdk>=0.48.0 # Apache-2.0
|
openstacksdk>=0.48.0 # Apache-2.0
|
||||||
osc-lib>=2.0.0 # Apache-2.0
|
osc-lib>=2.0.0 # Apache-2.0
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
oslo.utils>=3.33.0 # Apache-2.0
|
|
||||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||||
python-novaclient>=15.1.0 # Apache-2.0
|
python-novaclient>=15.1.0 # Apache-2.0
|
||||||
python-cinderclient>=3.3.0 # Apache-2.0
|
python-cinderclient>=3.3.0 # Apache-2.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user