Resolves
https://bugzilla.redhat.com/show_bug.cgi?id=765703
---
src/app/controllers/images_controller.rb | 2 ++
src/config/locales/en.yml | 1 +
src/lib/exceptions.rb | 1 +
src/lib/image.rb | 1 +
4 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/images_controller.rb
b/src/app/controllers/images_controller.rb
index 018929c..e9fa68c 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -102,6 +102,8 @@ class ImagesController < ApplicationController
logger.error "Caught exception importing image: #{e.message}"
if e.is_a?(Aeolus::Conductor::Base::ImageNotFound)
flash[:error] = t('images.not_on_provider')
+ elsif e.is_a?(Aeolus::Conductor::Base::BlankImageId)
+ flash[:error] = t('images.import.blank_id')
else
flash[:error] = t("images.import.image_not_imported")
end
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 80bd35b..59c022b 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -691,6 +691,7 @@ en:
name: Image Name
image_imported: The image was imported successfully.
image_not_imported: The image could not be imported. Check the Image Factory log
for further details.
+ blank_id: Image ID cannot be blank.
index:
images: Images
name: Name
diff --git a/src/lib/exceptions.rb b/src/lib/exceptions.rb
index 0198c6b..c18c1e7 100644
--- a/src/lib/exceptions.rb
+++ b/src/lib/exceptions.rb
@@ -45,6 +45,7 @@ module Aeolus
module Base
class ImageNotFound < StandardError; end
+ class BlankImageId < StandardError; end
end
end
end
diff --git a/src/lib/image.rb b/src/lib/image.rb
index d2ed4c8..02bfdba 100644
--- a/src/lib/image.rb
+++ b/src/lib/image.rb
@@ -18,6 +18,7 @@ class Image
# Given a ProviderAccount and an AMI/image ID on a provider, plus an optional XML
string, use aeolus-image
# to import the image. Returns an Aeolus::Image::Factory::Image or allows exceptions to
bubble up
def self.import(provider_account, image_id, xml=nil)
+ raise Aeolus::Conductor::Base::BlankImageId unless image_id.present?
# Verify that the image exists prior to import
conn = provider_account.connect
img = conn.image(image_id) rescue nil
--
1.7.6.5