Sha256: 846f349077e96fd2f8e2a348cdde095230ee3e06bfe33d32a6df5ed30fae4729

Contents?: true

Size: 956 Bytes

Versions: 25

Compression:

Stored size: 956 Bytes

Contents

class Job < CloudstackCli::Base

  desc 'list', 'list async jobs'
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    jobs = client.list_async_jobs
    if jobs.size < 1
      say "No jobs found."
    else
      case options[:format].to_sym
      when :yaml
        puts({jobs: jobs}.to_yaml)
      when :json
        puts JSON.pretty_generate(jobs: jobs)
      else
        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']
          ]
        end
        print_table table
      end
    end
  end

  desc 'query ID', 'query async job'
  def query(id)
    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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/job.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/job.rb