WIP (DIO-911) Include job_id in ABS --json output

Prior to this commit, when using --service=abs and --json the job_id
value is not included in the JSON blob, which makes it difficult for
calling code to grab both the job_id and the hosts without text
processing the log messages printed to standard error.
This commit is contained in:
Nate Wolfe 2020-08-24 14:20:28 -07:00
parent 9a44cc480e
commit cb1ea8247b
No known key found for this signature in database
GPG key ID: B2DE44E5E14C0F96
2 changed files with 9 additions and 4 deletions

View file

@ -45,6 +45,10 @@ class Utils
result = {}
# ABS has a job_id associated with hosts so pass that along
abs_job_id = response_body.delete('job_id')
result['job_id'] = abs_job_id unless abs_job_id.nil?
filtered_response_body = response_body.reject { |key, _| key == 'request_id' || key == 'ready' }
filtered_response_body.each do |os, value|
hostnames = Array(value['hostname'])
@ -57,7 +61,8 @@ class Utils
def self.format_host_output(hosts)
hosts.flat_map do |os, names|
names.map { |name| "- #{name} (#{os})" }
# Assume hosts are stored in Arrays and ignore everything else
names.map { |name| "- #{name} (#{os})" } if names.is_a? Array
end.join("\n")
end