Implements
https://www.aeolusproject.org/redmine/issues/1605
---
src/app/controllers/deployments_controller.rb | 45 ++++++++++++++-
src/app/models/deployment.rb | 1 -
src/app/views/deployments/_filter_view.haml | 2 +-
src/app/views/deployments/_launch_new.haml | 38 +++++++++++--
src/app/views/deployments/_legacy_launch_new.haml | 8 +++
src/app/views/deployments/_legacy_new.haml | 25 +++++++++
src/app/views/deployments/_list.haml | 2 +-
src/app/views/deployments/_new.haml | 58 ++++++++++++--------
src/app/views/deployments/index.haml | 3 +-
src/app/views/deployments/legacy_launch_new.haml | 1 +
src/app/views/deployments/legacy_new.haml | 1 +
src/app/views/deployments/show.haml | 6 +--
src/app/views/legacy_deployables/_properties.haml | 2 +-
src/app/views/pools/_header_show.haml | 2 +-
src/config/locales/en.yml | 1 +
src/config/routes.rb | 3 +-
..._null_constraint_on_deployment_deployable_id.rb | 9 +++
src/features/authentication.feature | 6 +-
src/features/deployment.feature | 9 ++--
src/features/instance.feature | 2 +-
src/features/legacy_deployable.feature | 2 +-
21 files changed, 172 insertions(+), 54 deletions(-)
create mode 100644 src/app/views/deployments/_legacy_launch_new.haml
create mode 100644 src/app/views/deployments/_legacy_new.haml
create mode 100644 src/app/views/deployments/legacy_launch_new.haml
create mode 100644 src/app/views/deployments/legacy_new.haml
create mode 100644
src/db/migrate/20110603204130_remove_not_null_constraint_on_deployment_deployable_id.rb
diff --git a/src/app/controllers/deployments_controller.rb
b/src/app/controllers/deployments_controller.rb
index 900fe44..39b36d0 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -3,6 +3,8 @@ class DeploymentsController < ApplicationController
before_filter :load_deployments, :only => [:index, :show]
before_filter :load_deployment, :only => [:edit, :update]
+ layout 'application'
+
def index
save_breadcrumb(deployments_path(:viewstate => @viewstate ? @viewstate.id : nil))
respond_to do |format|
@@ -12,20 +14,47 @@ class DeploymentsController < ApplicationController
end
end
+ # It is expected that params[:pool_id] will be set on requests into this method
def launch_new
+ require_privilege(Privilege::CREATE, Deployment)
+ @pool = Pool.find(params[:pool_id]) or raise "Invalid pool"
+ @deployment = Deployment.new(:pool_id => @pool.id)
+ respond_to do |format|
+ format.js { render :partial => 'launch_new' }
+ format.html
+ format.json { render :json => @deployment }
+ end
+ end
+
+ # TODO - 03may2011 - This is going away
+ def legacy_launch_new
@launchable_deployables = []
LegacyDeployable.all.each do |deployable|
@launchable_deployables << deployable if deployable.launchable?
end
respond_to do |format|
- format.js { render :partial => 'launch_new' }
+ format.js { render :partial => 'legacy_launch_new' }
format.html
format.json { render :json => @launchable_deployables }
end
end
+ # launch_new will post here, but you can use this RESTfully as well
def new
require_privilege(Privilege::CREATE, Deployment)
+ @deployment = Deployment.new(params[:deployment])
+ @pool = @deployment.pool
+ @deployment.import_xml_from_url(params[:deployable][:url]) if params[:deployable]
&& params[:deployable][:url]
+ respond_to do |format|
+ format.js { render :partial => 'new' }
+ format.html
+ format.json { render :json => @deployment }
+ end
+ end
+
+ # TODO - 03may2011 - This is going away
+ def legacy_new
+ require_privilege(Privilege::CREATE, Deployment)
@deployment = Deployment.new(:legacy_deployable_id =>
params[:legacy_deployable_id])
respond_to do |format|
if @deployment.legacy_deployable.legacy_assemblies.empty?
@@ -38,7 +67,7 @@ class DeploymentsController < ApplicationController
format.json { render :json => {:error => flash[:warning]}, :status =>
:unprocessable_entity }
else
init_new_deployment_attrs
- format.js { render :partial => 'new' }
+ format.js { render :partial => 'legacy_new' }
format.html
format.json { render :json => @deployment }
end
@@ -63,9 +92,11 @@ class DeploymentsController < ApplicationController
format.html { redirect_to deployment_path(@deployment) }
format.json { render :json => @deployment, :status => :created }
else
+ # We need @pool to re-display the form
+ @pool = @deployment.pool
flash.now[:warning] = "Deployment launch failed"
init_new_deployment_attrs
- format.js { launch_new }
+ format.js { legacy_launch_new }
format.html { render :action => 'new' }
format.json { render :json => @deployment.errors, :status =>
:unprocessable_entity }
end
@@ -178,6 +209,14 @@ class DeploymentsController < ApplicationController
end
end
+ # Quick method to check if a deployment name is taken or not
+ # TODO - The AJAX calls here have a potential race condition; might want to include
params[:name]
+ # in the output to help catch this and discard output if appropriate
+ def check_name
+ deployment = Deployment.find_by_name(params[:name])
+ render :text => deployment.nil?.to_s
+ end
+
private
def load_deployments
@url_params = params
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index df1784d..248e156 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -62,7 +62,6 @@ class Deployment < ActiveRecord::Base
has_one :provider, :through => :realm
validates_presence_of :pool_id
- validates_presence_of :legacy_deployable_id
validates_presence_of :name
validates_uniqueness_of :name, :scope => :pool_id
diff --git a/src/app/views/deployments/_filter_view.haml
b/src/app/views/deployments/_filter_view.haml
index 677d434..6c5a00a 100644
--- a/src/app/views/deployments/_filter_view.haml
+++ b/src/app/views/deployments/_filter_view.haml
@@ -7,7 +7,7 @@
%td
= link_to(deployment.name, deployment)
%td
- = link_to(deployment.legacy_deployable.name, deployment.legacy_deployable)
+ = link_to(deployment.legacy_deployable.name, deployment.legacy_deployable) if
deployment.legacy_deployable
%td
= count_uptime(deployment.created_at)
%td
diff --git a/src/app/views/deployments/_launch_new.haml
b/src/app/views/deployments/_launch_new.haml
index 0618455..238e66f 100644
--- a/src/app/views/deployments/_launch_new.haml
+++ b/src/app/views/deployments/_launch_new.haml
@@ -1,8 +1,34 @@
= if request.xhr?
= render :partial => '/layouts/notification'
-%h2 Launch new deployment via
-- form_tag new_deployment_path, :method => :get do
- = label_tag "Deployable:"
- = select_tag :legacy_deployable_id,
options_from_collection_for_select(@launchable_deployables, "id",
"name")
- = submit_tag "Launch"
- = link_to "Cancel", deployments_path, :class => "button"
+%header.page-header
+ %h1
+ New Deployment in
+ = @pool.name
+%h2
+ Deployment Details
+- form_for :deployment, {:url => new_deployment_path, :method => :get} do
+ = hidden_field :deployment, :pool_id
+ %p
+ What do you want to launch?
+ %p
+ Provide the URL of the Deployable definition
+ = text_field('deployable', 'url')
+ %p
+ Name your deployment
+ = text_field(:deployment, :name)
+ %span.name_available
+ = submit_tag('Next')
+
+:javascript
+ // FIXME: This has a theoretical race condition: if responses come back out of order,
the value
+ // might reflect some previous entry and tell you a name is available when it's
not.
+ // Might be nice to build something in application.js to guard against this, and that
also
+ // introduces a ~250ms buffer so we don't do a lookup on every single keystroke...
+ $(document).ready(function () {
+ $('#deployment_name').keyup(function(e) {
+ e.preventDefault();
+ $.get('#{check_name_deployments_path}', {name:
$('#deployment_name').val() }, function(data) {
+ $('.name_available').html(data == "false" ? "That name is
already in use" : "Name available");
+ });
+ });
+ });
diff --git a/src/app/views/deployments/_legacy_launch_new.haml
b/src/app/views/deployments/_legacy_launch_new.haml
new file mode 100644
index 0000000..f2d4770
--- /dev/null
+++ b/src/app/views/deployments/_legacy_launch_new.haml
@@ -0,0 +1,8 @@
+= if request.xhr?
+ = render :partial => '/layouts/notification'
+%h2 Launch new deployment via
+- form_tag legacy_new_deployments_path, :method => :get do
+ = label_tag "Deployable:"
+ = select_tag :legacy_deployable_id,
options_from_collection_for_select(@launchable_deployables, "id",
"name")
+ = submit_tag "Launch"
+ = link_to "Cancel", deployments_path, :class => "button"
diff --git a/src/app/views/deployments/_legacy_new.haml
b/src/app/views/deployments/_legacy_new.haml
new file mode 100644
index 0000000..22b213c
--- /dev/null
+++ b/src/app/views/deployments/_legacy_new.haml
@@ -0,0 +1,25 @@
+= error_messages_for 'deployment'
+%h2 Launch deployable
+- form_for @deployment, :url => deployments_path do
+ = hidden_field :deployment, :legacy_deployable_id
+ %ul
+ %li
+ = label :deployment, :name
+ = text_field :deployment, :name
+ %li
+ = label :deployment, :pool
+ = select :deployment, :pool_id, @pools.map {|p| [ p.name, p.id ]}, { :include_blank
=> true }
+ %li
+ = label :deployment, :frontend_realm
+ = select :deployment, :frontend_realm_id, @realms.map {|r| [ r.name, r.id ]}, {
:include_blank => true }
+ %p
+ %h3 Assemblies hardware profiles
+ %ul
+ - @deployment.legacy_deployable.legacy_assemblies.each do |assembly|
+ %li
+ - hwprofiles = @hardware_profiles.select {|hwp| hwp.architecture.value ==
assembly.legacy_templates.first.architecture}
+ = label_tag "hw_profiles[#{assembly.id}]", assembly.name
+ = select_tag "hw_profiles[#{assembly.id}]",
options_from_collection_for_select(hwprofiles, 'id', 'name')
+
+ = submit_tag 'Cancel', :name => 'cancel'
+ = submit_tag 'Launch', :name => 'launch'
diff --git a/src/app/views/deployments/_list.haml b/src/app/views/deployments/_list.haml
index 7916f3b..77f6307 100644
--- a/src/app/views/deployments/_list.haml
+++ b/src/app/views/deployments/_list.haml
@@ -2,7 +2,7 @@
= render :partial => '/layouts/notification'
- form_tag do
- = link_to "New Deployment", launch_new_deployments_path, { :class =>
'button' }
+ = link_to "New Deployment", legacy_launch_new_deployments_path, { :class
=> 'button' }
= restful_submit_tag "Stop", "multi_stop",
multi_stop_deployments_path, 'POST', :id => 'stop_button'
= label_tag "More actions"
= select_tag("more_actions",nil, :disabled => true)
diff --git a/src/app/views/deployments/_new.haml b/src/app/views/deployments/_new.haml
index 22b213c..f515d7f 100644
--- a/src/app/views/deployments/_new.haml
+++ b/src/app/views/deployments/_new.haml
@@ -1,25 +1,37 @@
= error_messages_for 'deployment'
-%h2 Launch deployable
-- form_for @deployment, :url => deployments_path do
- = hidden_field :deployment, :legacy_deployable_id
- %ul
- %li
- = label :deployment, :name
- = text_field :deployment, :name
- %li
- = label :deployment, :pool
- = select :deployment, :pool_id, @pools.map {|p| [ p.name, p.id ]}, { :include_blank
=> true }
- %li
- = label :deployment, :frontend_realm
- = select :deployment, :frontend_realm_id, @realms.map {|r| [ r.name, r.id ]}, {
:include_blank => true }
- %p
- %h3 Assemblies hardware profiles
- %ul
- - @deployment.legacy_deployable.legacy_assemblies.each do |assembly|
- %li
- - hwprofiles = @hardware_profiles.select {|hwp| hwp.architecture.value ==
assembly.legacy_templates.first.architecture}
- = label_tag "hw_profiles[#{assembly.id}]", assembly.name
- = select_tag "hw_profiles[#{assembly.id}]",
options_from_collection_for_select(hwprofiles, 'id', 'name')
+%header.page-header
+ %h1
+ Deployment
+ = @deployment.name
+%h2
+ Launch Summary
- = submit_tag 'Cancel', :name => 'cancel'
- = submit_tag 'Launch', :name => 'launch'
+#scoreboard
+ %dl.statistics
+ %ul.groups
+ %li
+ %dt= t("pools.index.pool")
+ %dd= @pool.name
+ %li
+ %dt= t("deployments.deployment")
+ %dd= @deployment.name
+ %li
+ = link_to('view deployable definition', '#')
+
+%h2
+ Images
+
+-# Cannot implement this with real data until we have deployments implemented...
+= filter_table(['Image'], []) do |image|
+ %tr
+ %td
+ = image.name
+
+- form_for @deployment do
+ = hidden_field :deployment, :name
+ = hidden_field :deployment, :pool_id
+ -# FIXME: Passing chunks of XML around in hidden form fields doesn't feel right
+ = hidden_field :deployment, :deployable_xml
+ = submit_tag 'Launch'
+
+-# Quota checking to go here as well, once I understand how it works with new code
diff --git a/src/app/views/deployments/index.haml b/src/app/views/deployments/index.haml
index d051c94..3f8fc5f 100644
--- a/src/app/views/deployments/index.haml
+++ b/src/app/views/deployments/index.haml
@@ -1,2 +1 @@
-- content_for :list do
- = render :partial => 'list'
\ No newline at end of file
+= render :partial => 'list'
\ No newline at end of file
diff --git a/src/app/views/deployments/legacy_launch_new.haml
b/src/app/views/deployments/legacy_launch_new.haml
new file mode 100644
index 0000000..43771b3
--- /dev/null
+++ b/src/app/views/deployments/legacy_launch_new.haml
@@ -0,0 +1 @@
+= render :partial => 'legacy_launch_new'
\ No newline at end of file
diff --git a/src/app/views/deployments/legacy_new.haml
b/src/app/views/deployments/legacy_new.haml
new file mode 100644
index 0000000..d49ca7c
--- /dev/null
+++ b/src/app/views/deployments/legacy_new.haml
@@ -0,0 +1 @@
+= render :partial => 'legacy_new'
\ No newline at end of file
diff --git a/src/app/views/deployments/show.haml b/src/app/views/deployments/show.haml
index a5a777d..d24154a 100644
--- a/src/app/views/deployments/show.haml
+++ b/src/app/views/deployments/show.haml
@@ -1,5 +1 @@
-- content_for :list do
- = render :partial => 'list'
-
-- content_for :details do
- = render :partial => 'layouts/details_pane'
\ No newline at end of file
+= render :partial => 'properties'
\ No newline at end of file
diff --git a/src/app/views/legacy_deployables/_properties.haml
b/src/app/views/legacy_deployables/_properties.haml
index bd66153..bc00c3f 100644
--- a/src/app/views/legacy_deployables/_properties.haml
+++ b/src/app/views/legacy_deployables/_properties.haml
@@ -3,6 +3,6 @@
= link_to 'Edit', edit_legacy_deployable_path(@deployable), :class =>
'button'
- if @deployable.launchable?
- = link_to "Launch", new_deployment_path(:legacy_deployable_id =>
@deployable.id), {:class => 'button'}
+ = link_to "Launch", legacy_new_deployments_path(:legacy_deployable_id =>
@deployable.id), {:class => 'button'}
- else
The deployable can't be launched - the deployable must have at least one assembly
and each assembly must have at least one template.
diff --git a/src/app/views/pools/_header_show.haml
b/src/app/views/pools/_header_show.haml
index 2ea3cac..a59f7d7 100644
--- a/src/app/views/pools/_header_show.haml
+++ b/src/app/views/pools/_header_show.haml
@@ -4,7 +4,7 @@
Pool
-# Insert appropriate controls here, or ommit %ul.controls
#obj_actions.button-container
- = link_to 'New Deployment', launch_new_deployments_path, :class =>
'button primary', :id => 'new_deployment_button'
+ = link_to 'New Deployment', launch_new_deployments_path(:pool_id =>
@pool.id), :class => 'button primary', :id =>
'new_deployment_button'
.button-group
= link_to 'Edit', edit_pool_path(@pool), :class => 'button
pill', :id => 'edit_pool_button'
- form_tag do
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 1ca4035..3623ffa 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -70,6 +70,7 @@ en:
updates: Udates
deployments:
deployments: Deployments
+ deployment: Deployment
deployment_name: Deployment Name
updated:
one: "The deployment %{list} was successfully updated."
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 100e960..a0933a0 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -33,7 +33,8 @@ ActionController::Routing::Routes.draw do |map|
# -- just remember to delete public/index.html.
map.resources :pools, :collection => { :multi_destroy => :delete }
- map.resources :deployments, :collection => { :multi_stop => :get, :launch_new
=> :get }
+ map.resources :deployments, :collection => { :multi_stop => :get, :launch_new
=> :get, :legacy_new => :get,
+ :legacy_launch_new => :get, :check_name => :get }
map.resources :instances, :collection => {:start => :get, :multi_stop => :get,
:select_legacy_template => :get, :remove_failed => :get, :can_start => :get,
:can_create => :get }, :member => {:key => :get}
map.can_start_instance
'/instances/:instance_id/can_start/:provider_account_id', :controller =>
'instances', :action => 'can_start', :conditions => { :method =>
:get }
diff --git
a/src/db/migrate/20110603204130_remove_not_null_constraint_on_deployment_deployable_id.rb
b/src/db/migrate/20110603204130_remove_not_null_constraint_on_deployment_deployable_id.rb
new file mode 100644
index 0000000..983466f
--- /dev/null
+++
b/src/db/migrate/20110603204130_remove_not_null_constraint_on_deployment_deployable_id.rb
@@ -0,0 +1,9 @@
+class RemoveNotNullConstraintOnDeploymentDeployableId < ActiveRecord::Migration
+ def self.up
+ change_column :deployments, :legacy_deployable_id, :integer, :null => true
+ end
+
+ def self.down
+ change_column :deployments, :legacy_deployable_id, :integer, :null => false
+ end
+end
diff --git a/src/features/authentication.feature b/src/features/authentication.feature
index 9e41789..9e9260f 100644
--- a/src/features/authentication.feature
+++ b/src/features/authentication.feature
@@ -50,7 +50,7 @@ Feature: User authentication
Scenario: Edit profile
Given I am logged in
- And I am on the homepage
+ And I am on the legacy assemblies page
When I want to edit my profile
Then should see "Editing Account"
When I fill in "E-mail" with "changed(a)example.com"
@@ -60,7 +60,7 @@ Feature: User authentication
Scenario: log out
Given I am logged in
- And I am on the homepage
+ And I am on the legacy assemblies page
When I follow "Log out"
Then I should be logged out
And I should see "Logout successful!"
@@ -69,7 +69,7 @@ Feature: User authentication
Scenario: Change user login to one with invalid length
Given I am logged in
- And I am on the homepage
+ And I am on the legacy assemblies page
When I want to edit my profile
Then should see "Editing Account"
When I enter a string of length "101" into "user[login]"
diff --git a/src/features/deployment.feature b/src/features/deployment.feature
index 3541378..ebbdcba 100644
--- a/src/features/deployment.feature
+++ b/src/features/deployment.feature
@@ -11,7 +11,7 @@ Feature: Manage Deployments
Given there is a deployment named "MySQL Cluster" belonging to
"Databases" owned by "bob"
And I am on the pools page
When I follow "Filter View"
- And I follow "Deployments"
+ And I follow "Deployments" within "#details-view"
Then I should see "MySQL Cluster"
And I should see "bob"
@@ -74,9 +74,10 @@ Feature: Manage Deployments
Scenario: Show operational status of deployment
Given there is a deployment named "testdeployment" belonging to
"testdeployable" owned by "testuser"
- When I am on the operational status of deployment page
- Then I should see "Operational status of testdeployment"
- And I should see "Uptime"
+ When I am on the deployments page
+ And I follow "testdeployment"
+ Then I should see "testdeployment"
+ And I should see "Created:"
Scenario: Edit deployment name
Given there is a deployment named "Hudson" belonging to "QA
Infrastructure" owned by "joe"
diff --git a/src/features/instance.feature b/src/features/instance.feature
index 155ed21..11846a3 100644
--- a/src/features/instance.feature
+++ b/src/features/instance.feature
@@ -37,7 +37,7 @@ Feature: Manage Instances
Scenario: I want to view all instances
Given there is a "mock1" instance
And I am on the home page
- When I follow "Resource Management"
+ When I follow "Monitor"
Then I should be on the pools page
When I follow "Filter View"
And I follow "Instances"
diff --git a/src/features/legacy_deployable.feature
b/src/features/legacy_deployable.feature
index ad92a6f..b6062fb 100644
--- a/src/features/legacy_deployable.feature
+++ b/src/features/legacy_deployable.feature
@@ -107,7 +107,7 @@ Feature: Manage Deployables
And there is "mock_pool" pool
When I follow "test1"
And I follow "Launch"
- Then I should be on the new deployment page
+ Then I should be on the legacy new deployments page
When I fill in "deployment_name" with "depl1"
And I select "mock_pool" from "deployment_pool_id"
And I select "mock_realm" from "deployment_frontend_realm_id"
--
1.7.4.4