From: Martyn Taylor <mtaylor(a)redhat.com>
Imported Images can not be rebuilt or repushed since nothing but
the provider image actually exists when importing an existing image
(the rest of the family i.e. image, build, target image are just
place holders). It makes no sense to leave this stuff hanging around
after an imported image's target image or provider image has been
deleted by the user. Trying to rebuild or repush an imported image
will result in factory HTTP 5xx error.
Since this patch changes the imported image lifecycle, (it is now
different from the lifecycle of other images), a user should be able
to distinguish between normal and imported images. This patch also
adds "(Imported)" to show imported images on the list and show views.
---
src/app/controllers/provider_images_controller.rb | 11 ++++++++++-
src/app/controllers/target_images_controller.rb | 10 +++++++++-
src/app/views/images/_list.html.haml | 2 +-
src/app/views/images/show.html.haml | 2 +-
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/app/controllers/provider_images_controller.rb
b/src/app/controllers/provider_images_controller.rb
index c1467ca..a08f1b8 100644
--- a/src/app/controllers/provider_images_controller.rb
+++ b/src/app/controllers/provider_images_controller.rb
@@ -43,7 +43,16 @@ class ProviderImagesController < ApplicationController
if image = Aeolus::Image::Warehouse::ProviderImage.find(params[:id])
target_id = image.target_identifier
provider = image.provider
- if image.delete!
+
+ if image.target_image.build.image.imported?
+ if image.target_image.build.image.delete!
+ flash[:notice] = t('images.flash.notice.deleted')
+ redirect_to images_path
+ return
+ else
+ flash[:warning] = t('images.flash.warning.delete_failed')
+ end
+ elsif image.delete!
flash[:notice] = t('provider_images.flash.notice.deleted',
:target_id => target_id, :provider => provider)
else
diff --git a/src/app/controllers/target_images_controller.rb
b/src/app/controllers/target_images_controller.rb
index c9f3b4f..cf65d57 100644
--- a/src/app/controllers/target_images_controller.rb
+++ b/src/app/controllers/target_images_controller.rb
@@ -38,7 +38,15 @@ class TargetImagesController < ApplicationController
def destroy
if image = Aeolus::Image::Warehouse::TargetImage.find(params[:id])
- if image.delete!
+ if image.build.image.imported?
+ if image.build.image.delete!
+ flash[:notice] = t('images.flash.notice.deleted')
+ redirect_to images_path
+ return
+ else
+ flash[:warning] = t('images.flash.warning.delete_failed')
+ end
+ elsif image.delete!
flash[:notice] = t('target_images.flash.notice.deleted')
else
flash[:warning] = t('target_images.flash.warning.delete_failed')
diff --git a/src/app/views/images/_list.html.haml b/src/app/views/images/_list.html.haml
index 0013f1a..d75ea59 100644
--- a/src/app/views/images/_list.html.haml
+++ b/src/app/views/images/_list.html.haml
@@ -11,7 +11,7 @@
- selected = params[:select] == 'all'
= check_box_tag "images_selected[]", image.id, selected, :id =>
"image_checkbox_#{image.id}"
%td
- = link_to image.name, image_path(image.id)
+ = link_to (image.imported? ? image.name + " (Imported)" : image.name),
image_path(image.id)
%td
= image.os.name.empty? ? "N/A" : image.os.name
%td
diff --git a/src/app/views/images/show.html.haml b/src/app/views/images/show.html.haml
index 4405deb..bff6284 100644
--- a/src/app/views/images/show.html.haml
+++ b/src/app/views/images/show.html.haml
@@ -1,6 +1,6 @@
= render :partial => 'layouts/admin_nav'
%header.admin-page-header
- %h1{:class => controller.controller_name}= @image.name
+ %h1{:class => controller.controller_name}= @image.imported? ? @image.name + "
(Imported)" : @image.name
#obj_actions.button-container.images
=t'return_to'
= link_to t('images.index.images'), images_path, :class =>
'rounded-link'
--
1.7.6.4
Show replies by date