Class: Fog::Compute::Cloudstack::Job

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/cloudstack/models/compute/job.rb

Instance Method Summary collapse

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/fog/cloudstack/models/compute/job.rb', line 22

def ready?
  self.job_status != 0
end

#reloadObject



17
18
19
20
# File 'lib/fog/cloudstack/models/compute/job.rb', line 17

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

#resultObject

so dirty



31
32
33
34
35
36
37
# File 'lib/fog/cloudstack/models/compute/job.rb', line 31

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

#successful?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fog/cloudstack/models/compute/job.rb', line 26

def successful?
  self.job_result_code == 0
end