mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-25 01:04:28 +00:00
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:
@@ -104,9 +104,6 @@ for var in $(env | grep -e '^ANSIBLE_VAR_'); do
|
|||||||
ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables
|
ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables
|
||||||
done
|
done
|
||||||
|
|
||||||
# Discover openstacksdk version
|
|
||||||
SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)")
|
|
||||||
|
|
||||||
# Choose integration tests
|
# Choose integration tests
|
||||||
tag_opt=""
|
tag_opt=""
|
||||||
if [ -n "$TAGS" ]; then
|
if [ -n "$TAGS" ]; then
|
||||||
@@ -136,5 +133,5 @@ set -o pipefail
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
ANSIBLE_COLLECTIONS_PATH=$TEST_COLLECTIONS_PATHS ansible-playbook \
|
ANSIBLE_COLLECTIONS_PATH=$TEST_COLLECTIONS_PATHS ansible-playbook \
|
||||||
-vvv ./run-collection.yml \
|
-vvv ./run-collection.yml \
|
||||||
-e "sdk_version=${SDK_VER} cloud=${CLOUD} cloud_alt=${CLOUD_ALT} ${ANSIBLE_VARS}" \
|
-e "cloud=${CLOUD} cloud_alt=${CLOUD_ALT} ${ANSIBLE_VARS}" \
|
||||||
${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log
|
${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ list(conn.network.ips())[0].to_dict(computed=False)
|
|||||||
To run the unit tests of the collection, run this in a Bash shell:
|
To run the unit tests of the collection, run this in a Bash shell:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)")
|
ansible-playbook -vvv ci/run-collection.yml -e "cloud=devstack-admin cloud_alt=devstack-alt"
|
||||||
ansible-playbook -vvv ci/run-collection.yml -e "sdk_version=${SDK_VER} cloud=devstack-admin cloud_alt=devstack-alt"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `ansible-playbook`'s `--tags` and `--skip-tags` parameters to skip CI tests. For a list of available tags, refer to
|
Use `ansible-playbook`'s `--tags` and `--skip-tags` parameters to skip CI tests. For a list of available tags, refer to
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ How to do a review? What to look for when reviewing patches?
|
|||||||
Example:
|
Example:
|
||||||
```sh
|
```sh
|
||||||
ansible-playbook -vvv ci/run-collection.yml \
|
ansible-playbook -vvv ci/run-collection.yml \
|
||||||
-e "sdk_version=1.0.0 cloud=devstack-admin cloud_alt=devstack-alt" \
|
-e "cloud=devstack-admin cloud_alt=devstack-alt" \
|
||||||
--tags floating_ip_info
|
--tags floating_ip_info
|
||||||
```
|
```
|
||||||
* Does a patch remove any functionality or break backwards compatibility? The author must give a good explanation for
|
* Does a patch remove any functionality or break backwards compatibility? The author must give a good explanation for
|
||||||
|
|||||||
@@ -155,9 +155,6 @@ import sys
|
|||||||
|
|
||||||
from ansible.errors import AnsibleParserError
|
from ansible.errors import AnsibleParserError
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
|
|
||||||
ensure_compatibility
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import openstack
|
import openstack
|
||||||
@@ -179,12 +176,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
raise AnsibleParserError(
|
raise AnsibleParserError(
|
||||||
'Could not import Python library openstacksdk')
|
'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
|
# Redirect logging to stderr so it does not mix with output, in
|
||||||
# particular JSON output of ansible-inventory.
|
# particular JSON output of ansible-inventory.
|
||||||
# TODO: Integrate openstack's logging with Ansible's logging.
|
# TODO: Integrate openstack's logging with Ansible's logging.
|
||||||
|
|||||||
@@ -47,45 +47,8 @@ import os
|
|||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
OVERRIDES = {}
|
OVERRIDES = {}
|
||||||
|
|
||||||
CUSTOM_VAR_PARAMS = ['min_ver', 'max_ver']
|
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():
|
def openstack_argument_spec():
|
||||||
# DEPRECATED: This argument spec is only used for the deprecated old
|
# 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:
|
except ImportError:
|
||||||
module.fail_json(msg='openstacksdk is required for this module')
|
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)
|
cloud_config = module.params.pop('cloud', None)
|
||||||
try:
|
try:
|
||||||
if isinstance(cloud_config, dict):
|
if isinstance(cloud_config, dict):
|
||||||
@@ -244,8 +199,6 @@ class OpenStackModule:
|
|||||||
deprecated_names = ()
|
deprecated_names = ()
|
||||||
argument_spec = {}
|
argument_spec = {}
|
||||||
module_kwargs = {}
|
module_kwargs = {}
|
||||||
module_min_sdk_version = None
|
|
||||||
module_max_sdk_version = None
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize Openstack base class.
|
"""Initialize Openstack base class.
|
||||||
@@ -314,19 +267,9 @@ class OpenStackModule:
|
|||||||
try:
|
try:
|
||||||
# Due to the name shadowing we should import other way
|
# Due to the name shadowing we should import other way
|
||||||
sdk = importlib.import_module('openstack')
|
sdk = importlib.import_module('openstack')
|
||||||
self.sdk_version = sdk.version.__version__
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
self.fail_json(msg='openstacksdk is required for this module')
|
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
|
# Fail if there are set unsupported for this version parameters
|
||||||
# New parameters should NOT use 'default' but rely on SDK defaults
|
# New parameters should NOT use 'default' but rely on SDK defaults
|
||||||
for param in self.argument_spec:
|
for param in self.argument_spec:
|
||||||
|
|||||||
Reference in New Issue
Block a user