Skip to content

Commit

Permalink
Merge pull request #14496 from bzwei/stdout_format
Browse files Browse the repository at this point in the history
Accept a format parameter to get stdout
  • Loading branch information
gmcculloug authored Mar 27, 2017
2 parents e788b2b + 30af212 commit ddfc437
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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.9.0", :require => false
gem "ansible_tower_client", "~>0.10.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 @@ -134,9 +134,9 @@ def raw_status
raise MiqException::MiqOrchestrationStatusError, err.to_s, err.backtrace
end

def raw_stdout
def raw_stdout(format = 'txt')
ext_management_system.with_provider_connection do |connection|
connection.api.jobs.find(ems_ref).stdout
connection.api.jobs.find(ems_ref).stdout(format)
end
rescue AnsibleTowerClient::ResourceNotFoundError
msg = "AnsibleTower Job #{name} with id(#{id}) does not exist on #{ext_management_system.name}"
Expand Down
6 changes: 3 additions & 3 deletions spec/support/ansible_shared/automation_manager/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'cloud_credential_id' => cloud_credential.manager_ref,
'network_credential_id' => network_credential.manager_ref
).tap do |rjob|
allow(rjob).to receive(:stdout).and_return('job stdout')
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)
end
end
Expand Down Expand Up @@ -145,12 +145,12 @@
end

it 'gets the standard output of the job' do
expect(subject.raw_stdout).to eq('job stdout')
expect(subject.raw_stdout('html')).to eq('<html><body>job stdout</body></html>')
end

it 'catches errors from provider' do
expect(connection.api.jobs).to receive(:find).and_raise("bad happened")
expect { subject.raw_stdout }.to raise_error(MiqException::MiqOrchestrationStatusError)
expect { subject.raw_stdout('html') }.to raise_error(MiqException::MiqOrchestrationStatusError)
end
end
end

0 comments on commit ddfc437

Please sign in to comment.