Class: Fog::Compute::Cloudstack::Job
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Cloudstack::Job
- Defined in:
- lib/fog/cloudstack/models/compute/job.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #ready? ⇒ Boolean
- #reload ⇒ Object
-
#result ⇒ Object
so dirty.
- #save ⇒ Object
- #successful? ⇒ Boolean
Instance Method Details
#destroy ⇒ Object
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
22 23 24 |
# File 'lib/fog/cloudstack/models/compute/job.rb', line 22 def ready? self.job_status != 0 end |
#reload ⇒ Object
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 |
#result ⇒ Object
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 |
#save ⇒ Object
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
26 27 28 |
# File 'lib/fog/cloudstack/models/compute/job.rb', line 26 def successful? self.job_result_code == 0 end |