def self.import(provider_name, deltacloud_driver, image_id, account_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!
iwhd_image = Warehouse::Image.find(image.id)
iwhd_image.set_attr("environment", environment)
iwhd_image.set_attr(:architecture, arch) if arch
pimg = iwhd_image.provider_images.first
if pimg
pimg.set_attr('provider_account_identifier', account_id)
return image
else
iwhd_image.delete!
raise "Image import failed to import provider image! Aborting."
end
end