Remove version checks

openstacksdk 1.0.0 was released 3½ years ago [1]. pip is not going to
pull that version any more. These checks are redundant.

In addition, we can remove sdk_version extra var. Change
I9665f04e6c0d5a84d6c20a73ef7b0dfdc7bd8159 removed the last guard that
relied on this, similarly about 3½ years ago.

[1] https://pypi.org/project/openstacksdk/1.0.0/

Change-Id: Ic0dd7bc5de1f24d1ee3336ccea97aced850f86af
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2026-06-10 12:28:26 +01:00
parent c81422e3f6
commit 0ada05ec10
5 changed files with 3 additions and 73 deletions

View File

@@ -155,9 +155,6 @@ import sys
from ansible.errors import AnsibleParserError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
ensure_compatibility
)
try:
import openstack
@@ -179,12 +176,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
raise AnsibleParserError(
'Could not import Python library openstacksdk')
try:
ensure_compatibility(openstack.version.__version__)
except ImportError as e:
raise AnsibleParserError(
'Incompatible openstacksdk library found: {0}'.format(e))
# Redirect logging to stderr so it does not mix with output, in
# particular JSON output of ansible-inventory.
# TODO: Integrate openstack's logging with Ansible's logging.

View File

@@ -47,45 +47,8 @@ import os
from ansible.module_utils.basic import AnsibleModule
OVERRIDES = {}
CUSTOM_VAR_PARAMS = ['min_ver', 'max_ver']
MINIMUM_SDK_VERSION = '1.0.0'
MAXIMUM_SDK_VERSION = None
def ensure_compatibility(version, min_version=None, max_version=None):
""" Raises ImportError if the specified version does not
meet the minimum and maximum version requirements"""
if min_version and MINIMUM_SDK_VERSION:
min_version = max(StrictVersion(MINIMUM_SDK_VERSION),
StrictVersion(min_version))
elif MINIMUM_SDK_VERSION:
min_version = StrictVersion(MINIMUM_SDK_VERSION)
if max_version and MAXIMUM_SDK_VERSION:
max_version = min(StrictVersion(MAXIMUM_SDK_VERSION),
StrictVersion(max_version))
elif MAXIMUM_SDK_VERSION:
max_version = StrictVersion(MAXIMUM_SDK_VERSION)
if min_version and StrictVersion(version) < min_version:
raise ImportError(
"Version MUST be >={min_version} and <={max_version}, but"
" {version} is smaller than minimum version {min_version}"
.format(version=version,
min_version=min_version,
max_version=max_version))
if max_version and StrictVersion(version) > max_version:
raise ImportError(
"Version MUST be >={min_version} and <={max_version}, but"
" {version} is larger than maximum version {max_version}"
.format(version=version,
min_version=min_version,
max_version=max_version))
def openstack_argument_spec():
# DEPRECATED: This argument spec is only used for the deprecated old
@@ -164,14 +127,6 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
except ImportError:
module.fail_json(msg='openstacksdk is required for this module')
try:
ensure_compatibility(sdk.version.__version__,
min_version, max_version)
except ImportError as e:
module.fail_json(
msg="Incompatible openstacksdk library found: {error}."
.format(error=str(e)))
cloud_config = module.params.pop('cloud', None)
try:
if isinstance(cloud_config, dict):
@@ -244,8 +199,6 @@ class OpenStackModule:
deprecated_names = ()
argument_spec = {}
module_kwargs = {}
module_min_sdk_version = None
module_max_sdk_version = None
def __init__(self):
"""Initialize Openstack base class.
@@ -314,19 +267,9 @@ class OpenStackModule:
try:
# Due to the name shadowing we should import other way
sdk = importlib.import_module('openstack')
self.sdk_version = sdk.version.__version__
except ImportError:
self.fail_json(msg='openstacksdk is required for this module')
try:
ensure_compatibility(self.sdk_version,
self.module_min_sdk_version,
self.module_max_sdk_version)
except ImportError as e:
self.fail_json(
msg="Incompatible openstacksdk library found: {error}."
.format(error=str(e)))
# Fail if there are set unsupported for this version parameters
# New parameters should NOT use 'default' but rely on SDK defaults
for param in self.argument_spec: