[PATCH aeolus-image-rubygem] BZ 795743 - Image.import supports setting architecture

Matt Wagner matt.wagner at redhat.com
Tue Feb 28 16:33:25 UTC 2012


When Conductor imports an image, it will attempt to detect the architecture
and pass it in as an optional parameter. If set, we should set an :architecture
attribute on the Image in iwhd.

Part of https://bugzilla.redhat.com/show_bug.cgi?id=795743
---
 lib/aeolus_image/import.rb                |    6 ++++--
 lib/aeolus_image/model/warehouse/image.rb |    4 ++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/aeolus_image/import.rb b/lib/aeolus_image/import.rb
index 2e5a9d2..b0bf8e0 100644
--- a/lib/aeolus_image/import.rb
+++ b/lib/aeolus_image/import.rb
@@ -14,7 +14,7 @@
 
 module Aeolus
   module Image
-    def self.import(provider_name, deltacloud_driver, image_id, account_id, environment, xml=nil)
+    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,
@@ -26,7 +26,9 @@ module Aeolus
       # Set the provider_account_id on the image
       iwhd_image = Warehouse::Image.find(image.id)
       iwhd_image.set_attr("environment", environment)
-     # Set the account on the provider image
+      # 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
       pimg.set_attr('provider_account_identifier', account_id)
diff --git a/lib/aeolus_image/model/warehouse/image.rb b/lib/aeolus_image/model/warehouse/image.rb
index 5bbc267..ef6497f 100644
--- a/lib/aeolus_image/model/warehouse/image.rb
+++ b/lib/aeolus_image/model/warehouse/image.rb
@@ -120,6 +120,10 @@ module Aeolus
           xml.present? ? xml.xpath(path).text : ""
         end
 
+        def architecture
+          @architecture || os.arch
+        end
+
         class << self
           def by_environment(environment)
             self.where("($environment == \"" + environment + "\")")
-- 
1.7.6.5




More information about the aeolus-devel mailing list