Module: Aeolus::Image

Defined in:
lib/aeolus_image/import.rb,
lib/aeolus_image/model/factory/base.rb,
lib/aeolus_image/model/factory/build.rb,
lib/aeolus_image/model/factory/image.rb,
lib/aeolus_image/model/factory/builder.rb,
lib/aeolus_image/model/warehouse/image.rb,
lib/aeolus_image/model/warehouse/icicle.rb,
lib/aeolus_image/model/warehouse/template.rb,
lib/aeolus_image/model/factory/target_image.rb,
lib/aeolus_image/model/warehouse/image_build.rb,
lib/aeolus_image/model/factory/provider_image.rb,
lib/aeolus_image/model/warehouse/target_image.rb,
lib/aeolus_image/model/warehouse/provider_image.rb,
lib/aeolus_image/model/warehouse/warehouse_model.rb,
lib/aeolus_image/model/warehouse/warehouse_client.rb

Defined Under Namespace

Modules: Factory, Warehouse

Class Method Summary collapse

Class Method Details

.import(provider_name, deltacloud_driver, image_id, account_id, environment, xml = nil, arch = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/aeolus_image/import.rb', line 17

def self.import(provider_name, deltacloud_driver, image_id, , environment, xml=nil, arch=nil)
  xml ||= "<image><name>#{image_id}</name></image>"
  image = Factory::Image.new(
    :target_name => deltacloud_driver,
    :provider_name => provider_name,
    :target_identifier => image_id,
    :image_descriptor => xml
  )
  image.save!
  # Set the provider_account_id on the image
  iwhd_image = Warehouse::Image.find(image.id)
  iwhd_image.set_attr("environment", environment)
  # For imported images, stash an :architecture flag on the image itself since we have no template
  iwhd_image.set_attr(:architecture, arch) if arch
  # Set the account on the provider image
  # This assumes (as is currently correct) that there will only be one provider image for imported images
  pimg = iwhd_image.provider_images.first
  # Check that we have provider images! If not, the import has failed.
  if pimg
    pimg.set_attr('provider_account_identifier', )
    return image
  else
    iwhd_image.delete!
    raise "Image import failed to import provider image! Aborting."
  end
end