[PATCH aeolus-image-rubygem] Image.import deletes Image if ProviderImage is absent

Matt Wagner matt.wagner at redhat.com
Mon Feb 27 17:51:43 UTC 2012


This is an apparent error condition in which the Image serves no value.

Part of https://bugzilla.redhat.com/show_bug.cgi?id=761279
---
 lib/aeolus_image/import.rb |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/aeolus_image/import.rb b/lib/aeolus_image/import.rb
index b0bf8e0..d227bc9 100644
--- a/lib/aeolus_image/import.rb
+++ b/lib/aeolus_image/import.rb
@@ -31,8 +31,14 @@ module Aeolus
       # 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)
-      image
+      # Check that we have provider images! If not, the import has failed.
+      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
   end
 end
-- 
1.7.6.5




More information about the aeolus-devel mailing list