Skip to content

Commit 6476cf9

Browse files
A-Beckitewk
authored andcommitted
Adding better comments and context to the launch_ansible_job method
1 parent 9ab4aaf commit 6476cf9

File tree

1 file changed

+46
-3
lines changed
  • Automate/RedHatConsulting_Utilities/AutomationManagement/AnsibleTower/Operations/StateMachines/Job.class/__methods__

1 file changed

+46
-3
lines changed

Automate/RedHatConsulting_Utilities/AutomationManagement/AnsibleTower/Operations/StateMachines/Job.class/__methods__/launch_ansible_job.rb

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
11
#
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+
#
543
#
644

745
module ManageIQ
@@ -46,12 +84,17 @@ def object_vars(object, ext_vars)
4684
# We are traversing the list twice because the object.attributes is a DrbObject
4785
# and when we use each_with_object on a DrbObject, it doesn't seem to update the
4886
# hash. We are investigating that
87+
88+
# Override - update method to ensure that 'start_with?' will always operate on a string
4989
key_list = object.attributes.keys.select { |k| k.to_s.start_with?('param', 'dialog_param') }
5090
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
5192
if key.to_s.start_with?('param')
5293
match_data = ANSIBLE_VAR_REGEX.match(object[key])
5394
hash[match_data[1].strip] ||= match_data[2] if match_data
5495
else
96+
# Override - update method to ensure that 'match' is called
97+
# on a string
5598
match_data = ANSIBLE_DIALOG_VAR_REGEX.match(key.to_s)
5699
hash[match_data[1]] = object[key] if match_data
57100
end

0 commit comments

Comments
 (0)