From fd335b40373c4b5e7f9ddac3e02dcd9a9917118a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 19 Nov 2020 10:02:34 +0000 Subject: [PATCH] Import packaging.version explicitly "packaging.version" should be imported explicitly to avoid the following error: >>> import packaging >>> packaging.version Traceback (most recent call last): File "", line 1, in AttributeError: module 'packaging' has no attribute 'version' This patch also inclues "packaging" in the requirements file. Change-Id: Ibd277e2fcc152fcf7c81ef7470e3beb0c668575c Closes-Bug: #1904854 --- lower-constraints.txt | 1 + neutron/cmd/runtime_checks.py | 6 +++--- requirements.txt | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 6a817905984..42193a3eed8 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -81,6 +81,7 @@ oslotest==3.2.0 osprofiler==2.3.0 ovs==2.8.0 ovsdbapp==1.4.0 +packaging==20.4 Paste==2.0.2 PasteDeploy==1.5.0 pbr==4.0.0 diff --git a/neutron/cmd/runtime_checks.py b/neutron/cmd/runtime_checks.py index 12a9d869972..0f93f9088b2 100644 --- a/neutron/cmd/runtime_checks.py +++ b/neutron/cmd/runtime_checks.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import packaging +from packaging import version from neutron_lib import exceptions from oslo_log import log as logging @@ -41,14 +41,14 @@ def keepalived_use_no_track_support(): cmd = ['keepalived', '--version'] env = {'LC_ALL': 'C', 'PATH': '/sbin:/usr/sbin'} - keepalived_with_track = packaging.version.parse("2.0.0") + keepalived_with_track = version.parse("2.0.0") try: # keepalived --version returns with stderr only res = agent_utils.execute(cmd, addl_env=env, log_fail_as_error=False, return_stderr=True) # First line is the interesting one here from stderr version_line = res[1].split('\n')[0] - keepalived_version = packaging.version.parse(version_line.split()[1]) + keepalived_version = version.parse(version_line.split()[1]) return keepalived_version >= keepalived_with_track except exceptions.ProcessExecutionError: return False diff --git a/requirements.txt b/requirements.txt index 7ca25669d45..cdadcc51c5a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,6 +46,7 @@ osprofiler>=2.3.0 # Apache-2.0 os-ken >= 0.3.0 # Apache-2.0 ovs>=2.8.0 # Apache-2.0 ovsdbapp>=1.4.0 # Apache-2.0 +packaging>=20.4 # Apache-2.0 psutil>=5.3.0 # BSD pyroute2>=0.5.13;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2) pyOpenSSL>=17.1.0 # Apache-2.0