Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch Ansible job plays from job events. #14779

Merged
merged 2 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gem "activerecord-session_store", "~>1.0.0"
gem "acts_as_list", "~>0.7.2"
gem "acts_as_tree", "~>2.1.0" # acts_as_tree needs to be required so that it loads before ancestry
gem "ancestry", "~>2.2.1", :require => false
gem "ansible_tower_client", "~>0.11.0", :require => false
gem "ansible_tower_client", "~>0.12.0", :require => false
gem "aws-sdk", "~>2", :require => false
gem "bundler", ">=1.11.1", :require => false
gem "color", "~>1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def update_credentials(raw_job)

def update_plays(raw_job)
last_play_hash = nil
plays = raw_job.job_plays.collect do |play|
plays = raw_job.job_events(:event => 'playbook_on_play_start').collect do |play|
{
:name => play.play,
:resource_status => play.failed ? 'failed' : 'successful',
:start_time => play.started,
:start_time => play.created,
:ems_ref => play.id,
:resource_category => 'job_play'
}.tap do |h|
last_play_hash[:finish_time] = play.started if last_play_hash
last_play_hash[:finish_time] = play.created if last_play_hash
last_play_hash = h
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_ansible_tower_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
:verbosity => 0,
:started => Time.current,
:finished => Time.current,
:job_plays => [],
:job_events => [],
:extra_vars_hash => {'var_name' => 'var_val'}))

job_done = service_mix_dialog_setter.launch_job
Expand Down
12 changes: 6 additions & 6 deletions spec/support/ansible_shared/automation_manager/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
'network_credential_id' => network_credential.manager_ref
).tap do |rjob|
allow(rjob).to receive(:stdout).with('html').and_return('<html><body>job stdout</body></html>')
allow(rjob).to receive(:job_plays).and_return(the_raw_plays)
allow(rjob).to receive(:job_events).with(:event => 'playbook_on_play_start').and_return(the_raw_plays)
end
end

let(:the_raw_plays) do
[
double('play1', :play => 'play1', :started => Time.current, :failed => false, :id => 1),
double('play2', :play => 'play2', :started => Time.current + 1, :failed => true, :id => 2)
double('play1', :play => 'play1', :created => Time.current, :failed => false, :id => 1),
double('play2', :play => 'play2', :created => Time.current + 1, :failed => true, :id => 2)
]
end

Expand Down Expand Up @@ -88,14 +88,14 @@
expect(subject.authentications).to match_array([machine_credential, cloud_credential, network_credential])

expect(subject.job_plays.first).to have_attributes(
:start_time => the_raw_plays.first.started,
:finish_time => the_raw_plays.last.started,
:start_time => the_raw_plays.first.created,
:finish_time => the_raw_plays.last.created,
:resource_status => 'successful',
:resource_category => 'job_play',
:name => 'play1'
)
expect(subject.job_plays.last).to have_attributes(
:start_time => the_raw_plays.last.started,
:start_time => the_raw_plays.last.created,
:finish_time => the_raw_job.finished,
:resource_status => 'failed',
:resource_category => 'job_play',
Expand Down