From: Jan Provaznik jprovazn@redhat.com
You can build images from 'Builds' tab now --- .../controllers/image_factory/builds_controller.rb | 51 +++--------------- src/app/views/image_factory/builds/new.haml | 55 -------------------- src/app/views/image_factory/templates/_builds.haml | 2 +- .../views/image_factory/templates/_properties.haml | 1 - src/features/template.feature | 24 ++------- 5 files changed, 13 insertions(+), 120 deletions(-) delete mode 100644 src/app/views/image_factory/builds/new.haml
diff --git a/src/app/controllers/image_factory/builds_controller.rb b/src/app/controllers/image_factory/builds_controller.rb index 9c649ef..b6efe81 100644 --- a/src/app/controllers/image_factory/builds_controller.rb +++ b/src/app/controllers/image_factory/builds_controller.rb @@ -1,49 +1,21 @@ class ImageFactory::BuildsController < ApplicationController before_filter [:require_user], :except => [:update_status]
- def new - raise "select template to build" unless id = params[:template_id] - @tpl = Template.find(id) - check_permission - if @tpl.imported - flash[:warning] = "Build imported template is not supported" - redirect_to image_factory_templates_path - end - @all_targets = ProviderType.all(:conditions => {:build_supported => true}) - end - def create @tpl = Template.find(params[:template_id]) check_permission - @all_targets = ProviderType.all(:conditions => {:build_supported => true}) - - if params[:targets].blank? - flash.now[:warning] = 'You need to check at least one provider format' - render :action => 'new' - return - end
errors = {} warnings = [] - params[:targets].each do |target_id| - begin - target = ProviderType.find(target_id) - Image.create_and_build!(@tpl, target) - rescue ImageExistsError - warnings << $!.message - rescue - errors[target ? target.name : target_id] = $!.message - logger.error $!.message - logger.error $!.backtrace.join("\n ") - end - end - flash[:warning] = 'Warning: ' + warnings.join unless warnings.empty? - if errors.empty? - redirect_to image_factory_template_path(@tpl, :details_tab => 'builds') - else - flash_error('Error while trying to build image', errors) - render :action => 'new' + begin + target = ProviderType.find(params[:target]) + Image.create_and_build!(@tpl, target) + rescue + flash[:error] = "Warning: #{$!.message}" + logger.error $!.message + logger.error $!.backtrace.join("\n ") end + redirect_to image_factory_template_path(@tpl, :details_tab => 'builds') end
def upload @@ -96,13 +68,6 @@ class ImageFactory::BuildsController < ApplicationController "#{@order_field} #{@order_dir}" end
- def flash_error(summary, errs) - flash.now[:error] ||= {} - flash.now[:error][:summary] = summary - flash.now[:error][:failures] ||= {} - flash.now[:error][:failures].merge!(errs) - end - def check_permission require_privilege(Privilege::MODIFY, @tpl) end diff --git a/src/app/views/image_factory/builds/new.haml b/src/app/views/image_factory/builds/new.haml deleted file mode 100644 index cf17e88..0000000 --- a/src/app/views/image_factory/builds/new.haml +++ /dev/null @@ -1,55 +0,0 @@ -%h2 Build Request -- form_tag :action => 'create' do - = hidden_field_tag :template_id, @tpl.id - %h3 Deployment Definition - %fieldset.clearfix - = label_tag :deploy_name, 'Deployment Definition Name:', :class => 'grid_4' - = text_field_tag 'deploy_name', 'Deployment Name', :disabled => true, :class => 'grid_3' - = text_field_tag 'deploy_description', 'Deployment Description', :disabled => true, :class => 'grid_3' - %fieldset.clearfix - .prefix_4.grid_6 - = check_box_tag 'use_for_machine', 1, true, :disabled => true - = label_tag 'use_for_machine', 'Use for Machine Definition Name and Description' - %fieldset.clearfix - .grid_7 - = file_field :templates, :choose_logo, :value => 'Choose Logo', :disabled => true - = text_field :templates, :logo_text, :value => 'Logo Text (5 characters)', :disabled => true, :class => "grid_3" - - %fieldset.clearfix - %label.grid_4{:for => :template_group} - Template Category: - .grid_3 - = select_tag(:template_group, options_for_select([['User Private', 1]])) - - %h3 Deployment Options - %fieldset.clearfix - .grid_6 - %label OS: - = @tpl.platform - .grid_3 - Hardware Profile - .grid_3.suffix_3 - Locale - %fieldset.clearfix - .grid_3 - %label OS Version: - = @tpl.platform_version - .grid_3.ra - %label Global Settings: - .grid_3 - Small - .grid_3 - Any - .grid_3 - = submit_tag "Config", :name => "config", :disabled => true - %h3 Build Options - %label Choose Provider Format: - %section.clearfix.gap - %ul.block - - @all_targets.each do |target| - %li - = check_box_tag 'targets[]', target.id, false, :id => target.name - = label_tag target.name - - = submit_tag "Submit to Build", :name => "build" - = link_to 'Cancel', image_factory_templates_path, :class => 'button' diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml index ae20651..00620e1 100644 --- a/src/app/views/image_factory/templates/_builds.haml +++ b/src/app/views/image_factory/templates/_builds.haml @@ -7,7 +7,7 @@ Builds for - form_tag(image_factory_builds_path, { :action => 'create', :method => :post }) do = hidden_field_tag :template_id, @tpl.id New Build for - = select( "targets", "", options_for_select(@targets_not_built)) + = select_tag 'target', options_for_select(@targets_not_built) = submit_tag "Go", :name => "build"
- form_tag do diff --git a/src/app/views/image_factory/templates/_properties.haml b/src/app/views/image_factory/templates/_properties.haml index e8bf757..0fe33ae 100644 --- a/src/app/views/image_factory/templates/_properties.haml +++ b/src/app/views/image_factory/templates/_properties.haml @@ -2,4 +2,3 @@ Properties for = @tpl.name = link_to "Edit", edit_image_factory_template_path(@tpl), { :class => 'button' } -= link_to "Build", new_image_factory_build_path(:template_id => @tpl.id), { :class => 'button' } diff --git a/src/features/template.feature b/src/features/template.feature index acdf337..4ed55b5 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -129,28 +129,12 @@ Feature: Manage Templates And there is Amazon AWS provider account And I am on the image factory templates page When I choose this template - And I follow "Build" - Then I should be on the new image factory build page - And I should see "Build Request" - When I check "Amazon EC2" - And I press "Submit to Build" - Then I should be on the image factory template page - And I should see "mock1" - - Scenario: Build template which is already built - Given there is a "mock1" template - And I am on the image factory templates page - And there is Amazon AWS build and push for this template - And I am on the image factory templates page - When I choose this template - And I follow "Build" - Then I should be on the new image factory build page - And I should see "Build Request" - When I check "Amazon EC2" - And I press "Submit to Build" + And I follow "Builds" + Then I should see "Builds for" + When I select "Amazon EC2" from "target" + And I press "Go" Then I should be on the image factory template page And I should see "mock1" - And I should see "An attempted build of this template for the target 'Amazon EC2' already exists"
Scenario: Upload image Given there is a "mock1" template
From: Jan Provaznik jprovazn@redhat.com
Disabled build for imported images --- src/app/views/image_factory/templates/_builds.haml | 29 +++++++++---------- src/features/template.feature | 6 ++-- src/spec/controllers/builds_controller_spec.rb | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml index 00620e1..65cbc5a 100644 --- a/src/app/views/image_factory/templates/_builds.haml +++ b/src/app/views/image_factory/templates/_builds.haml @@ -3,17 +3,15 @@ Builds for = @tpl.platform_version , template "#{@tpl.name}"
-- if @targets_not_built.count > 0 then - - form_tag(image_factory_builds_path, { :action => 'create', :method => :post }) do - = hidden_field_tag :template_id, @tpl.id - New Build for - = select_tag 'target', options_for_select(@targets_not_built) - = submit_tag "Go", :name => "build" - -- form_tag do +- form_tag image_factory_builds_path do = hidden_field_tag :template_id, @tpl.id - /= restful_submit_tag "Upload", 'upload', upload_image_factory_builds_path, 'POST' - /= restful_submit_tag "Delete", 'delete', delete_image_factory_builds_path, 'DELETE' + - if @targets_not_built.count > 0 then + - if @tpl.imported + Build imported template is not supported + - else + New Build for + = select_tag 'target', options_for_select(@targets_not_built) + = submit_tag "Go", :name => "build"
%ul - if @images.empty? @@ -27,8 +25,9 @@ Builds for - img.provider_images.each do |pimg| %li = "#{pimg.provider.name}: #{pimg.status}" - - img.not_uploaded_providers.each do |provider| - %li - = "#{provider.name}: " - not uploaded - = link_to 'upload', upload_image_factory_builds_path(:template_id => @tpl.id, :image_id => img.id, :provider_id => provider.id), {:class => 'button'} + - unless @tpl.imported + - img.not_uploaded_providers.each do |provider| + %li + = "#{provider.name}: " + not uploaded + = link_to 'upload', upload_image_factory_builds_path(:template_id => @tpl.id, :image_id => img.id, :provider_id => provider.id), {:class => 'button'} diff --git a/src/features/template.feature b/src/features/template.feature index 4ed55b5..3ffea33 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -152,11 +152,11 @@ Feature: Manage Templates
Scenario: Build imported template Given there is an imported template + And there is Amazon AWS provider account And I am on the image factory templates page When I choose this template - And I follow "Build" - Then I should be on the image factory templates page - And I should see "Build imported template is not supported" + And I follow "Builds" + Then I should see "Build imported template is not supported"
Scenario: Search for templates Given there are these templates: diff --git a/src/spec/controllers/builds_controller_spec.rb b/src/spec/controllers/builds_controller_spec.rb index 0024592..a3d7f4d 100644 --- a/src/spec/controllers/builds_controller_spec.rb +++ b/src/spec/controllers/builds_controller_spec.rb @@ -50,7 +50,7 @@ describe ImageFactory::BuildsController do
it "should create a new Image" do lambda do - post :create, :template_id => @template.id, :targets => [ProviderType.find_by_codename("mock").id] + post :create, :template_id => @template.id, :target => ProviderType.find_by_codename("mock").id end.should change(Image, :count).by(1) end end
Ack to this series,
Thanks mate
----- Original Message ----- From: jprovazn@redhat.com To: aeolus-devel@lists.fedorahosted.org Sent: Thursday, 31 March, 2011 1:13:35 PM Subject: [PATCH conductor 2/2] Fixed template builds tab
From: Jan Provaznik jprovazn@redhat.com
Disabled build for imported images --- src/app/views/image_factory/templates/_builds.haml | 29 +++++++++---------- src/features/template.feature | 6 ++-- src/spec/controllers/builds_controller_spec.rb | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/src/app/views/image_factory/templates/_builds.haml b/src/app/views/image_factory/templates/_builds.haml index 00620e1..65cbc5a 100644 --- a/src/app/views/image_factory/templates/_builds.haml +++ b/src/app/views/image_factory/templates/_builds.haml @@ -3,17 +3,15 @@ Builds for = @tpl.platform_version , template "#{@tpl.name}"
-- if @targets_not_built.count > 0 then - - form_tag(image_factory_builds_path, { :action => 'create', :method => :post }) do - = hidden_field_tag :template_id, @tpl.id - New Build for - = select_tag 'target', options_for_select(@targets_not_built) - = submit_tag "Go", :name => "build" - -- form_tag do +- form_tag image_factory_builds_path do = hidden_field_tag :template_id, @tpl.id - /= restful_submit_tag "Upload", 'upload', upload_image_factory_builds_path, 'POST' - /= restful_submit_tag "Delete", 'delete', delete_image_factory_builds_path, 'DELETE' + - if @targets_not_built.count > 0 then + - if @tpl.imported + Build imported template is not supported + - else + New Build for + = select_tag 'target', options_for_select(@targets_not_built) + = submit_tag "Go", :name => "build"
%ul - if @images.empty? @@ -27,8 +25,9 @@ Builds for - img.provider_images.each do |pimg| %li = "#{pimg.provider.name}: #{pimg.status}" - - img.not_uploaded_providers.each do |provider| - %li - = "#{provider.name}: " - not uploaded - = link_to 'upload', upload_image_factory_builds_path(:template_id => @tpl.id, :image_id => img.id, :provider_id => provider.id), {:class => 'button'} + - unless @tpl.imported + - img.not_uploaded_providers.each do |provider| + %li + = "#{provider.name}: " + not uploaded + = link_to 'upload', upload_image_factory_builds_path(:template_id => @tpl.id, :image_id => img.id, :provider_id => provider.id), {:class => 'button'} diff --git a/src/features/template.feature b/src/features/template.feature index 4ed55b5..3ffea33 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -152,11 +152,11 @@ Feature: Manage Templates
Scenario: Build imported template Given there is an imported template + And there is Amazon AWS provider account And I am on the image factory templates page When I choose this template - And I follow "Build" - Then I should be on the image factory templates page - And I should see "Build imported template is not supported" + And I follow "Builds" + Then I should see "Build imported template is not supported"
Scenario: Search for templates Given there are these templates: diff --git a/src/spec/controllers/builds_controller_spec.rb b/src/spec/controllers/builds_controller_spec.rb index 0024592..a3d7f4d 100644 --- a/src/spec/controllers/builds_controller_spec.rb +++ b/src/spec/controllers/builds_controller_spec.rb @@ -50,7 +50,7 @@ describe ImageFactory::BuildsController do
it "should create a new Image" do lambda do - post :create, :template_id => @template.id, :targets => [ProviderType.find_by_codename("mock").id] + post :create, :template_id => @template.id, :target => ProviderType.find_by_codename("mock").id end.should change(Image, :count).by(1) end end
aeolus-devel@lists.fedorahosted.org