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

[WIP] [FINE] Change raw_stdout method to fix displaying details of active ansible services #17584

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,25 @@ def raw_status
raise MiqException::MiqOrchestrationStatusError, err.to_s, err.backtrace
end

def raw_stdout(format = 'txt')
ext_management_system.with_provider_connection do |connection|
connection.api.jobs.find(ems_ref).stdout(format)
# Intend to be called by UI to display stdout. Therefore the error message directly returned
# instead of raising an exception.
def raw_stdout_via_worker(userid = User.current_user, format = 'txt')
unless MiqRegion.my_region.role_active?("embedded_ansible")
return "Cannot get standard output of this playbook because the embedded Ansible role is not enabled"
end
rescue AnsibleTowerClient::ResourceNotFoundError
msg = "AnsibleTower Job #{name} with id(#{id}) does not exist on #{ext_management_system.name}"
raise MiqException::MiqOrchestrationStackNotExistError, msg
rescue => err
_log.error "Reading AnsibleTower Job #{name} with id(#{id}) stdout failed with error: #{err}"
raise MiqException::MiqOrchestrationStatusError, err.to_s, err.backtrace
end

options = {:userid => userid, :action => 'ansible_stdout'}
queue_options = {:class_name => self.class,
:method_name => 'raw_stdout',
:instance_id => id,
:args => [format],
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'embedded_ansible'}
taskid = MiqTask.generic_action_with_callback(options, queue_options)
MiqTask.wait_for_taskid(taskid)
miq_task = MiqTask.find(taskid)
results = miq_task.task_results || miq_task.message
miq_task.destroy
results
end
end