Class: Aeolus::Image::Warehouse::TargetImage

Inherits:
WarehouseModel show all
Defined in:
lib/aeolus_image/model/warehouse/target_image.rb

Instance Attribute Summary

Attributes inherited from WarehouseModel

#body

Instance Method Summary collapse

Methods inherited from WarehouseModel

#==, all, #bucket_object, bucket_objects, config, config=, create!, delete, find, first, #id, #initialize, iwhd_url, last, oauth_consumer_key, oauth_consumer_secret, #set_attr, set_warehouse_and_bucket, use_oauth?, where

Constructor Details

This class inherits a constructor from Aeolus::Image::Warehouse::WarehouseModel

Instance Method Details

#buildObject



21
22
23
# File 'lib/aeolus_image/model/warehouse/target_image.rb', line 21

def build
  ImageBuild.find(@build) if @build
end

#delete!Object

Deletes this targetimage and all child objects



34
35
36
37
38
39
40
41
42
# File 'lib/aeolus_image/model/warehouse/target_image.rb', line 34

def delete!
  begin
    provider_images.each do |pi|
      pi.delete!
    end
  rescue NoMethodError
  end
  TargetImage.delete(@uuid)
end

#find_provider_image_by_provider_and_account(provider, provider_account) ⇒ Object



44
45
46
47
48
49
# File 'lib/aeolus_image/model/warehouse/target_image.rb', line 44

def (provider, )
  conditions = ["$target_image == \"#{@uuid}\""]
  conditions << "$provider == \"#{provider}\"" if provider
  conditions << "$provider_account_identifier == \"#{}\"" if 
  ProviderImage.where('(' + conditions.join(' && ') + ')')
end

#provider_imagesObject



25
26
27
# File 'lib/aeolus_image/model/warehouse/target_image.rb', line 25

def provider_images
  ProviderImage.where("($target_image == \"" + @uuid.to_s + "\")")
end

#target_templateObject



29
30
31
# File 'lib/aeolus_image/model/warehouse/target_image.rb', line 29

def target_template
  Template.find(@template) if @template
end