From: Jozef Zigmund <jzigmund(a)redhat.com>
---
src/app/controllers/deployables_controller.rb | 149 --------------------
src/app/controllers/deployments_controller.rb | 6 +-
.../controllers/legacy_deployables_controller.rb | 149 ++++++++++++++++++++
src/app/controllers/pools_controller.rb | 1 -
src/app/controllers/templates_controller.rb | 2 +-
src/app/models/assembly.rb | 2 +-
src/app/models/deployable.rb | 94 ------------
src/app/models/deployment.rb | 10 +-
src/app/models/legacy_deployable.rb | 94 ++++++++++++
src/app/models/permission.rb | 2 +-
src/app/views/deployables/_assemblies.haml | 30 ----
src/app/views/deployables/_deployments.haml | 25 ----
src/app/views/deployables/_form.haml | 10 --
src/app/views/deployables/_list.haml | 28 ----
src/app/views/deployables/_pick_assemblies.haml | 16 --
src/app/views/deployables/_properties.haml | 8 -
src/app/views/deployables/edit.haml | 4 -
src/app/views/deployables/index.haml | 2 -
src/app/views/deployables/new.haml | 3 -
src/app/views/deployables/pick_assemblies.haml | 5 -
src/app/views/deployables/show.haml | 5 -
src/app/views/deployments/_edit.haml | 2 +-
src/app/views/deployments/_filter_view.haml | 2 +-
src/app/views/deployments/_launch_new.haml | 2 +-
src/app/views/deployments/_new.haml | 4 +-
src/app/views/legacy_deployables/_assemblies.haml | 30 ++++
src/app/views/legacy_deployables/_deployments.haml | 25 ++++
src/app/views/legacy_deployables/_form.haml | 10 ++
src/app/views/legacy_deployables/_list.haml | 28 ++++
.../views/legacy_deployables/_pick_assemblies.haml | 16 ++
src/app/views/legacy_deployables/_properties.haml | 8 +
src/app/views/legacy_deployables/edit.haml | 4 +
src/app/views/legacy_deployables/index.haml | 2 +
src/app/views/legacy_deployables/new.haml | 3 +
.../views/legacy_deployables/pick_assemblies.haml | 5 +
src/app/views/legacy_deployables/show.haml | 5 +
src/config/navigation.rb | 2 +-
src/config/routes.rb | 2 +-
.../migrate/20110112094108_create_deployables.rb | 4 +-
.../migrate/20110207100800_update_deployables.rb | 10 +-
.../migrate/20110207100900_create_deployments.rb | 2 +-
src/db/migrate/20110207101000_update_instances.rb | 2 +-
src/db/migrate/20110427071851_add_owner_id.rb | 4 +-
src/features/deployable.feature | 26 ++--
src/features/deployable_permissions.feature | 24 ++--
src/features/deployment.feature | 4 +-
src/features/step_definitions/assembly_steps.rb | 6 +-
src/features/step_definitions/deployable_steps.rb | 16 +-
src/features/step_definitions/deployment_steps.rb | 8 +-
src/features/step_definitions/pool_steps.rb | 4 +-
src/features/support/paths.rb | 4 +-
src/features/template.feature | 2 +-
src/spec/factories/deployable.rb | 2 +-
src/spec/factories/deployment.rb | 2 +-
src/spec/models/deployable_spec.rb | 20 ++--
src/spec/models/deployment_spec.rb | 10 +-
56 files changed, 472 insertions(+), 473 deletions(-)
delete mode 100644 src/app/controllers/deployables_controller.rb
create mode 100644 src/app/controllers/legacy_deployables_controller.rb
delete mode 100644 src/app/models/deployable.rb
create mode 100644 src/app/models/legacy_deployable.rb
delete mode 100644 src/app/views/deployables/_assemblies.haml
delete mode 100644 src/app/views/deployables/_deployments.haml
delete mode 100644 src/app/views/deployables/_form.haml
delete mode 100644 src/app/views/deployables/_list.haml
delete mode 100644 src/app/views/deployables/_pick_assemblies.haml
delete mode 100644 src/app/views/deployables/_properties.haml
delete mode 100644 src/app/views/deployables/edit.haml
delete mode 100644 src/app/views/deployables/index.haml
delete mode 100644 src/app/views/deployables/new.haml
delete mode 100644 src/app/views/deployables/pick_assemblies.haml
delete mode 100644 src/app/views/deployables/show.haml
create mode 100644 src/app/views/legacy_deployables/_assemblies.haml
create mode 100644 src/app/views/legacy_deployables/_deployments.haml
create mode 100644 src/app/views/legacy_deployables/_form.haml
create mode 100644 src/app/views/legacy_deployables/_list.haml
create mode 100644 src/app/views/legacy_deployables/_pick_assemblies.haml
create mode 100644 src/app/views/legacy_deployables/_properties.haml
create mode 100644 src/app/views/legacy_deployables/edit.haml
create mode 100644 src/app/views/legacy_deployables/index.haml
create mode 100644 src/app/views/legacy_deployables/new.haml
create mode 100644 src/app/views/legacy_deployables/pick_assemblies.haml
create mode 100644 src/app/views/legacy_deployables/show.haml
diff --git a/src/app/controllers/deployables_controller.rb
b/src/app/controllers/deployables_controller.rb
deleted file mode 100644
index 40a0a04..0000000
--- a/src/app/controllers/deployables_controller.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-class DeployablesController < ApplicationController
- before_filter :require_user
- before_filter :load_deployables, :only => [:index, :show, :pick_assemblies]
- before_filter :load_deployable_with_assemblies, :only => [:remove_assemblies,
:add_assemblies, :pick_assemblies]
-
- def index
- require_privilege(Privilege::VIEW, Template)
- @search_term = params[:q]
- return if @search_term.blank?
- search = Deployable.search() do
- keywords(params[:q])
- end
- @deployables = search.results
- end
-
- def show
- @deployable = Deployable.find(params[:id])
- require_privilege(Privilege::VIEW, @deployable)
- @url_params = params.clone
- @tab_captions = ['Properties', 'Assemblies', 'Deployments']
- @details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
- if @details_tab == 'deployments'
- @deployments = @deployable.deployments
- end
- respond_to do |format|
- format.js do
- if @url_params.delete :details_pane
- render :partial => 'layouts/details_pane' and return
- end
- render :partial => @details_tab and return
- end
- format.html { render :action => 'show'}
- end
- end
-
- def new
- require_privilege(Privilege::CREATE, Template)
- @deployable = Deployable.new
- end
-
- def create
- require_privilege(Privilege::CREATE, Template)
- @deployable = Deployable.new(params[:deployable])
- @deployable.owner = current_user
- if @deployable.save
- flash[:notice] = "Deployable added."
- redirect_to deployable_url(@deployable)
- else
- render :action => :new
- end
- end
-
- def edit
- @deployable = Deployable.find(params[:id])
- require_privilege(Privilege::MODIFY, @deployable)
- end
-
- def update
- @deployable = Deployable.find(params[:id])
- require_privilege(Privilege::MODIFY, @deployable)
- if @deployable.update_attributes(params[:deployable])
- flash[:notice] = "Deployable updated."
- redirect_to deployable_url(@deployable)
- else
- render :action => :edit
- end
- end
-
- def multi_destroy
- destroyed = []
- failed = []
- Deployable.find(params[:deployables_selected]).each do |deployable|
- if check_privilege(Privilege::MODIFY, deployable) and deployable.destroyable?
- deployable.destroy
- destroyed << deployable.name
- else
- failed << deployable.name
- end
- end
-
- unless destroyed.empty?
- flash[:notice] = t('deployables.index.deleted', :count =>
destroyed.length, :list => destroyed.join(', '))
- end
- unless failed.empty?
- flash[:error] = t('deployables.index.not_deleted', :count =>
failed.length, :list => failed.join(', '))
- end
- redirect_to deployables_url
- end
-
- def pick_assemblies
- require_privilege(Privilege::MODIFY, @deployable)
- @assemblies = Assembly.all - @deployable.assemblies
- respond_to do |format|
- format.js { render :partial => 'pick_assemblies' }
- format.html { render 'pick_assemblies' }
- end
- end
-
- def add_assemblies
- require_privilege(Privilege::MODIFY, @deployable)
- if assemblies = params.delete(:assemblies_selected)
- @deployable.assembly_ids += assemblies.collect{|a| a.to_i}
- @deployable.save!
- flash[:notice] = "Assemblies saved."
- end
- respond_to do |format|
- format.js { render :partial => 'assemblies' }
- format.html { redirect_to deployable_url(@deployable, :details_tab =>
'assemblies') and return }
- end
- end
-
- def remove_assemblies
- require_privilege(Privilege::MODIFY, @deployable)
- if params[:assemblies_selected].present?
- @deployable.assembly_ids = @deployable.assembly_ids -
params[:assemblies_selected].collect{|a| a.to_i}
- @deployable.save!
- flash[:notice] = "Assemblies removed."
- end
- respond_to do |format|
- format.js { render :partial => 'assemblies' }
- format.html { redirect_to deployable_url(@deployable, :details_tab =>
'assemblies') and return }
- end
- end
-
- protected
-
- def load_deployables
- @header = [
- { :name => "Deployable name", :sort_attr => :name }
- ]
- @header_deployments = [
- { :name => "Deployment name", :sort_attr => :name },
- { :name => "Deployable", :sortable => false },
- { :name => "Deployment Owner", :sort_attr =>
"owner.last_name"},
- { :name => "Running Since", :sort_attr => :running_since },
- { :name => "Heath Metric", :sort_attr => :health },
- { :name => "Pool", :sort_attr => "pool.name" }
- ]
- @deployables = Deployable.paginate(:all,
- :page => params[:page] || 1,
- :order => (params[:order_field] || 'name') +' '+
(params[:order_dir] || 'asc')
- )
- @url_params = params.clone
- end
-
- def load_deployable_with_assemblies
- @deployable = Deployable.find(params[:id], :include => :assemblies)
- end
-end
diff --git a/src/app/controllers/deployments_controller.rb
b/src/app/controllers/deployments_controller.rb
index 53ec037..355ac1f 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -14,7 +14,7 @@ class DeploymentsController < ApplicationController
def launch_new
@launchable_deployables = []
- Deployable.all.each do |deployable|
+ LegacyDeployable.all.each do |deployable|
@launchable_deployables << deployable if deployable.launchable?
end
respond_to do |format|
@@ -26,9 +26,9 @@ class DeploymentsController < ApplicationController
def new
require_privilege(Privilege::CREATE, Deployment)
- @deployment = Deployment.new(:deployable_id => params[:deployable_id])
+ @deployment = Deployment.new(:legacy_deployable_id =>
params[:legacy_deployable_id])
respond_to do |format|
- if @deployment.deployable.assemblies.empty?
+ if @deployment.legacy_deployable.assemblies.empty?
flash[:warning] = "Deployable must have at least one assembly"
format.js do
load_deployments
diff --git a/src/app/controllers/legacy_deployables_controller.rb
b/src/app/controllers/legacy_deployables_controller.rb
new file mode 100644
index 0000000..6ef295b
--- /dev/null
+++ b/src/app/controllers/legacy_deployables_controller.rb
@@ -0,0 +1,149 @@
+class LegacyDeployablesController < ApplicationController
+ before_filter :require_user
+ before_filter :load_deployables, :only => [:index, :show, :pick_assemblies]
+ before_filter :load_deployable_with_assemblies, :only => [:remove_assemblies,
:add_assemblies, :pick_assemblies]
+
+ def index
+ require_privilege(Privilege::VIEW, Template)
+ @search_term = params[:q]
+ return if @search_term.blank?
+ search = LegacyDeployable.search() do
+ keywords(params[:q])
+ end
+ @deployables = search.results
+ end
+
+ def show
+ @deployable = LegacyDeployable.find(params[:id])
+ require_privilege(Privilege::VIEW, @deployable)
+ @url_params = params.clone
+ @tab_captions = ['Properties', 'Assemblies', 'Deployments']
+ @details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
+ if @details_tab == 'deployments'
+ @deployments = @deployable.deployments
+ end
+ respond_to do |format|
+ format.js do
+ if @url_params.delete :details_pane
+ render :partial => 'layouts/details_pane' and return
+ end
+ render :partial => @details_tab and return
+ end
+ format.html { render :action => 'show'}
+ end
+ end
+
+ def new
+ require_privilege(Privilege::CREATE, Template)
+ @deployable = LegacyDeployable.new
+ end
+
+ def create
+ require_privilege(Privilege::CREATE, Template)
+ @deployable = LegacyDeployable.new(params[:legacy_deployable])
+ @deployable.owner = current_user
+ if @deployable.save
+ flash[:notice] = "Deployable added."
+ redirect_to legacy_deployable_url(@deployable)
+ else
+ render :action => :new
+ end
+ end
+
+ def edit
+ @deployable = LegacyDeployable.find(params[:id])
+ require_privilege(Privilege::MODIFY, @deployable)
+ end
+
+ def update
+ @deployable = LegacyDeployable.find(params[:id])
+ require_privilege(Privilege::MODIFY, @deployable)
+ if @deployable.update_attributes(params[:legacy_deployable])
+ flash[:notice] = "Deployable updated."
+ redirect_to legacy_deployable_url(@deployable)
+ else
+ render :action => :edit
+ end
+ end
+
+ def multi_destroy
+ destroyed = []
+ failed = []
+ LegacyDeployable.find(params[:deployables_selected]).each do |deployable|
+ if check_privilege(Privilege::MODIFY, deployable) and deployable.destroyable?
+ deployable.destroy
+ destroyed << deployable.name
+ else
+ failed << deployable.name
+ end
+ end
+
+ unless destroyed.empty?
+ flash[:notice] = t('deployables.index.deleted', :count =>
destroyed.length, :list => destroyed.join(', '))
+ end
+ unless failed.empty?
+ flash[:error] = t('deployables.index.not_deleted', :count =>
failed.length, :list => failed.join(', '))
+ end
+ redirect_to legacy_deployables_url
+ end
+
+ def pick_assemblies
+ require_privilege(Privilege::MODIFY, @deployable)
+ @assemblies = Assembly.all - @deployable.assemblies
+ respond_to do |format|
+ format.js { render :partial => 'pick_assemblies' }
+ format.html { render 'pick_assemblies' }
+ end
+ end
+
+ def add_assemblies
+ require_privilege(Privilege::MODIFY, @deployable)
+ if assemblies = params.delete(:assemblies_selected)
+ @deployable.assembly_ids += assemblies.collect{|a| a.to_i}
+ @deployable.save!
+ flash[:notice] = "Assemblies saved."
+ end
+ respond_to do |format|
+ format.js { render :partial => 'assemblies' }
+ format.html { redirect_to legacy_deployable_url(@deployable, :details_tab =>
'assemblies') and return }
+ end
+ end
+
+ def remove_assemblies
+ require_privilege(Privilege::MODIFY, @deployable)
+ if params[:assemblies_selected].present?
+ @deployable.assembly_ids = @deployable.assembly_ids -
params[:assemblies_selected].collect{|a| a.to_i}
+ @deployable.save!
+ flash[:notice] = "Assemblies removed."
+ end
+ respond_to do |format|
+ format.js { render :partial => 'assemblies' }
+ format.html { redirect_to legacy_deployable_url(@deployable, :details_tab =>
'assemblies') and return }
+ end
+ end
+
+ protected
+
+ def load_deployables
+ @header = [
+ { :name => "Deployable name", :sort_attr => :name }
+ ]
+ @header_deployments = [
+ { :name => "Deployment name", :sort_attr => :name },
+ { :name => "Deployable", :sortable => false },
+ { :name => "Deployment Owner", :sort_attr =>
"owner.last_name"},
+ { :name => "Running Since", :sort_attr => :running_since },
+ { :name => "Heath Metric", :sort_attr => :health },
+ { :name => "Pool", :sort_attr => "pool.name" }
+ ]
+ @deployables = LegacyDeployable.paginate(:all,
+ :page => params[:page] || 1,
+ :order => (params[:order_field] || 'name') +' '+
(params[:order_dir] || 'asc')
+ )
+ @url_params = params.clone
+ end
+
+ def load_deployable_with_assemblies
+ @deployable = LegacyDeployable.find(params[:id], :include => :assemblies)
+ end
+end
diff --git a/src/app/controllers/pools_controller.rb
b/src/app/controllers/pools_controller.rb
index 2aee5ff..83c3b5f 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -214,7 +214,6 @@ class PoolsController < ApplicationController
{ :name => t("uptime"), :sortable => false },
{ :name => t("instances.instances"), :sortable => false },
{ :name => t("providers.provider"), :sortable => false }
-
]
end
diff --git a/src/app/controllers/templates_controller.rb
b/src/app/controllers/templates_controller.rb
index 53e17b7..7ab8e0a 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -78,7 +78,7 @@ class TemplatesController < ApplicationController
flash[:notice] = "Template saved."
@tpl.set_complete
if params[:create_deployable]
- Deployable.create!(:name => @tpl.name, :assemblies => @tpl.assemblies,
:owner => current_user)
+ LegacyDeployable.create!(:name => @tpl.name, :assemblies =>
@tpl.assemblies, :owner => current_user)
end
redirect_to templates_path
else
diff --git a/src/app/models/assembly.rb b/src/app/models/assembly.rb
index 99c083b..9e2ac23 100644
--- a/src/app/models/assembly.rb
+++ b/src/app/models/assembly.rb
@@ -46,7 +46,7 @@ class Assembly < ActiveRecord::Base
end
has_and_belongs_to_many :templates
- has_and_belongs_to_many :deployables
+ has_and_belongs_to_many :legacy_deployables
has_many :instances
has_many :permissions, :as => :permission_object, :dependent => :destroy,
diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
deleted file mode 100644
index f2264f9..0000000
--- a/src/app/models/deployable.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# == Schema Information
-# Schema version: 20110207110131
-#
-# Table name: deployables
-#
-# id :integer not null, primary key
-# name :string(255)
-# created_at :datetime
-# updated_at :datetime
-# lock_version :integer default(0)
-# uuid :string(255) not null
-# xml :binary not null
-# uri :string(255)
-# summary :text
-# uploaded :boolean
-#
-
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Scott Seago <sseago(a)redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at
http://www.gnu.org/copyleft/gpl.html.
-
-require 'sunspot_rails'
-class Deployable < ActiveRecord::Base
- include PermissionedObject
- include ImageWarehouseObject
- searchable do
- text :name, :as => :code_substring
- text :summary, :as => :code_substring
- end
-
- has_and_belongs_to_many :assemblies
- has_many :deployments
-
- has_many :permissions, :as => :permission_object, :dependent => :destroy,
- :include => [:role],
- :order => "permissions.id ASC"
- belongs_to :owner, :class_name => "User", :foreign_key =>
"owner_id"
- after_create "assign_owner_roles(owner)"
-
- before_validation :generate_uuid
- before_save :update_xml
-
- validates_presence_of :uuid
- validates_uniqueness_of :uuid
- validates_presence_of :name
- validates_uniqueness_of :name
- validates_length_of :name, :maximum => 255
- validates_presence_of :owner_id
-
- before_destroy :destroyable?
-
- def self.default_privilege_target_type
- Template
- end
-
- def update_xml
- xml.name = self.name
- xml.description = self.summary
- write_attribute(:xml, xml.to_xml)
- end
-
- def self.find_or_create(id)
- id ? Deployable.find(id) : Deployable.new
- end
-
- def destroyable?
- deployments.all? {|d| d.destroyable? }
- end
-
- def launchable?
- return false if assemblies.empty?
- assemblies.each do |a|
- return false if a.templates.empty?
- # TODO: should we check if there is an uploaded image for each template in
- # assembly?
- end
- return true
- end
-end
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index a9615ea..336e92a 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -8,7 +8,7 @@
# realm_id :integer
# owner_id :integer
# pool_id :integer not null
-# deployable_id :integer not null
+# legacy_deployable_id :integer not null
# lock_version :integer default(0)
# created_at :datetime
# updated_at :datetime
@@ -44,7 +44,7 @@ class Deployment < ActiveRecord::Base
belongs_to :pool
- belongs_to :deployable
+ belongs_to :legacy_deployable
has_many :instances
belongs_to :realm
@@ -60,7 +60,7 @@ class Deployment < ActiveRecord::Base
has_one :provider, :through => :realm
validates_presence_of :pool_id
- validates_presence_of :deployable_id
+ validates_presence_of :legacy_deployable_id
validates_presence_of :name
validates_uniqueness_of :name, :scope => :pool_id
@@ -112,8 +112,8 @@ class Deployment < ActiveRecord::Base
def launch(hw_profiles, user)
errors = []
- raise "the deployable must have at least one assembly and each assembly must
have at least one template" unless deployable.launchable?
- deployable.assemblies.each do |assembly|
+ raise "the deployable must have at least one assembly and each assembly must
have at least one template" unless legacy_deployable.launchable?
+ legacy_deployable.assemblies.each do |assembly|
# TODO: for now we try to start all instances even if some of them fails
begin
Instance.transaction do
diff --git a/src/app/models/legacy_deployable.rb b/src/app/models/legacy_deployable.rb
new file mode 100644
index 0000000..853e4b5
--- /dev/null
+++ b/src/app/models/legacy_deployable.rb
@@ -0,0 +1,94 @@
+# == Schema Information
+# Schema version: 20110207110131
+#
+# Table name: deployables
+#
+# id :integer not null, primary key
+# name :string(255)
+# created_at :datetime
+# updated_at :datetime
+# lock_version :integer default(0)
+# uuid :string(255) not null
+# xml :binary not null
+# uri :string(255)
+# summary :text
+# uploaded :boolean
+#
+
+#
+# Copyright (C) 2011 Red Hat, Inc.
+# Written by Scott Seago <sseago(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at
http://www.gnu.org/copyleft/gpl.html.
+
+require 'sunspot_rails'
+class LegacyDeployable < ActiveRecord::Base
+ include PermissionedObject
+ include ImageWarehouseObject
+ searchable do
+ text :name, :as => :code_substring
+ text :summary, :as => :code_substring
+ end
+
+ has_and_belongs_to_many :assemblies
+ has_many :deployments
+
+ has_many :permissions, :as => :permission_object, :dependent => :destroy,
+ :include => [:role],
+ :order => "permissions.id ASC"
+ belongs_to :owner, :class_name => "User", :foreign_key =>
"owner_id"
+ after_create "assign_owner_roles(owner)"
+
+ before_validation :generate_uuid
+ before_save :update_xml
+
+ validates_presence_of :uuid
+ validates_uniqueness_of :uuid
+ validates_presence_of :name
+ validates_uniqueness_of :name
+ validates_length_of :name, :maximum => 255
+ validates_presence_of :owner_id
+
+ before_destroy :destroyable?
+
+ def self.default_privilege_target_type
+ Template
+ end
+
+ def update_xml
+ xml.name = self.name
+ xml.description = self.summary
+ write_attribute(:xml, xml.to_xml)
+ end
+
+ def self.find_or_create(id)
+ id ? LegacyDeployable.find(id) : LegacyDeployable.new
+ end
+
+ def destroyable?
+ deployments.all? {|d| d.destroyable? }
+ end
+
+ def launchable?
+ return false if assemblies.empty?
+ assemblies.each do |a|
+ return false if a.templates.empty?
+ # TODO: should we check if there is an uploaded image for each template in
+ # assembly?
+ end
+ return true
+ end
+end
diff --git a/src/app/models/permission.rb b/src/app/models/permission.rb
index 34e37bd..f27a0af 100644
--- a/src/app/models/permission.rb
+++ b/src/app/models/permission.rb
@@ -61,7 +61,7 @@ class Permission < ActiveRecord::Base
:foreign_key =>
"permission_object_id"
belongs_to :assembly, :class_name => "Assembly",
:foreign_key =>
"permission_object_id"
- belongs_to :deployable, :class_name => "Deployable",
+ belongs_to :legacy_deployable, :class_name =>
"LegacyDeployable",
:foreign_key =>
"permission_object_id"
belongs_to :base_permission_object, :class_name =>
"BasePermissionObject",
:foreign_key =>
"permission_object_id"
diff --git a/src/app/views/deployables/_assemblies.haml
b/src/app/views/deployables/_assemblies.haml
deleted file mode 100644
index 01bf09a..0000000
--- a/src/app/views/deployables/_assemblies.haml
+++ /dev/null
@@ -1,30 +0,0 @@
-.grid_13
-- form_tag do
- = restful_submit_tag "Remove Selected", 'destroy',
remove_assemblies_deployable_path(@deployable), 'DELETE', :id =>
'delete_button'
- = link_to "Add Assembly...", pick_assemblies_deployable_path(@deployable),
:class => 'button', :id => 'add_assembly'
-
- %table#assemblies_table
- %thead
- %tr
- %th
- %th= "Name"
- %th= "Created"
- -@deployable.assemblies(:include => :templates).each do |assembly|
- %tr
- %td
- %input{:name => "assemblies_selected[]", :type =>
"checkbox", :value => assembly.id, :id =>
"assembly_checkbox_#{assembly.id}" }
- %td= assembly.name
- %td= assembly.created_at
-
-:javascript
- $(document).ready(function () {
- $('#add_assembly').click(function(e) {
- e.preventDefault();
- var url = $(this).attr('href');
- $.get(url, function(data) {
- var selectedTabIndex = $("#details-view").tabs('option',
'selected');
- var $selectedTab = $("#details-view
div.ui-tabs-panel").eq(selectedTabIndex);
- $selectedTab.html(data);
- });
- });
- });
diff --git a/src/app/views/deployables/_deployments.haml
b/src/app/views/deployables/_deployments.haml
deleted file mode 100644
index d2ce11a..0000000
--- a/src/app/views/deployables/_deployments.haml
+++ /dev/null
@@ -1,25 +0,0 @@
-.grid_13
- %h2 Deployments for #{(a)deployable.name}
-
- - unless @deployments.empty?
- - form_tag do
- %table#deployments_table
- = sortable_table_header @header_deployments
- - @deployments.each do |deployment|
- %tr
- %td
- - selected = @url_params[:select] == 'all'
- %input{:name => "deployments_selected[]", :type =>
"checkbox", :value => deployment.id, :id =>
"deployment_checkbox_#{deployment.id}", :checked => selected }
- = link_to deployment.name, deployment_path(deployment)
- %td
- = deployment.deployable.name
- %td
- = deployment.owner.login
- %td
- = deployment.created_at.strftime("%d-%b-%Y %H:%M:%S")
- %td
- TODO
- %td
- = deployment.pool.name
- - else
- No Deployments for #{(a)deployable.name}
diff --git a/src/app/views/deployables/_form.haml b/src/app/views/deployables/_form.haml
deleted file mode 100644
index bf54513..0000000
--- a/src/app/views/deployables/_form.haml
+++ /dev/null
@@ -1,10 +0,0 @@
-= form.error_messages
-%fieldset.clear
- = form.label :name, t(:name), :class => "grid_3 alpha"
- = form.text_field :name, :class => "grid_5"
-%fieldset.clear
- = form.label :summary, t(:summary), :class => "grid_3 alpha"
- = form.text_area :summary, :class => "grid_5", :rows => 3
-%fieldset.clearfix
- = form.submit "Save", :class => "submit formbutton"
- = link_to t(:cancel), deployables_path, :class => 'button formbutton'
diff --git a/src/app/views/deployables/_list.haml b/src/app/views/deployables/_list.haml
deleted file mode 100644
index b0fb991..0000000
--- a/src/app/views/deployables/_list.haml
+++ /dev/null
@@ -1,28 +0,0 @@
-- form_tag do
- = link_to "Create", new_deployable_url, :class => 'button'
- = restful_submit_tag "Delete", 'destroy',
multi_destroy_deployables_path, 'DELETE', :id => 'delete_button'
-
- %table#deployables_table
- %thead
- %tr
- %th
- %th= link_to "Name", deployables_url(:sort_by => "name")
- -(a)deployables.each do |deployable|
- %tr
- %td
- %input{:name => "deployables_selected[]", :type =>
"checkbox", :value => deployable.id, :id =>
"deployable_checkbox_#{deployable.id}" }
- %td= link_to deployable.name, deployable_path(deployable)
-
-:javascript
- $(document).ready(function () {
- $('#delete_button').click(function(e) {
- if ($("#deployables_table input[@type=radio]:checked").length == 0) {
- alert('Please select any deployable to be deleted before clicking Delete
button.');
- e.preventDefault();
- } else {
- if (!confirm("Are you sure you want to delete this deployable?")) {
- e.preventDefault();
- }
- }
- });
- });
diff --git a/src/app/views/deployables/_pick_assemblies.haml
b/src/app/views/deployables/_pick_assemblies.haml
deleted file mode 100644
index 01e472b..0000000
--- a/src/app/views/deployables/_pick_assemblies.haml
+++ /dev/null
@@ -1,16 +0,0 @@
-.grid_13
- - form_tag(deployable_path(@deployable)) do
- %table#assemblies_list
- %thead
- %tr
- %th
- %th= "Name"
- -(a)assemblies.each do |assembly|
- %tr
- %td
- %input{:name => "assemblies_selected[]", :type =>
"checkbox", :value => assembly.id, :id =>
"assembly_checkbox_#{assembly.id}" }
- %td= assembly.name
-
- -# AJAX post
- = restful_submit_tag('Save', 'add_assemblies',
add_assemblies_deployable_path(@deployable), 'PUT')
- = link_to "Back", deployable_path(@deployable, :details_tab =>
'assemblies'), :class => 'button'
diff --git a/src/app/views/deployables/_properties.haml
b/src/app/views/deployables/_properties.haml
deleted file mode 100644
index 1fbf002..0000000
--- a/src/app/views/deployables/_properties.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-.grid_13
- %h2 #{(a)deployable.name}
-
- = link_to 'Edit', edit_deployable_path(@deployable), :class =>
'button'
- - if @deployable.launchable?
- = link_to "Launch", new_deployment_path(: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/deployables/edit.haml b/src/app/views/deployables/edit.haml
deleted file mode 100644
index fd81aeb..0000000
--- a/src/app/views/deployables/edit.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-%h2 Editing Deployable: #{(a)deployable.name}
-
-- form_for @deployable, :url => deployable_path(@deployable), :html => { :method
=> :put } do |f|
- = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/deployables/index.haml b/src/app/views/deployables/index.haml
deleted file mode 100644
index 62ccbc6..0000000
--- a/src/app/views/deployables/index.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-- content_for :list do
- = render :partial => 'list'
diff --git a/src/app/views/deployables/new.haml b/src/app/views/deployables/new.haml
deleted file mode 100644
index 50abe11..0000000
--- a/src/app/views/deployables/new.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-%h2 New Deployable
-- form_for @deployable, :url => deployables_path do |f|
- = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/deployables/pick_assemblies.haml
b/src/app/views/deployables/pick_assemblies.haml
deleted file mode 100644
index c223367..0000000
--- a/src/app/views/deployables/pick_assemblies.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-- content_for :list do
- = render :partial => 'list'
-
-- content_for :details do
- = render :partial => 'pick_assemblies'
diff --git a/src/app/views/deployables/show.haml b/src/app/views/deployables/show.haml
deleted file mode 100644
index 05eeedd..0000000
--- a/src/app/views/deployables/show.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-- content_for :list do
- = render :partial => 'list'
-
-- content_for :details do
- = render :partial => 'layouts/details_pane'
diff --git a/src/app/views/deployments/_edit.haml b/src/app/views/deployments/_edit.haml
index 72c8e60..1bccdee 100644
--- a/src/app/views/deployments/_edit.haml
+++ b/src/app/views/deployments/_edit.haml
@@ -1,7 +1,7 @@
= error_messages_for 'deployment'
%h2 Edit deployment
- form_for @deployment do
- = hidden_field :deployment, :deployable_id
+ = hidden_field :deployment, :legacy_deployable_id
%ul
%li
= label :deployment, :name
diff --git a/src/app/views/deployments/_filter_view.haml
b/src/app/views/deployments/_filter_view.haml
index 59ea23f..677d434 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.deployable.name, deployment.deployable)
+ = link_to(deployment.legacy_deployable.name, 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 34126dd..0618455 100644
--- a/src/app/views/deployments/_launch_new.haml
+++ b/src/app/views/deployments/_launch_new.haml
@@ -3,6 +3,6 @@
%h2 Launch new deployment via
- form_tag new_deployment_path, :method => :get do
= label_tag "Deployable:"
- = select_tag :deployable_id,
options_from_collection_for_select(@launchable_deployables, "id",
"name")
+ = 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/_new.haml b/src/app/views/deployments/_new.haml
index 390840d..99cb680 100644
--- a/src/app/views/deployments/_new.haml
+++ b/src/app/views/deployments/_new.haml
@@ -1,7 +1,7 @@
= error_messages_for 'deployment'
%h2 Launch deployable
- form_for @deployment, :url => deployments_path do
- = hidden_field :deployment, :deployable_id
+ = hidden_field :deployment, :legacy_deployable_id
%ul
%li
= label :deployment, :name
@@ -15,7 +15,7 @@
%p
%h3 Assemblies hardware profiles
%ul
- - @deployment.deployable.assemblies.each do |assembly|
+ - @deployment.legacy_deployable.assemblies.each do |assembly|
%li
- hwprofiles = @hardware_profiles.select {|hwp| hwp.architecture.value ==
assembly.templates.first.architecture}
= label_tag "hw_profiles[#{assembly.id}]", assembly.name
diff --git a/src/app/views/legacy_deployables/_assemblies.haml
b/src/app/views/legacy_deployables/_assemblies.haml
new file mode 100644
index 0000000..4b6aaeb
--- /dev/null
+++ b/src/app/views/legacy_deployables/_assemblies.haml
@@ -0,0 +1,30 @@
+.grid_13
+- form_tag do
+ = restful_submit_tag "Remove Selected", 'destroy',
remove_assemblies_legacy_deployable_path(@deployable), 'DELETE', :id =>
'delete_button'
+ = link_to "Add Assembly...",
pick_assemblies_legacy_deployable_path(@deployable), :class => 'button', :id
=> 'add_assembly'
+
+ %table#assemblies_table
+ %thead
+ %tr
+ %th
+ %th= "Name"
+ %th= "Created"
+ -@deployable.assemblies(:include => :templates).each do |assembly|
+ %tr
+ %td
+ %input{:name => "assemblies_selected[]", :type =>
"checkbox", :value => assembly.id, :id =>
"assembly_checkbox_#{assembly.id}" }
+ %td= assembly.name
+ %td= assembly.created_at
+
+:javascript
+ $(document).ready(function () {
+ $('#add_assembly').click(function(e) {
+ e.preventDefault();
+ var url = $(this).attr('href');
+ $.get(url, function(data) {
+ var selectedTabIndex = $("#details-view").tabs('option',
'selected');
+ var $selectedTab = $("#details-view
div.ui-tabs-panel").eq(selectedTabIndex);
+ $selectedTab.html(data);
+ });
+ });
+ });
diff --git a/src/app/views/legacy_deployables/_deployments.haml
b/src/app/views/legacy_deployables/_deployments.haml
new file mode 100644
index 0000000..175b918
--- /dev/null
+++ b/src/app/views/legacy_deployables/_deployments.haml
@@ -0,0 +1,25 @@
+.grid_13
+ %h2 Deployments for #{(a)deployable.name}
+
+ - unless @deployments.empty?
+ - form_tag do
+ %table#deployments_table
+ = sortable_table_header @header_deployments
+ - @deployments.each do |deployment|
+ %tr
+ %td
+ - selected = @url_params[:select] == 'all'
+ %input{:name => "deployments_selected[]", :type =>
"checkbox", :value => deployment.id, :id =>
"deployment_checkbox_#{deployment.id}", :checked => selected }
+ = link_to deployment.name, deployment_path(deployment)
+ %td
+ = deployment.legacy_deployable.name
+ %td
+ = deployment.owner.login
+ %td
+ = deployment.created_at.strftime("%d-%b-%Y %H:%M:%S")
+ %td
+ TODO
+ %td
+ = deployment.pool.name
+ - else
+ No Deployments for #{(a)deployable.name}
diff --git a/src/app/views/legacy_deployables/_form.haml
b/src/app/views/legacy_deployables/_form.haml
new file mode 100644
index 0000000..75d46d0
--- /dev/null
+++ b/src/app/views/legacy_deployables/_form.haml
@@ -0,0 +1,10 @@
+= form.error_messages
+%fieldset.clear
+ = form.label :name, t(:name), :class => "grid_3 alpha"
+ = form.text_field :name, :class => "grid_5"
+%fieldset.clear
+ = form.label :summary, t(:summary), :class => "grid_3 alpha"
+ = form.text_area :summary, :class => "grid_5", :rows => 3
+%fieldset.clearfix
+ = form.submit "Save", :class => "submit formbutton"
+ = link_to t(:cancel), legacy_deployables_path, :class => 'button
formbutton'
diff --git a/src/app/views/legacy_deployables/_list.haml
b/src/app/views/legacy_deployables/_list.haml
new file mode 100644
index 0000000..1fdb80c
--- /dev/null
+++ b/src/app/views/legacy_deployables/_list.haml
@@ -0,0 +1,28 @@
+- form_tag do
+ = link_to "Create", new_legacy_deployable_url, :class => 'button'
+ = restful_submit_tag "Delete", 'destroy',
multi_destroy_legacy_deployables_path, 'DELETE', :id =>
'delete_button'
+
+ %table#deployables_table
+ %thead
+ %tr
+ %th
+ %th= link_to "Name", legacy_deployables_url(:sort_by =>
"name")
+ -(a)deployables.each do |deployable|
+ %tr
+ %td
+ %input{:name => "deployables_selected[]", :type =>
"checkbox", :value => deployable.id, :id =>
"deployable_checkbox_#{deployable.id}" }
+ %td= link_to deployable.name, legacy_deployable_path(deployable)
+
+:javascript
+ $(document).ready(function () {
+ $('#delete_button').click(function(e) {
+ if ($("#deployables_table input[@type=radio]:checked").length == 0) {
+ alert('Please select any deployable to be deleted before clicking Delete
button.');
+ e.preventDefault();
+ } else {
+ if (!confirm("Are you sure you want to delete this deployable?")) {
+ e.preventDefault();
+ }
+ }
+ });
+ });
diff --git a/src/app/views/legacy_deployables/_pick_assemblies.haml
b/src/app/views/legacy_deployables/_pick_assemblies.haml
new file mode 100644
index 0000000..ca4d190
--- /dev/null
+++ b/src/app/views/legacy_deployables/_pick_assemblies.haml
@@ -0,0 +1,16 @@
+.grid_13
+ - form_tag(legacy_deployable_path(@deployable)) do
+ %table#assemblies_list
+ %thead
+ %tr
+ %th
+ %th= "Name"
+ -(a)assemblies.each do |assembly|
+ %tr
+ %td
+ %input{:name => "assemblies_selected[]", :type =>
"checkbox", :value => assembly.id, :id =>
"assembly_checkbox_#{assembly.id}" }
+ %td= assembly.name
+
+ -# AJAX post
+ = restful_submit_tag('Save', 'add_assemblies',
add_assemblies_legacy_deployable_path(@deployable), 'PUT')
+ = link_to "Back", legacy_deployable_path(@deployable, :details_tab =>
'assemblies'), :class => 'button'
diff --git a/src/app/views/legacy_deployables/_properties.haml
b/src/app/views/legacy_deployables/_properties.haml
new file mode 100644
index 0000000..bd66153
--- /dev/null
+++ b/src/app/views/legacy_deployables/_properties.haml
@@ -0,0 +1,8 @@
+.grid_13
+ %h2 #{(a)deployable.name}
+
+ = 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'}
+ - 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/legacy_deployables/edit.haml
b/src/app/views/legacy_deployables/edit.haml
new file mode 100644
index 0000000..d94495e
--- /dev/null
+++ b/src/app/views/legacy_deployables/edit.haml
@@ -0,0 +1,4 @@
+%h2 Editing Deployable: #{(a)deployable.name}
+
+- form_for @deployable, :url => legacy_deployable_path(@deployable), :html => {
:method => :put } do |f|
+ = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/legacy_deployables/index.haml
b/src/app/views/legacy_deployables/index.haml
new file mode 100644
index 0000000..62ccbc6
--- /dev/null
+++ b/src/app/views/legacy_deployables/index.haml
@@ -0,0 +1,2 @@
+- content_for :list do
+ = render :partial => 'list'
diff --git a/src/app/views/legacy_deployables/new.haml
b/src/app/views/legacy_deployables/new.haml
new file mode 100644
index 0000000..4637af5
--- /dev/null
+++ b/src/app/views/legacy_deployables/new.haml
@@ -0,0 +1,3 @@
+%h2 New Deployable
+- form_for @deployable, :url => legacy_deployables_path do |f|
+ = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/legacy_deployables/pick_assemblies.haml
b/src/app/views/legacy_deployables/pick_assemblies.haml
new file mode 100644
index 0000000..c223367
--- /dev/null
+++ b/src/app/views/legacy_deployables/pick_assemblies.haml
@@ -0,0 +1,5 @@
+- content_for :list do
+ = render :partial => 'list'
+
+- content_for :details do
+ = render :partial => 'pick_assemblies'
diff --git a/src/app/views/legacy_deployables/show.haml
b/src/app/views/legacy_deployables/show.haml
new file mode 100644
index 0000000..05eeedd
--- /dev/null
+++ b/src/app/views/legacy_deployables/show.haml
@@ -0,0 +1,5 @@
+- content_for :list do
+ = render :partial => 'list'
+
+- content_for :details do
+ = render :partial => 'layouts/details_pane'
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index 89f0a8d..805e5ff 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -9,7 +9,7 @@ SimpleNavigation::Configuration.run do |navigation|
first_level.item :image_factory, t(:image_factory), templates_path, :highlights_on
=> /\/image_factory/ do |second_level|
second_level.item :templates, t('templates.templates'), templates_path
second_level.item :assemblies, t(:assemblies), assemblies_path
- second_level.item :deployables, t('deployables.index.deployables'),
deployables_path
+ second_level.item :deployables, t('deployables.index.deployables'),
legacy_deployables_path
second_level.item :image_imports, t(:image_imports), new_image_import_path
end
first_level.item :administration, t(:administration), users_path, :highlights_on
=> /\/admin/ do |second_level|
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 5d48373..f61b9f1 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -41,7 +41,7 @@ ActionController::Routing::Routes.draw do |map|
map.resources :assemblies
map.resources :image_imports
- map.resources :deployables, :collection => { :multi_destroy => :delete }, :member
=> { :pick_assemblies => :get, :remove_assemblies => :delete, :add_assemblies
=> :put, :launch => :post }
+ map.resources :legacy_deployables, :collection => { :multi_destroy => :delete },
:member => { :pick_assemblies => :get, :remove_assemblies => :delete,
:add_assemblies => :put, :launch => :post }
map.resources :templates, :collection => {:collections => :get, :add_selected
=> :get, :metagroup_packages => :get, :remove_package => :get, :multi_destroy
=> :delete}
map.connect "/builds/update_status.:format", :controller => :builds,
:action => :update_status
map.resources :builds, :collection => { :delete => :delete, :upload => :get,
:retry => :post }
diff --git a/src/db/migrate/20110112094108_create_deployables.rb
b/src/db/migrate/20110112094108_create_deployables.rb
index 5ec0982..7509927 100644
--- a/src/db/migrate/20110112094108_create_deployables.rb
+++ b/src/db/migrate/20110112094108_create_deployables.rb
@@ -1,6 +1,6 @@
class CreateDeployables < ActiveRecord::Migration
def self.up
- create_table :deployables do |t|
+ create_table :legacy_deployables do |t|
t.string :name
t.timestamps
@@ -8,6 +8,6 @@ class CreateDeployables < ActiveRecord::Migration
end
def self.down
- drop_table :deployables
+ drop_table :legacy_deployables
end
end
diff --git a/src/db/migrate/20110207100800_update_deployables.rb
b/src/db/migrate/20110207100800_update_deployables.rb
index 4414560..58b3675 100644
--- a/src/db/migrate/20110207100800_update_deployables.rb
+++ b/src/db/migrate/20110207100800_update_deployables.rb
@@ -1,6 +1,6 @@
class UpdateDeployables < ActiveRecord::Migration
def self.up
- change_table :deployables do |t|
+ change_table :legacy_deployables do |t|
t.integer :lock_version, :default => 0
t.string :uuid, :null => false
t.binary :xml, :null => false
@@ -9,15 +9,15 @@ class UpdateDeployables < ActiveRecord::Migration
t.boolean :uploaded, :default => false
end
- create_table :assemblies_deployables, :id => false do |t|
+ create_table :assemblies_legacy_deployables, :id => false do |t|
t.integer :assembly_id, :null => false
- t.integer :deployable_id, :null => false
+ t.integer :legacy_deployable_id, :null => false
end
end
def self.down
- drop_table :assemblies_deployables
- change_table :deployables do |t|
+ drop_table :assemblies_legacy_deployables
+ change_table :legacy_deployables do |t|
t.remove :lock_version, :uuid, :xml, :uri, :summary, :uploaded
end
end
diff --git a/src/db/migrate/20110207100900_create_deployments.rb
b/src/db/migrate/20110207100900_create_deployments.rb
index d026f7b..35eb671 100644
--- a/src/db/migrate/20110207100900_create_deployments.rb
+++ b/src/db/migrate/20110207100900_create_deployments.rb
@@ -5,7 +5,7 @@ class CreateDeployments < ActiveRecord::Migration
t.integer :realm_id
t.integer :owner_id
t.integer :pool_id, :null => false
- t.integer :deployable_id, :null => false
+ t.integer :legacy_deployable_id, :null => false
t.integer :lock_version, :default => 0
t.timestamps
end
diff --git a/src/db/migrate/20110207101000_update_instances.rb
b/src/db/migrate/20110207101000_update_instances.rb
index 4b758f7..f326e03 100644
--- a/src/db/migrate/20110207101000_update_instances.rb
+++ b/src/db/migrate/20110207101000_update_instances.rb
@@ -8,7 +8,7 @@ class UpdateInstances < ActiveRecord::Migration
create_table :assemblies_instances, :id => false do |t|
t.integer :assembly_id, :null => false
- t.integer :deployable_id, :null => false
+ t.integer :legacy_deployable_id, :null => false
end
end
diff --git a/src/db/migrate/20110427071851_add_owner_id.rb
b/src/db/migrate/20110427071851_add_owner_id.rb
index 205bea4..2f568d3 100644
--- a/src/db/migrate/20110427071851_add_owner_id.rb
+++ b/src/db/migrate/20110427071851_add_owner_id.rb
@@ -2,12 +2,12 @@ class AddOwnerId < ActiveRecord::Migration
def self.up
add_column :templates, :owner_id, :integer
add_column :assemblies, :owner_id, :integer
- add_column :deployables, :owner_id, :integer
+ add_column :legacy_deployables, :owner_id, :integer
end
def self.down
remove_column :templates, :owner_id
remove_column :assemblies, :owner_id
- remove_column :deployables, :owner_id
+ remove_column :legacy_deployables, :owner_id
end
end
diff --git a/src/features/deployable.feature b/src/features/deployable.feature
index 979ea72..ad92a6f 100644
--- a/src/features/deployable.feature
+++ b/src/features/deployable.feature
@@ -11,16 +11,16 @@ Feature: Manage Deployables
Scenario: List deployables
Given I am on the homepage
And there is a deployable named "MySQL cluster"
- When I go to the deployables page
+ When I go to the legacy_deployables page
Then I should see "MySQL cluster"
Scenario: Create a new Deployable
Given there is a deployable named "MySQL cluster"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "Create"
- Then I should be on the new deployable page
+ Then I should be on the new legacy_deployable page
And I should see "New Deployable"
- When I fill in "deployable[name]" with "App"
+ When I fill in "legacy_deployable[name]" with "App"
And I press "Save"
Then I should be on App's deployable page
And I should see "Deployable added"
@@ -29,12 +29,12 @@ Feature: Manage Deployables
Scenario: Edit a deployable
Given there is a deployable named "MySQL cluster"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "MySQL cluster"
And I follow "Edit"
- Then I should be on the edit deployable page
+ Then I should be on the edit legacy_deployable page
And I should see "Editing Deployable"
- When I fill in "deployable[name]" with "AppModified"
+ When I fill in "legacy_deployable[name]" with "AppModified"
And I press "Save"
Then I should be on AppModified's deployable page
And I should see "Deployable updated"
@@ -43,16 +43,16 @@ Feature: Manage Deployables
Scenario: Delete a deployable
Given there is a deployable named "App"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I check the "App" deployable
And I press "Delete"
- Then I should be on the deployables page
+ Then I should be on the legacy_deployables page
And there should be no deployables
Scenario: Add an assembly to a deployable
Given there is a deployable named "Webserver"
Given there is an assembly named "Apache"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "Webserver"
And I follow "details_Assemblies"
And I follow "Add Assembly..."
@@ -65,7 +65,7 @@ Feature: Manage Deployables
Scenario: Remove an assembly from a deployable
Given there is a deployable named "Webserver"
Given there is an assembly named "Apache" belonging to
"Webserver"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "Webserver"
And I follow "details_Assemblies"
Then I should see "Apache"
@@ -77,7 +77,7 @@ Feature: Manage Deployables
Scenario: Search for deployables
Given there is a deployable named "first"
And there is a deployable named "second"
- And I am on the deployables page
+ And I am on the legacy_deployables page
Then I should see "first"
And I should see "second"
When I fill in "q" with "first"
@@ -101,7 +101,7 @@ Feature: Manage Deployables
Scenario: Create and launch a deployment from a deployable
Given there is a factory deployable named "test1"
- And I am on the deployables page
+ And I am on the legacy_deployables page
And there is "mock_profile" conductor hardware profile
And there is "mock_realm" frontend realm
And there is "mock_pool" pool
diff --git a/src/features/deployable_permissions.feature
b/src/features/deployable_permissions.feature
index 4550d57..d556151 100644
--- a/src/features/deployable_permissions.feature
+++ b/src/features/deployable_permissions.feature
@@ -9,29 +9,29 @@ Feature: Manage Deployables as a non-admin
Scenario: List deployables as a new user
Given I am on the homepage
And there is a deployable named "MySQL cluster"
- When I go to the deployables page
+ When I go to the legacy_deployables page
Then I should see "MySQL cluster"
Scenario: View an existing deployable as a new user
Given there is a deployable named "MySQL cluster"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "MySQL cluster"
Then I should see "Edit"
@allow-rescue
Scenario: Try to edit an existing deployable as a new user
Given there is a deployable named "Apache Webserver"
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "Apache Webserver"
And I follow "Edit"
Then I should see "You have insufficient privileges to perform action."
Scenario: Edit a deployable I created
- Given I am on the deployables page
+ Given I am on the legacy_deployables page
When I follow "Create"
- Then I should be on the new deployable page
+ Then I should be on the new legacy deployable page
And I should see "New Deployable"
- When I fill in "deployable[name]" with "Mahout Server"
+ When I fill in "legacy_deployable[name]" with "Mahout Server"
And I press "Save"
Then I should be on App's deployable page
And I should see "Deployable added"
@@ -39,9 +39,9 @@ Feature: Manage Deployables as a non-admin
And I should see "Mahout Server"
When I follow "Mahout Server"
And I follow "Edit"
- Then I should be on the edit deployable page
+ Then I should be on the edit legacy deployable page
And I should see "Editing Deployable"
- When I fill in "deployable[name]" with "MahoutModified"
+ When I fill in "legacy_deployable[name]" with "MahoutModified"
And I press "Save"
Then I should be on MahoutModified's deployable page
And I should see "Deployable updated"
@@ -49,11 +49,11 @@ Feature: Manage Deployables as a non-admin
And I should see "MahoutModified"
Scenario: Create a deployable as a new user
- And I am on the deployables page
+ And I am on the legacy_deployables page
When I follow "Create"
- Then I should be on the new deployable page
+ Then I should be on the new legacy deployable page
And I should see "New Deployable"
- When I fill in "deployable[name]" with "Solr Server"
+ When I fill in "legacy_deployable[name]" with "Solr Server"
And I press "Save"
Then I should be on App's deployable page
And I should see "Deployable added"
@@ -64,7 +64,7 @@ Feature: Manage Deployables as a non-admin
Scenario: Try to remove an existing assembly as a new user
Given there is a deployable named "Mailserver Cluster"
Given there is an assembly named "Postfix Node" belonging to
"Mailserver Cluster"
- And I am on the deployables page
+ And I am on the legacy_deployables page
Then I should see "Mailserver Cluster"
When I follow "Mailserver Cluster"
And I follow "details_Assemblies"
diff --git a/src/features/deployment.feature b/src/features/deployment.feature
index 515f3f1..3541378 100644
--- a/src/features/deployment.feature
+++ b/src/features/deployment.feature
@@ -33,7 +33,7 @@ Feature: Manage Deployments
When I go to the deployments page
And I follow "New Deployment"
Then I should see "Launch new deployment via"
- When I select "testdeployable" from "deployable_id"
+ When I select "testdeployable" from "legacy_deployable_id"
When I press "Launch"
Then I should see "Launch deployable"
@@ -48,7 +48,7 @@ Feature: Manage Deployments
And I follow "New Deployment"
Then I should see "Launch new deployment via"
And I should get back a partial
- When I select "testdeployable" from "deployable_id"
+ When I select "testdeployable" from "legacy_deployable_id"
When I press "Launch"
Then I should get back a partial
And I should see "Launch deployable"
diff --git a/src/features/step_definitions/assembly_steps.rb
b/src/features/step_definitions/assembly_steps.rb
index bb50b85..26fc4ce 100644
--- a/src/features/step_definitions/assembly_steps.rb
+++ b/src/features/step_definitions/assembly_steps.rb
@@ -3,9 +3,9 @@ Given /^there is an assembly named "([^"]*)"$/ do |name|
end
Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)"$/ do |assembly_name, deployable_name|
- deployable = Deployable.find_by_name(deployable_name)
+ deployable = LegacyDeployable.find_by_name(deployable_name)
deployable.assemblies.create!(:name => assembly_name, :architecture =>
'x86_64', :owner => user)
-# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:deployable => Deployable.find_by_name(deployable))
+# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:legacy_deployable => Deployable.find_by_name(legacy_deployable))
end
Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)" template$/ do |assembly_name, template_name|
@@ -16,7 +16,7 @@ Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)" template$/ d
else
template.assemblies.create!(:name => assembly_name, :architecture =>
'x86_64')
end
-# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:deployable => Deployable.find_by_name(deployable))
+# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:legacy_deployable => Deployable.find_by_name(legacy_deployable))
end
When /^I check the "([^"]*)" assembly$/ do |name|
diff --git a/src/features/step_definitions/deployable_steps.rb
b/src/features/step_definitions/deployable_steps.rb
index 374d43e..545e15c 100644
--- a/src/features/step_definitions/deployable_steps.rb
+++ b/src/features/step_definitions/deployable_steps.rb
@@ -1,34 +1,34 @@
Then /^there should be no deployables$/ do
- Deployable.count.should == 0
+ LegacyDeployable.count.should == 0
end
Given /^there are no deployables$/ do
- Deployable.count.should == 0
+ LegacyDeployable.count.should == 0
end
Then /^I should have a deployable named "([^"]*)"$/ do |name|
- Deployable.find_by_name(name).should_not be_nil
+ LegacyDeployable.find_by_name(name).should_not be_nil
end
Given /^there is a deployable named "([^"]*)"$/ do |name|
- @deployable = Deployable.create!(:name => name, :owner => user)
+ @deployable = LegacyDeployable.create!(:name => name, :owner => user)
end
When /^I check the "([^"]*)" deployable$/ do |name|
- deployable = Deployable.find_by_name(name)
+ deployable = LegacyDeployable.find_by_name(name)
check("deployable_checkbox_#{deployable.id}")
end
Given /^there are deployment named "([^"]*)" belongs to
"([^"]*)"$/ do |deployment_name, deployable_name|
- Factory(:deployment, :deployable => Deployable.find_by_name(deployable_name), :name
=> deployment_name)
+ Factory(:deployment, :legacy_deployable =>
LegacyDeployable.find_by_name(deployable_name), :name => deployment_name)
end
Given /^there is a factory deployable named "([^"]*)"$/ do |arg1|
- Factory(:deployable, :name => arg1)
+ Factory(:legacy_deployable, :name => arg1)
end
When /^I select default hardware profile for assemblies in "([^"]*)"$/ do
|arg1|
- deployable = Deployable.find_by_name(arg1)
+ deployable = LegacyDeployable.find_by_name(arg1)
deployable.assemblies.each do |a|
select('mock_profile', :from => "hw_profiles_#{a.id}")
end
diff --git a/src/features/step_definitions/deployment_steps.rb
b/src/features/step_definitions/deployment_steps.rb
index 874b612..b1d516c 100644
--- a/src/features/step_definitions/deployment_steps.rb
+++ b/src/features/step_definitions/deployment_steps.rb
@@ -1,7 +1,7 @@
Given /^there is a deployment named "([^"]*)" belonging to
"([^"]*)" owned by "([^"]*)"$/ do |deployment_name,
deployable_name, owner_name|
user = Factory(:user, :login => owner_name, :last_name => owner_name)
- deployable = Deployable.create!(:name => deployable_name, :owner => user)
- @deployment = Deployment.create!({:name => deployment_name, :pool => Pool.first,
:owner => user, :deployable_id => deployable.id})
+ deployable = LegacyDeployable.create!(:name => deployable_name, :owner => user)
+ @deployment = Deployment.create!({:name => deployment_name, :pool => Pool.first,
:owner => user, :legacy_deployable_id => deployable.id})
end
When /^I check "([^"]*)" deployment/ do |name|
@@ -38,9 +38,9 @@ end
When /^I create a deployment$/ do
deployment = Factory.build :deployment
deployment.pool.save!
- deployment.deployable.save!
+ deployment.legacy_deployable.save!
visit(deployments_url, :post, 'deployment[name]' => deployment.name,
- 'deployment[pool_id]' => deployment.pool.id,
'deployment[deployable_id]' => deployment.deployable.id)
+ 'deployment[pool_id]' => deployment.pool.id,
'deployment[legacy_deployable_id]' => deployment.legacy_deployable.id)
end
Then /^I should get back a deployment in JSON format$/ do
diff --git a/src/features/step_definitions/pool_steps.rb
b/src/features/step_definitions/pool_steps.rb
index 91d8a6a..517d36f 100644
--- a/src/features/step_definitions/pool_steps.rb
+++ b/src/features/step_definitions/pool_steps.rb
@@ -26,8 +26,8 @@ Given /^a pool "([^"]*)" exists with deployment
"([^"]*)"$/ do |pool_name, deplo
pool_family = PoolFamily.find_by_name('default') || Factory(:pool_family)
quota = Factory(:quota)
pool = Pool.find_by_name(pool_name) || Pool.create!(:name => pool_name, :pool_family
=> pool_family, :quota => quota)
- deployable = Deployable.create!(:name => 'deployable1', :owner =>
User.first)
- Deployment.create!(:name => deployment_name, :pool => pool, :deployable =>
deployable, :owner => User.first)
+ deployable = LegacyDeployable.create!(:name => 'deployable1', :owner =>
User.first)
+ Deployment.create!(:name => deployment_name, :pool => pool, :legacy_deployable
=> deployable, :owner => User.first)
end
Then /^I should have a pool named "([^\"]*)"$/ do |name|
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index b6ee8d5..7007fb8 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -114,13 +114,13 @@ module NavigationHelpers
provider_account_path(ProviderAccount.find_by_label($1))
when /the deployable deployments page/
- deployable_path(@deployable, :details_tab => 'deployments')
+ legacy_deployable_path(@deployable, :details_tab => 'deployments')
when /the operational status of deployment page/
deployment_path(@deployment, :details_tab => 'operation')
when /^(.*)'s deployable page$/
- deployable_path(Deployable.find_by_name($1))
+ legacy_deployable_path(LegacyDeployable.find_by_name($1))
when /^(.*)'s edit deployment page$/
edit_deployment_path(Deployment.find_by_name($1))
diff --git a/src/features/template.feature b/src/features/template.feature
index 90c1ed5..4f41f61 100644
--- a/src/features/template.feature
+++ b/src/features/template.feature
@@ -224,5 +224,5 @@ Feature: Manage Templates
And I press "Save"
Then I should be on the templates page
And I should see "mocktemplate"
- When I go to the deployables page
+ When I go to the legacy_deployables page
And I should see "mocktemplate"
diff --git a/src/spec/factories/deployable.rb b/src/spec/factories/deployable.rb
index 62699ba..40051f6 100644
--- a/src/spec/factories/deployable.rb
+++ b/src/spec/factories/deployable.rb
@@ -1,4 +1,4 @@
-Factory.define :deployable do |a|
+Factory.define :legacy_deployable do |a|
a.sequence(:name) { |n| "deployable#{n}" }
a.assemblies { |t| [t.association(:assembly)] }
a.association :owner, :factory => :user
diff --git a/src/spec/factories/deployment.rb b/src/spec/factories/deployment.rb
index f3c0522..b01d42b 100644
--- a/src/spec/factories/deployment.rb
+++ b/src/spec/factories/deployment.rb
@@ -1,6 +1,6 @@
Factory.define :deployment do |d|
d.sequence(:name) { |n| "deployment#{n}" }
- d.association :deployable, :factory => :deployable
+ d.association :legacy_deployable, :factory => :legacy_deployable
d.association :pool, :factory => :pool
d.association :owner, :factory => :user
end
diff --git a/src/spec/models/deployable_spec.rb b/src/spec/models/deployable_spec.rb
index aec4518..2a5be81 100644
--- a/src/spec/models/deployable_spec.rb
+++ b/src/spec/models/deployable_spec.rb
@@ -1,16 +1,16 @@
require 'spec_helper'
-describe Deployable do
+describe LegacyDeployable do
it "should have automatically generated uuid after validation" do
- d = Factory.build(:deployable)
+ d = Factory.build(:legacy_deployable)
d.uuid = nil
d.save
d.uuid.should_not be_nil
end
it "should not be valid if deployable name is too long" do
- d = Factory.build(:deployable)
+ d = Factory.build(:legacy_deployable)
d.name = ('a' * 256)
d.valid?.should be_false
d.errors[:name].should_not be_nil
@@ -18,26 +18,26 @@ describe Deployable do
end
it "should have associated assembly" do
- d = Factory.build(:deployable)
+ d = Factory.build(:legacy_deployable)
d.assemblies.size.should eql(1)
end
it "should not be destroyable when it has running instances" do
- deployable = Factory.create(:deployable)
- deployment = Factory.create(:deployment, :deployable_id => deployable.id)
+ deployable = Factory.create(:legacy_deployable)
+ deployment = Factory.create(:deployment, :legacy_deployable_id => deployable.id)
assembly = Factory.create(:assembly)
instance = Factory.create(:instance, :deployment_id => deployment.id, :assembly_id
=> assembly.id, :template_id => nil)
- Deployable.find(deployable).should_not be_destroyable
+ LegacyDeployable.find(deployable).should_not be_destroyable
instance.state = Instance::STATE_STOPPED
instance.save!
- Deployable.find(deployable).should be_destroyable
+ LegacyDeployable.find(deployable).should be_destroyable
end
it "should not be destroyable when it has stopped stateful instances" do
- deployable = Factory.build(:deployable)
- deployment = Factory.build(:deployment, :deployable_id => deployable.id)
+ deployable = Factory.build(:legacy_deployable)
+ deployment = Factory.build(:deployment, :legacy_deployable_id => deployable.id)
deployable.deployments << deployment
assembly = Factory.build(:assembly)
diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
index 0d91cd9..4b1f3b4 100644
--- a/src/spec/models/deployment_spec.rb
+++ b/src/spec/models/deployment_spec.rb
@@ -17,10 +17,10 @@ describe Deployment do
end
it "should require deployable to be set" do
- @deployment.deployable_id = nil
+ @deployment.legacy_deployable_id = nil
@deployment.should_not be_valid
- @deployment.deployable_id = 1
+ @deployment.legacy_deployable_id = 1
@deployment.should be_valid
end
@@ -59,16 +59,16 @@ describe Deployment do
hwp = Factory(:mock_hwp1)
hwp_ids = {}
@deployment.save!
- @deployment.deployable.assemblies.each {|a| hwp_ids[a.id.to_s] = hwp.id}
+ @deployment.legacy_deployable.assemblies.each {|a| hwp_ids[a.id.to_s] = hwp.id}
@deployment.instances.should be_empty
errs = @deployment.launch(hwp_ids, Factory(:user))
errs.should be_empty
- @deployment.instances.count.should == @deployment.deployable.assemblies.count
+ @deployment.instances.count.should == @deployment.legacy_deployable.assemblies.count
end
it "should not launch a deployment if deployable has not assemblies" do
@deployment.save!
- @deployment.deployable.assemblies = []
+ @deployment.legacy_deployable.assemblies = []
lambda {(a)deployment.launch}.should raise_exception
end
--
1.7.4.4