Class: Job

Inherits:
CloudstackCli::Base show all
Defined in:
lib/cloudstack-cli/commands/job.rb

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #get_async_job_status, #print_options, #watch_jobs

Instance Method Details

#listObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cloudstack-cli/commands/job.rb', line 4

def list
  jobs = client.list_jobs()
  if jobs.size < 1
    say "No jobs found."
  else
    table = [["Command", "Created", "Status", "ID", "User ID"]]
    jobs.each do |job|
      table << [job['cmd'].split('.')[-1], job['created'], job['jobstatus'], job['jobid'], job['userid']]
    end
    print_table table
  end
end

#query(id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cloudstack-cli/commands/job.rb', line 18

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
  end
end