-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ec2_snapshot_facts for python3 #30606
Conversation
@@ -185,7 +185,7 @@ | |||
def list_ec2_snapshots(connection, module): | |||
|
|||
snapshot_ids = module.params.get("snapshot_ids") | |||
owner_ids = map(str, module.params.get("owner_ids")) | |||
owner_ids = module.params.get("owner_ids") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This drops running str on the owner_ids. This could have an impact if the API these are used with expect strings but an int is passed in, for instance. If the str is still needed, you can do something like:
owner_ids = [str(i) for i in module.params.get("owner_ids")]
@willthames I left one comment but I don't know the API being used so I don't know if it's needed or not. Once you know the answer to that (either it's fine the way it is or modify the code to handle that corner case), feel free to merge this in. You can also cherry-pick to stable-2.4 (or request that I do so on irc). |
Avoid the following seen when running ec2_ami tests on python3, presumably because the return type of `map` is different between python2 and python3. ``` Traceback (most recent call last): File "/tmp/ansible_e44v27uj/ansible_module_ec2_snapshot_facts.py", line 242, in <module> main() File "/tmp/ansible_e44v27uj/ansible_module_ec2_snapshot_facts.py", line 238, in main list_ec2_snapshots(connection, module) File "/tmp/ansible_e44v27uj/ansible_module_ec2_snapshot_facts.py", line 193, in list_ec2_snapshots snapshots = connection.describe_snapshots(SnapshotIds=snapshot_ids, OwnerIds=owner_ids, RestorableByUserIds=restorable_by_user_ids, Filters=filters) File "/usr/local/lib/python3.5/dist-packages/botocore/client.py", line 312, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/client.py", line 575, in _make_api_call api_params, operation_model, context=request_context) File "/usr/local/lib/python3.5/dist-packages/botocore/client.py", line 630, in _convert_to_request_dict api_params, operation_model) File "/usr/local/lib/python3.5/dist-packages/botocore/validate.py", line 291, in serialize_to_request raise ParamValidationError(report=report.generate_report()) botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter OwnerIds, value: <map object at 0x7ff577511048>, type: <class 'map'>, valid types: <class 'list'>, <class 'tuple'> ``` ansible#30435 (comment)
57c9447
to
85f04eb
Compare
@abadger, a great spot, thank you - I tested this and you were quite correct. I've updated the fix and applied a similar fix to |
Merged to devel and cherry-picked for the 2.4.1 release. |
SUMMARY
Avoid the following seen when running ec2_ami tests on python3,
presumably because the return type of
map
is different betweenpython2 and python3.
#30435 (comment)
ISSUE TYPE
COMPONENT NAME
ec2_snapshot_facts
ANSIBLE VERSION