Skip to content

Commit

Permalink
Fixed adapter crypto_number property
Browse files Browse the repository at this point in the history
Details:
* The crypto_number property is an integer property, and thus the Ansible
  module needs to change the string passed by Ansible back to an integer.
  It did that only for input properties, but not for the newly introduced
  match parameter. This change applies the type conversions for all
  properties now also for the match parameter.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Jan 7, 2019
1 parent 216001f commit ce7b9ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ Released: not yet
* Updated the 'requests' package to 2.20.0 to fix the following vulnerability:
https://nvd.nist.gov/vuln/detail/CVE-2018-18074

* The `crypto_number` property of Adapter is an integer property, and thus the
Ansible module `zhmc_adapter` needs to change the string passed by Ansible
back to an integer. It did that correctly but only for the `properties`
input parameter, and not for the `match` input parameter. The type conversions
are now applied for all properties of Adapter also for the `match` parameter.

**Enhancements:**

* Docs: Improved and fixed the documentation how to release a version
Expand Down
10 changes: 9 additions & 1 deletion zhmc_ansible_modules/zhmc_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,15 @@ def identify_adapter(cpc, name, match_props):
match_props_hmc = dict()
for prop_name in match_props:
prop_name_hmc = prop_name.replace('_', '-')
match_props_hmc[prop_name_hmc] = match_props[prop_name]
match_value = match_props[prop_name]

# Apply type cast from property definition also to match values:
if prop_name in ZHMC_ADAPTER_PROPERTIES:
type_cast = ZHMC_ADAPTER_PROPERTIES[prop_name][5]
if type_cast:
match_value = type_cast(match_value)

match_props_hmc[prop_name_hmc] = match_value
adapter = cpc.adapters.find(**match_props_hmc)
return adapter

Expand Down

0 comments on commit ce7b9ba

Please sign in to comment.