From eaae992bf38db7a37919c4df58973cfd8c27895d Mon Sep 17 00:00:00 2001 From: Bill Wei Date: Mon, 17 Apr 2017 14:53:06 -0400 Subject: [PATCH 1/2] Bump ansible_tower_client to 0.12.0 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3457a34a569..114edcca2af 100644 --- a/Gemfile +++ b/Gemfile @@ -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" From e4dcf459e53438636554a4aaca4824b4118f4293 Mon Sep 17 00:00:00 2001 From: Bill Wei Date: Mon, 17 Apr 2017 14:55:07 -0400 Subject: [PATCH 2/2] Get job_plays by filtering job_events https://bugzilla.redhat.com/show_bug.cgi?id=1434961 --- .../ansible_tower/shared/automation_manager/job.rb | 6 +++--- spec/models/service_ansible_tower_spec.rb | 2 +- .../support/ansible_shared/automation_manager/job.rb | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/manageiq/providers/ansible_tower/shared/automation_manager/job.rb b/app/models/manageiq/providers/ansible_tower/shared/automation_manager/job.rb index e834fdb4e0f..82e6afb3714 100644 --- a/app/models/manageiq/providers/ansible_tower/shared/automation_manager/job.rb +++ b/app/models/manageiq/providers/ansible_tower/shared/automation_manager/job.rb @@ -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 diff --git a/spec/models/service_ansible_tower_spec.rb b/spec/models/service_ansible_tower_spec.rb index 3d95a8c4bb7..a1fa759888d 100644 --- a/spec/models/service_ansible_tower_spec.rb +++ b/spec/models/service_ansible_tower_spec.rb @@ -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 diff --git a/spec/support/ansible_shared/automation_manager/job.rb b/spec/support/ansible_shared/automation_manager/job.rb index d9650c90abc..234faf0999a 100644 --- a/spec/support/ansible_shared/automation_manager/job.rb +++ b/spec/support/ansible_shared/automation_manager/job.rb @@ -30,14 +30,14 @@ 'network_credential_id' => network_credential.manager_ref ).tap do |rjob| allow(rjob).to receive(:stdout).with('html').and_return('job stdout') - 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 @@ -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',