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

#destroyObject

Raises:

  • (Fog::Errors::Error)


43
44
45
# File 'lib/fog/cloudstack/models/compute/job.rb', line 43

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

#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

#saveObject

Raises:

  • (Fog::Errors::Error)


39
40
41
# File 'lib/fog/cloudstack/models/compute/job.rb', line 39

def save
  raise Fog::Errors::Error.new('Creating a job is not supported')
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