[PATCH conductor] Prevent launching invalid deployments

tsedovic at redhat.com tsedovic at redhat.com
Mon Dec 19 16:13:52 UTC 2011


From: Tomas Sedovic <tomas at sedovic.cz>

https://bugzilla.redhat.com/show_bug.cgi?id=723686
https://bugzilla.redhat.com/show_bug.cgi?id=740907

When we detect issues with a deployment before we launch it (e.g. unknown
hardware profile or image id), this disables the Launch button to prevent the
deployment from launching.
---
 src/app/controllers/deployments_controller.rb |    9 +++++----
 src/app/stylesheets/layout.scss               |    4 +++-
 src/app/views/deployments/_overview.html.haml |    2 +-
 src/features/deployment.feature               |    6 +++---
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/app/controllers/deployments_controller.rb b/src/app/controllers/deployments_controller.rb
index 3ca38c3..8245dd1 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -70,7 +70,8 @@ class DeploymentsController < ApplicationController
 
     if @services.empty? or @services.all? {|s, a| s.parameters.empty?}
       # we can skip the launch-time parameters screen
-      check_assemblies_for_errors
+      @errors = @deployment.check_assemblies_matches(current_user)
+      set_errors_flash(@errors)
       @additional_quota = count_additional_quota(@deployment)
       render 'overview' and return
     end
@@ -86,7 +87,8 @@ class DeploymentsController < ApplicationController
 
     respond_to do |format|
       if @deployable_xml && @deployment.valid_deployable_xml?(@deployable_xml)
-        check_assemblies_for_errors
+        @errors = @deployment.check_assemblies_matches(current_user)
+        set_errors_flash(@errors)
         @additional_quota = count_additional_quota(@deployment)
 
         format.html
@@ -349,8 +351,7 @@ class DeploymentsController < ApplicationController
     @pool = @deployment.pool
   end
 
-  def check_assemblies_for_errors
-    errors = @deployment.check_assemblies_matches(current_user)
+  def set_errors_flash(errors)
     unless errors.empty?
       flash[:error] = {
           :summary => t("deployments.flash.error.not_launched"),
diff --git a/src/app/stylesheets/layout.scss b/src/app/stylesheets/layout.scss
index 15112ac..a6d5301 100644
--- a/src/app/stylesheets/layout.scss
+++ b/src/app/stylesheets/layout.scss
@@ -2453,7 +2453,7 @@ ul.instances-array{
 /********************************************* Deployable Detail page */
 /************************************************************************** */
 
-a#launch_deployment_button{
+#launch_deployment_button{
   display: inline-block;
   margin: -7px 0px 0px 10px;
   padding: 13px 12px 9px 46px;
@@ -2483,6 +2483,8 @@ a#launch_deployment_button{
     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9ecc9b', endColorstr='#458944',GradientType=0 ); /* IE6-9 */
     -webkit-box-shadow: inset 1px 1px 2px 0px #333; -moz-box-shadow: inset 1px 1px 2px 0px #333; box-shadow: inset 1px 1px 2px 0px #333;
   }
+  &[type=submit][disabled=disabled],
+  &[disabled=disabled],
   &.disabled{
     cursor: default;
     zoom: 1;
diff --git a/src/app/views/deployments/_overview.html.haml b/src/app/views/deployments/_overview.html.haml
index 6a6ba3c..72f1495 100644
--- a/src/app/views/deployments/_overview.html.haml
+++ b/src/app/views/deployments/_overview.html.haml
@@ -36,5 +36,5 @@
   #action-buttons
     = link_to t(:cancel), pool_path(@pool), :class => 'button danger', :id => 'cancel_deployment_button'
     = submit_tag t(:back), :class => 'button', :value => 'back'
-    = submit_tag t('.launch'), :class => 'button primary', :id => 'launch_deployment'
+    = submit_tag t('.launch'), :id => 'launch_deployment_button', :disabled => @errors.any?
 -# Quota checking to go here as well, once I understand how it works with new code
diff --git a/src/features/deployment.feature b/src/features/deployment.feature
index 294eb67..b58080b 100644
--- a/src/features/deployment.feature
+++ b/src/features/deployment.feature
@@ -41,7 +41,7 @@ Feature: Manage Deployments
     When I fill in "deployment_name" with "mynewdeployment"
     When I press "next_button"
     Then I should see "Are you sure you wish to deploy"
-    When I press "launch_deployment"
+    When I press "launch_deployment_button"
     Then I should see "Deployment launched"
     Then I should see "mynewdeployment Deployment"
     And I should see "mynewdeployment/frontend"
@@ -62,7 +62,7 @@ Feature: Manage Deployments
     When I fill in "deployment_name" with "mynewdeployment"
     When I press "next_button"
     Then I should see "Are you sure you wish to deploy"
-    When I press "launch_deployment"
+    When I press "launch_deployment_button"
     Then I should see "Created"
     Then I should see "mynewdeployment"
 
@@ -247,7 +247,7 @@ Feature: Manage Deployments
     When  I fill in "deployment_launch_parameters_assembly_with_launch_parameters_service_with_launch_parameters_launch_parameter_1" with "value_1"
     And   I press "submit_params"
     Then  I should see "Are you sure you wish to deploy"
-    When  I press "launch_deployment"
+    When  I press "launch_deployment_button"
     Then  I should see "launch_parameter_2 cannot be blank"
 
   Scenario: Search deployments
-- 
1.7.6.4




More information about the aeolus-devel mailing list