Skip to content

Commit

Permalink
Merge pull request ManageIQ#19232 from Fryguy/fix_embedded_ansible_ui…
Browse files Browse the repository at this point in the history
…_issues

Fixes multiple issues with job show page
  • Loading branch information
bdunne authored Aug 30, 2019
2 parents e2b3257 + b065c9c commit 521b41c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def self.create_stack(template, options = {})
template_ref = template.new_record? ? nil : template
new(:name => template.name,
:ext_management_system => template.manager,
:verbosity => template.variables["verbosity"].to_i,
:authentications => collect_authentications(template.manager, options),
:job_template => template_ref).tap do |stack|
stack.send(:update_with_provider_object, raw_create_stack(template, options))
end
Expand Down Expand Up @@ -97,6 +99,17 @@ def self.reconcile_extra_vars_keys(_template, options)
end
private_class_method :reconcile_extra_vars_keys

def self.collect_authentications(manager, options)
credential_ids = options.values_at(
:credential,
:cloud_credential,
:network_credential,
:vault_credential
).compact
manager.credentials.where(:id => credential_ids)
end
private_class_method :collect_authentications

def update_with_provider_object(raw_job)
self.miq_task ||= raw_job.miq_task

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@
end

context "#refresh_ems" do
subject { described_class.create_job(template, {}) }
subject { described_class.create_job(template, job_options) }

let(:job_options) do
{
:credential => machine_credential.id,
:cloud_credential => cloud_credential.id,
:network_credential => network_credential.id,
:vault_credential => vault_credential.id
}
end

it "syncs the job with the provider" do
subject.refresh_ems
Expand All @@ -82,22 +91,22 @@
:status => subject.miq_task.state,
:start_time => subject.miq_task.started_on,
:finish_time => nil,
:verbosity => nil # TODO: Implement this as an job options, right?
:verbosity => 0
)
subject.reload
expect(subject.ems_ref).to eq(subject.miq_task.id.to_s)
expect(subject.status).to eq(subject.miq_task.state)

expect(subject.authentications).to match_array([machine_credential, vault_credential, cloud_credential, network_credential])

# TODO/FIXME: This needs to be implemented.
#
# The following are implemented in AnsibleTower::Job but not here:
#
# - update_parameters
# - update_credentials
# - update_plays
#
# expect(subject.parameters.first).to have_attributes(:name => "param1", :value => "val1")
# expect(subject.authentications).to match_array([machine_credential, vault_credential, cloud_credential, network_credential])
# expect(subject.job_plays.first).to have_attributes(
# :start_time => a_value_within(1.second).of(the_raw_plays.first.created),
# :finish_time => a_value_within(1.second).of(the_raw_plays.last.created),
Expand Down

0 comments on commit 521b41c

Please sign in to comment.