lib/cloudstack-cli/commands/job.rb in cloudstack-cli-0.15.1 vs lib/cloudstack-cli/commands/job.rb in cloudstack-cli-1.0.0.rc1

- old
+ new

@@ -1,30 +1,32 @@ class Job < CloudstackCli::Base desc 'list', 'list async jobs' def list - jobs = client.list_jobs() + jobs = client.list_async_jobs if jobs.size < 1 say "No jobs found." else - table = [["Command", "Created", "Status", "ID", "User ID"]] + table = [%w(Command Created Status ID User-ID)] jobs.each do |job| - table << [job['cmd'].split('.')[-1], job['created'], job['jobstatus'], job['jobid'], job['userid']] + table << [ + job['cmd'].split('.')[-1], + job['created'], + job['jobstatus'], + job['jobid'], + job['userid'] + ] end print_table table end end desc 'query ID', 'query async job' def query(id) - job = client.query_job(id) - job.each do |key, value| - say "#{key} : " - if value.is_a?(Hash) - value.each {|subkey, subvalue| say " #{subkey} : #{subvalue}"} - else - say(value) - end + job = client.query_async_job_result(jobid: id) + table = job.map do |key, value| + [ set_color("#{key}:", :yellow), "#{value}" ] end + print_table table end - -end \ No newline at end of file + +end