Code like this:
if cond1 and cond2:
pass
elif cond1:
pass
Has a hidden dependency on the order that the conditions are checked.
This makes them fragile and subject to breakage during refactors.
Rewrite the code like this:
if cond1:
if cond2:
pass
else:
pass
The nested structure makes the ordering explicit and less likely for
someone to break the code when they refactor.
* Add os_keystone_service_endpoint
This patch adds a new Ansible module which allows a user to create
an endpoint to a service with Keystone.
Fixes#23909
* os_keystone_endpoint: Fix style and messages
Fix comments, pep8, version, metadata, license header
and imports according to the Contributing Modules Checklist
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Fix return values
- Change type of 'endpoint' return value from dictionary to complex
in order to get validate_module checks passed.
- Remove 'id' from the return data since it is included inside the
'endpoint' value wich is already being returned.
- Rename 'service' field to 'service_id' which is the correct name
for the service id field returned in json.
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Update shade version
Update minimum shade version to 1.11.0
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Make region optional
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Validate service exists before using service.id
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Fix documentation for service to accept name or id
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Pass the full service object to create_endpoint()
We already have the service object retrieved in code, by passing service.id to
create_endpoint, the shade librarie queries the api again to get the full service
object.
By Passing the already rerieved service object to create_endpoint() we save one
request to the API.
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* os_keystone_endpoint: Make type explicit in module arguments.
Althoug type is default to str when not specified in module arguments
this commit explicitly defines type='str' for better readability.
Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
* Fix fact failures cause by ordering of collectors
Some fact collectors need info collected by other facts.
(for ex, service_mgr needs to know 'ansible_system').
This info is passed to the Collector.collect method via
the 'collected_facts' info.
But, the order the fact collectors were running in is
not a set order, so collectors like service_mgr could
run before the PlatformFactCollect ('ansible_system', etc),
so the 'ansible_system' fact would not exist yet.
Depending on the collector and the deps, this can result
in incorrect behavior and wrong or missing facts.
To make the ordering of the collectors more consistent
and predictable, the code that builds that list is now
driven by the order of collectors in default_collectors.py,
and the rest of the code tries to preserve it.
* Flip the loops when building collector names
iterate over the ordered default_collectors list
selecting them for the final list in order instead
of driving it from the unordered collector_names set.
This lets the list returned by select_collector_classes
to stay in the same order as default_collectors.collectors
For collectors that have implicit deps on other fact collectors,
the default collectors can be ordered to include those early.
* default_collectors.py now uses a handful of sub lists of
collectors that can be ordered in default_collectors.collectors.
fixes#30753fixes#30623
* Return correct changed status when EIP is reused
When reusing an existing EIP, the changed status
should be False, not True.
* If public_ip is given and it exists, return it
Ensure EIP allocation returns existing public_ip correctly
* Added ecs_taskdefinition_facts module
* Expanding documentation
Now includes all possible return values
* Fixed boto dependency
* Converting results to snake case.
* Remove EcsTaskManager class, move to main()
Remove unnecessary `except` block
* Change botocore import method
Also make Profile exception message less redundant
* Changing case conversion of the results
Now converts only the root level keys
Commented is a version that would not convert only container_definitions
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'>
```
https://github.com/ansible/ansible/pull/30435#issuecomment-330750498
* fixed ansible/git invocation options
now falls back to using localhost as 'all' does not include implicit accidentally anymore
fixes#30636
* better fix
* qfq9
* Save the serialized values instead of their types
* Add tests for creating and modifying VMs without using a template
* Remove blank line
* Add tests for vm deletion
* Update playbooks_blocks.rst
The rescue section documentation should be clear that successful completion of a rescue section will override other error handling behavior.
* more precise rescue docs
explains in detail the consequences of successful rescue
In python2 str gives byte string. In Python3 it gives unicode string so it
can't be written in a binary mode opened file.
Use to_bytes helper function to ensure content being written will be
properly encoded in both python2 and python3.