From 41dcac598bb57c7ef28b5321284a25d61eaf25cb Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Wed, 17 Jul 2024 17:39:50 -0400 Subject: [PATCH] Use convert_version_to_tuple() instead of pkg_resources In [0] when we changed code to consistently use convert_version_to_tuple() instead of the packaging library, one place was missed since it used the pkg_resources library. Change to use the same code throughout the tree for version checks. Also fixes a pylint warning as the pkg_resources API usage generates a DeprecationWarning. [0] https://review.opendev.org/c/openstack/neutron/+/890162 TrivialFix Change-Id: I54e4e310b660acf3dd4cf07a50636512904b578c --- neutron/agent/linux/iptables_manager.py | 3 ++- neutron/common/utils.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/neutron/agent/linux/iptables_manager.py b/neutron/agent/linux/iptables_manager.py index f933f827387..e7537575f75 100644 --- a/neutron/agent/linux/iptables_manager.py +++ b/neutron/agent/linux/iptables_manager.py @@ -487,7 +487,8 @@ class IptablesManager(object): privsep_exec=True).split('\n') def _get_version(self): - # Output example is "iptables v1.6.2" + # Output example is "iptables v1.8.7 (nf_tables)", + # this will return "1.8.7" args = ['iptables', '--version'] version = str(linux_utils.execute( args, run_as_root=True, privsep_exec=True).split()[1][1:]) diff --git a/neutron/common/utils.py b/neutron/common/utils.py index 58d20dbd06f..ffe9164db2c 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -50,8 +50,8 @@ from oslo_utils import encodeutils from oslo_utils import excutils from oslo_utils import timeutils from oslo_utils import uuidutils +from oslo_utils import versionutils from osprofiler import profiler -import pkg_resources from sqlalchemy.dialects.mysql import dialect as mysql_dialect from sqlalchemy.dialects.postgresql import dialect as postgresql_dialect from sqlalchemy.dialects.sqlite import dialect as sqlite_dialect @@ -356,8 +356,8 @@ def get_socket_address_family(ip_version): def is_version_greater_equal(version1, version2): """Returns True if version1 is greater or equal than version2 else False""" - return (pkg_resources.parse_version(version1) >= - pkg_resources.parse_version(version2)) + return (versionutils.convert_version_to_tuple(version1) >= + versionutils.convert_version_to_tuple(version2)) class DelayedStringRenderer(object):