Skip to content

Commit

Permalink
Use botocore_at_least rather than LooseVersion/StrictVersion directly (
Browse files Browse the repository at this point in the history
…ansible-collections#280)

* Use botocore_at_least rather than LooseVersion/StrictVersion directly

* changelog
  • Loading branch information
tremble authored and abikouo committed Sep 18, 2023
1 parent 0f83c78 commit 671e1b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 2 additions & 3 deletions dynamodb_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
- { "AttributeName": "deploy_timestamp", "Enabled": true }
'''

import distutils.version
import traceback

try:
Expand Down Expand Up @@ -126,8 +125,8 @@ def main():
argument_spec=argument_spec,
)

if distutils.version.StrictVersion(botocore.__version__) < distutils.version.StrictVersion('1.5.24'):
# TTL was added in this version.
if not module.botocore_at_least('1.5.24'):
# TTL was added in 1.5.24
module.fail_json(msg='Found botocore in version {0}, but >= {1} is required for TTL support'.format(botocore.__version__, '1.5.24'))

try:
Expand Down
3 changes: 1 addition & 2 deletions ec2_vpc_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
except ImportError:
pass # Handled by AnsibleAWSModule

import distutils.version
import traceback

from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
Expand Down Expand Up @@ -279,7 +278,7 @@ def create_peer_connection(client, module):
params['VpcId'] = module.params.get('vpc_id')
params['PeerVpcId'] = module.params.get('peer_vpc_id')
if module.params.get('peer_region'):
if distutils.version.StrictVersion(botocore.__version__) < distutils.version.StrictVersion('1.8.6'):
if not module.botocore_at_least('1.8.6'):
module.fail_json(msg="specifying peer_region parameter requires botocore >= 1.8.6")
params['PeerRegion'] = module.params.get('peer_region')
if module.params.get('peer_owner_id'):
Expand Down
9 changes: 3 additions & 6 deletions ecs_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,26 @@ def stop_task(self, cluster, task):
return response['task']

def ecs_api_handles_launch_type(self):
from distutils.version import LooseVersion
# There doesn't seem to be a nice way to inspect botocore to look
# for attributes (and networkConfiguration is not an explicit argument
# to e.g. ecs.run_task, it's just passed as a keyword argument)
return LooseVersion(botocore.__version__) >= LooseVersion('1.8.4')
return self.module.botocore_at_least('1.8.4')

def ecs_task_long_format_enabled(self):
account_support = self.ecs.list_account_settings(name='taskLongArnFormat', effectiveSettings=True)
return account_support['settings'][0]['value'] == 'enabled'

def ecs_api_handles_tags(self):
from distutils.version import LooseVersion
# There doesn't seem to be a nice way to inspect botocore to look
# for attributes (and networkConfiguration is not an explicit argument
# to e.g. ecs.run_task, it's just passed as a keyword argument)
return LooseVersion(botocore.__version__) >= LooseVersion('1.12.46')
return self.module.botocore_at_least('1.12.46')

def ecs_api_handles_network_configuration(self):
from distutils.version import LooseVersion
# There doesn't seem to be a nice way to inspect botocore to look
# for attributes (and networkConfiguration is not an explicit argument
# to e.g. ecs.run_task, it's just passed as a keyword argument)
return LooseVersion(botocore.__version__) >= LooseVersion('1.7.44')
return self.module.botocore_at_least('1.7.44')


def main():
Expand Down

0 comments on commit 671e1b0

Please sign in to comment.