From 4eefb425507c5ca9c876774fad3ac90ba6db3cb3 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Tue, 24 Mar 2020 10:18:09 +0100 Subject: [PATCH] Finalize ironicclient removal Completely remove dependency from ironicclient in favor of openstacksdk. Change-Id: I9b98ddb05fe867a0d3884f736a2edd7b4d61b00c --- ironic_inspector/plugins/local_link_connection.py | 4 ++-- .../test/unit/test_plugins_local_link_connection.py | 6 +++--- ironic_inspector/test/unit/test_utils.py | 10 +++++----- ironic_inspector/utils.py | 3 ++- lower-constraints.txt | 1 - .../notes/vaporize-ironicclient-8c6afbecc0152dad.yaml | 7 +++++++ requirements.txt | 1 - tox.ini | 2 +- 8 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/vaporize-ironicclient-8c6afbecc0152dad.yaml diff --git a/ironic_inspector/plugins/local_link_connection.py b/ironic_inspector/plugins/local_link_connection.py index aea9faa7d..956f1d305 100644 --- a/ironic_inspector/plugins/local_link_connection.py +++ b/ironic_inspector/plugins/local_link_connection.py @@ -16,8 +16,8 @@ import binascii from construct import core -from ironicclient import exceptions import netaddr +from openstack import exceptions from oslo_config import cfg from oslo_utils import netutils @@ -160,7 +160,7 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook): try: node_info.patch_port(port, patches) - except exceptions.BadRequest as e: + except exceptions.BadRequestException as e: LOG.warning("Failed to update port %(uuid)s: %(error)s", {'uuid': port.uuid, 'error': e}, node_info=node_info) diff --git a/ironic_inspector/test/unit/test_plugins_local_link_connection.py b/ironic_inspector/test/unit/test_plugins_local_link_connection.py index b0687203d..375f3b853 100644 --- a/ironic_inspector/test/unit/test_plugins_local_link_connection.py +++ b/ironic_inspector/test/unit/test_plugins_local_link_connection.py @@ -11,8 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ironicclient import exceptions import mock +from openstack import exceptions from oslo_config import cfg from ironic_inspector import node_cache @@ -224,8 +224,8 @@ class TestGenericLocalLinkConnectionHook(test_base.NodeTest): } } - mock_patch.side_effect = exceptions.BadRequest('invalid data') + mock_patch.side_effect = exceptions.BadRequestException('invalid data') self.hook.before_update(self.data, self.node_info) - log_msg = ("Failed to update port %(uuid)s: %(error)s") + log_msg = "Failed to update port %(uuid)s: %(error)s" mock_log.warning.assert_called_with(log_msg, mock.ANY, node_info=mock.ANY) diff --git a/ironic_inspector/test/unit/test_utils.py b/ironic_inspector/test/unit/test_utils.py index 17b335460..d84b4c44f 100644 --- a/ironic_inspector/test/unit/test_utils.py +++ b/ironic_inspector/test/unit/test_utils.py @@ -11,9 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ironicclient.v1 import node from keystonemiddleware import auth_token import mock +from openstack.baremetal.v1 import node from oslo_config import cfg from ironic_inspector.common import context @@ -87,7 +87,7 @@ class TestProcessingLogger(base.BaseTest): utils.processing_logger_prefix()) def test_prefix_only_uuid(self): - node_info = node.Node(mock.Mock(), dict(uuid='NNN')) + node_info = mock.Mock(uuid='NNN', spec=node.Node) self.assertEqual('[node: NNN]', utils.processing_logger_prefix(node_info=node_info)) @@ -102,7 +102,7 @@ class TestProcessingLogger(base.BaseTest): utils.processing_logger_prefix(data=data)) def test_prefix_everything(self): - node_info = node.Node(mock.Mock(), dict(uuid='NNN')) + node_info = mock.Mock(uuid='NNN', spec=node.Node) data = {'boot_interface': '01-aa-bb-cc-dd-ee-ff', 'inventory': {'bmc_address': '1.2.3.4'}} self.assertEqual('[node: NNN MAC aa:bb:cc:dd:ee:ff BMC 1.2.3.4]', @@ -110,7 +110,7 @@ class TestProcessingLogger(base.BaseTest): data=data)) def test_prefix_uuid_not_str(self): - node_info = node.Node(mock.Mock(), dict(uuid=None)) + node_info = mock.Mock(uuid=None, spec=node.Node) self.assertEqual('[node: None]', utils.processing_logger_prefix(node_info=node_info)) @@ -125,7 +125,7 @@ class TestProcessingLogger(base.BaseTest): utils.processing_logger_prefix(node_info=node_info)) def test_adapter_with_bmc(self): - node_info = node.Node(mock.Mock(), dict(uuid='NNN')) + node_info = mock.Mock(uuid='NNN', spec=node.Node) data = {'boot_interface': '01-aa-bb-cc-dd-ee-ff', 'inventory': {'bmc_address': '1.2.3.4'}} logger = utils.getProcessingLogger(__name__) diff --git a/ironic_inspector/utils.py b/ironic_inspector/utils.py index f560d5133..7f87e4070 100644 --- a/ironic_inspector/utils.py +++ b/ironic_inspector/utils.py @@ -15,8 +15,8 @@ import datetime import logging as pylog import futurist -from ironicclient.v1 import node from keystonemiddleware import auth_token +from openstack.baremetal.v1 import node from oslo_config import cfg from oslo_log import log from oslo_middleware import cors as cors_middleware @@ -203,6 +203,7 @@ def check_auth(request, rule=None, target=None): :param request: Flask request :param rule: policy rule to check the request against + :param target: dict-like structure to check rule against :raises: utils.Error if access is denied """ if CONF.auth_strategy == 'noauth': diff --git a/lower-constraints.txt b/lower-constraints.txt index 1ef01d2cb..7e49473f5 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -37,7 +37,6 @@ oslotest==3.2.0 oslo.utils==3.33.0 pbr==2.0.0 pymemcache==1.2.9 -python-ironicclient==2.3.0 pytz==2013.6 reno==2.5.0 retrying==1.2.3 diff --git a/releasenotes/notes/vaporize-ironicclient-8c6afbecc0152dad.yaml b/releasenotes/notes/vaporize-ironicclient-8c6afbecc0152dad.yaml new file mode 100644 index 000000000..bc6dd08db --- /dev/null +++ b/releasenotes/notes/vaporize-ironicclient-8c6afbecc0152dad.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The python-ironicclient package has been removed as a dependency in favor + of openstacksdk. + Third party modules and plugins will require an update if they previously + invoked ironicclient. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4b52ef79a..5f824784d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,6 @@ keystoneauth1>=3.14.0 # Apache-2.0 keystonemiddleware>=4.18.0 # Apache-2.0 netaddr>=0.7.18 # BSD pbr!=2.1.0,>=2.0.0 # Apache-2.0 -python-ironicclient!=2.5.2,!=2.7.1,!=3.0.0,>=2.3.0 # Apache-2.0 pytz>=2013.6 # MIT openstacksdk>=0.40.0 # Apache-2.0 oslo.concurrency>=3.26.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 193626d41..f90693356 100644 --- a/tox.ini +++ b/tox.ini @@ -76,7 +76,7 @@ import-order-style = pep8 application-import-names = ironic_inspector [hacking] -import_exceptions = ironicclient.exceptions,ironic_inspector.common.i18n +import_exceptions = ironic_inspector.common.i18n [testenv:docs] setenv = PYTHONHASHSEED=0