Sha256: 2259d21310524991c8cf857cd62fca196d573ea17e1a43a194117d95b0f619ba

Contents?: true

Size: 1.72 KB

Versions: 24

Compression:

Stored size: 1.72 KB

Contents

module Fog
  module Compute
    class Cloudstack
      class Job < Fog::Model
        identity  :id,              :aliases => 'jobid'
        attribute :user_id,         :aliases => 'userid'
        attribute :account_id,      :aliases => 'accountid'
        attribute :cmd
        attribute :job_status,      :aliases => 'jobstatus',     :type => :integer
        attribute :job_result_type, :aliases => 'jobresulttype'
        attribute :job_result_code, :aliases => 'jobresultcode', :type => :integer
        attribute :job_proc_status, :aliases => 'jobprocstatus', :type => :integer

        attribute :created_at,      :aliases => 'created',       :type => :time
        attribute :job_result,      :aliases => 'jobresult'

        def reload
          requires :id
          merge_attributes(service.query_async_job_result('jobid' => self.id)['queryasyncjobresultresponse'])
        end

        def ready?
          self.job_status != 0
        end

        def successful?
          self.job_result_code == 0
        end

        # so dirty
        def result
          if successful? && model = Fog::Compute::Cloudstack.constants.find{|c| c.to_s.downcase == self.job_result.keys.first.to_s}.to_s
            collection = model.gsub(/.[A-Z]/){|w| "#{w[0,1]}_#{w[1,1].downcase}"}.downcase + "s" # cheap underscorize, assume simple pluralization
            service.send(collection).new(self.job_result.values.first)
          else self.job_result
          end
        end

        def save
          raise Fog::Errors::Error.new('Creating a job is not supported')
        end

        def destroy
          raise Fog::Errors::Error.new('Destroying a job is not supported')
        end


      end # Job
    end # Cloudstack
  end # Compute
end # Fog

Version data entries

24 entries across 22 versions & 3 rubygems

Version Path
fog-2.1.0 lib/fog/cloudstack/models/compute/job.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/job.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/job.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/job.rb
fog-1.42.1 lib/fog/cloudstack/models/compute/job.rb
fog-2.0.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.42.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.41.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.40.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.39.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.38.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.37.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.36.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.35.0 lib/fog/cloudstack/models/compute/job.rb
fog-2.0.0.pre.0 lib/fog/cloudstack/models/compute/job.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudstack/models/compute/job.rb
fog-1.34.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.33.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.32.0 lib/fog/cloudstack/models/compute/job.rb
fog-1.31.0 lib/fog/cloudstack/models/compute/job.rb