|
1 | 1 | #
|
2 |
| -# Description: Launch a Ansible Job Template and save the job id |
3 |
| -# in the state variables so we can use it when we |
4 |
| -# wait for the job to finish. |
| 2 | +# Description: |
| 3 | +# |
| 4 | +# Launch a Ansible Job Template and save the job id |
| 5 | +# in the state variables so we can use it when we |
| 6 | +# wait for the job to finish. |
| 7 | +# |
| 8 | +# We are overriding the default job launch method becuase |
| 9 | +# of problems when the code encounters symbols instead of |
| 10 | +# extra vars. |
| 11 | +# |
| 12 | +# Related Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1647192 |
| 13 | +# |
| 14 | +# This method can be removed once the bugzilla is addressed. |
| 15 | +# |
| 16 | +# This method should be updated if the base launch_ansible_job |
| 17 | +# method in the MIQ domain is updates with CFME releases. |
| 18 | +# When updating, ensure that the string conversion is preserved, as described below. |
| 19 | +# |
| 20 | +# Updates made over base methods: |
| 21 | +# |
| 22 | +# All updates made are in the object_vars method. All keys that may be |
| 23 | +# symbols are converted to strings before string operations are used on them. |
| 24 | +# |
| 25 | +# All updates are marked with an 'Override' comment in the code |
| 26 | +# |
| 27 | +# This is a minimal diff to the default method in the manageIQ domain: |
| 28 | +# |
| 29 | +# 49c49 |
| 30 | +# < key_list = object.attributes.keys.select { |k| k.to_s.start_with?('param', 'dialog_param') } |
| 31 | +# --- |
| 32 | +# > key_list = object.attributes.keys.select { |k| k.start_with?('param', 'dialog_param') } |
| 33 | +# 51c51 |
| 34 | +# < if key.to_s.start_with?('param') |
| 35 | +# --- |
| 36 | +# > if key.start_with?('param') |
| 37 | +# 55c55 |
| 38 | +# < match_data = ANSIBLE_DIALOG_VAR_REGEX.match(key.to_s) |
| 39 | +# --- |
| 40 | +# > match_data = ANSIBLE_DIALOG_VAR_REGEX.match(key) |
| 41 | +# |
| 42 | +# |
5 | 43 | #
|
6 | 44 |
|
7 | 45 | module ManageIQ
|
@@ -46,12 +84,17 @@ def object_vars(object, ext_vars)
|
46 | 84 | # We are traversing the list twice because the object.attributes is a DrbObject
|
47 | 85 | # and when we use each_with_object on a DrbObject, it doesn't seem to update the
|
48 | 86 | # hash. We are investigating that
|
| 87 | + |
| 88 | + # Override - update method to ensure that 'start_with?' will always operate on a string |
49 | 89 | key_list = object.attributes.keys.select { |k| k.to_s.start_with?('param', 'dialog_param') }
|
50 | 90 | key_list.each_with_object(ext_vars) do |key, hash|
|
| 91 | + # Override - update method to ensure that 'start_with?' will always operate on a string |
51 | 92 | if key.to_s.start_with?('param')
|
52 | 93 | match_data = ANSIBLE_VAR_REGEX.match(object[key])
|
53 | 94 | hash[match_data[1].strip] ||= match_data[2] if match_data
|
54 | 95 | else
|
| 96 | + # Override - update method to ensure that 'match' is called |
| 97 | + # on a string |
55 | 98 | match_data = ANSIBLE_DIALOG_VAR_REGEX.match(key.to_s)
|
56 | 99 | hash[match_data[1]] = object[key] if match_data
|
57 | 100 | end
|
|
0 commit comments