From: Jiri Tomasek <jtomasek(a)redhat.com>
---
src/app/controllers/assemblies_controller.rb | 6 -
src/app/controllers/builds_controller.rb | 28 +-
src/app/controllers/deployments_controller.rb | 2 +-
src/app/controllers/image_imports_controller.rb | 4 +-
src/app/controllers/instances_controller.rb | 22 +-
.../controllers/legacy_assemblies_controller.rb | 6 +
.../controllers/legacy_deployables_controller.rb | 14 +-
src/app/controllers/legacy_templates_controller.rb | 301 ++++++++++++++++++++
src/app/controllers/templates_controller.rb | 301 --------------------
src/app/helpers/legacy_templates_helper.rb | 8 +
src/app/helpers/templates_helper.rb | 8 -
src/app/models/assembly.rb | 84 ------
src/app/models/build_job.rb | 4 +-
src/app/models/deployment.rb | 4 +-
src/app/models/image.rb | 245 ----------------
src/app/models/instance.rb | 16 +-
src/app/models/legacy_assembly.rb | 86 ++++++
src/app/models/legacy_deployable.rb | 10 +-
src/app/models/legacy_image.rb | 245 ++++++++++++++++
src/app/models/legacy_provider_image.rb | 10 +-
src/app/models/legacy_template.rb | 186 ++++++++++++
src/app/models/permission.rb | 4 +-
src/app/models/privilege.rb | 2 +-
src/app/models/provider_type.rb | 2 +-
src/app/models/push_job.rb | 2 +-
src/app/models/template.rb | 186 ------------
src/app/util/condormatic.rb | 4 +-
src/app/views/assemblies/index.haml | 1 -
src/app/views/deployments/_new.haml | 4 +-
src/app/views/deployments/new.haml | 2 +-
src/app/views/instances/_list.haml | 4 +-
src/app/views/instances/_new.haml | 6 +-
src/app/views/instances/_properties.haml | 10 +-
src/app/views/instances/new.haml | 2 +-
.../views/instances/select_legacy_template.haml | 19 ++
src/app/views/instances/select_template.haml | 19 --
src/app/views/layouts/application.haml | 2 +-
src/app/views/legacy_assemblies/index.haml | 1 +
src/app/views/legacy_deployables/_assemblies.haml | 2 +-
src/app/views/legacy_templates/_addbuttons.haml | 4 +
src/app/views/legacy_templates/_basics.haml | 27 ++
src/app/views/legacy_templates/_builds.haml | 41 +++
src/app/views/legacy_templates/_collections.haml | 8 +
src/app/views/legacy_templates/_form.haml | 120 ++++++++
src/app/views/legacy_templates/_hidden_fields.haml | 8 +
src/app/views/legacy_templates/_list.haml | 35 +++
.../legacy_templates/_local_content_to_bundle.haml | 21 ++
.../views/legacy_templates/_managed_content.haml | 21 ++
.../legacy_templates/_metagroup_packages.haml | 19 ++
src/app/views/legacy_templates/_metagroups.haml | 13 +
.../legacy_templates/_preboot_configuration.haml | 11 +
src/app/views/legacy_templates/_properties.haml | 4 +
.../views/legacy_templates/_search_packages.haml | 45 +++
.../legacy_templates/_software_selection.haml | 41 +++
src/app/views/legacy_templates/collections.haml | 1 +
src/app/views/legacy_templates/edit.haml | 9 +
src/app/views/legacy_templates/index.haml | 2 +
.../views/legacy_templates/managed_content.haml | 1 +
.../views/legacy_templates/metagroup_packages.haml | 1 +
src/app/views/legacy_templates/new.haml | 10 +
.../views/legacy_templates/search_packages.haml | 1 +
src/app/views/legacy_templates/show.haml | 5 +
.../xml/_hardware_profile.xml.haml | 6 +
.../xml/_hardware_profile_property.xml.haml | 9 +
src/app/views/pools/_instances.haml | 2 +-
src/app/views/templates/_addbuttons.haml | 4 -
src/app/views/templates/_basics.haml | 27 --
src/app/views/templates/_builds.haml | 41 ---
src/app/views/templates/_collections.haml | 8 -
src/app/views/templates/_form.haml | 120 --------
src/app/views/templates/_hidden_fields.haml | 8 -
src/app/views/templates/_list.haml | 35 ---
.../views/templates/_local_content_to_bundle.haml | 21 --
src/app/views/templates/_managed_content.haml | 21 --
src/app/views/templates/_metagroup_packages.haml | 19 --
src/app/views/templates/_metagroups.haml | 13 -
.../views/templates/_preboot_configuration.haml | 11 -
src/app/views/templates/_properties.haml | 4 -
src/app/views/templates/_search_packages.haml | 45 ---
src/app/views/templates/_software_selection.haml | 41 ---
src/app/views/templates/collections.haml | 1 -
src/app/views/templates/edit.haml | 9 -
src/app/views/templates/index.haml | 2 -
src/app/views/templates/managed_content.haml | 1 -
src/app/views/templates/metagroup_packages.haml | 1 -
src/app/views/templates/new.haml | 10 -
src/app/views/templates/search_packages.haml | 1 -
src/app/views/templates/show.haml | 5 -
.../views/templates/xml/_hardware_profile.xml.haml | 6 -
.../xml/_hardware_profile_property.xml.haml | 9 -
src/config/locales/en.yml | 4 +-
src/config/navigation.rb | 6 +-
src/config/routes.rb | 6 +-
src/db/migrate/20090804140143_create_images.rb | 48 ---
.../migrate/20090804140143_create_legacy_images.rb | 48 +++
src/db/migrate/20090804142049_create_instances.rb | 2 +-
.../20100830150014_create_legacy_templates.rb | 23 ++
src/db/migrate/20100830150014_create_templates.rb | 23 --
src/db/migrate/20110119000000_owner_roles.rb | 2 +-
...0110202165053_change_column_target_in_images.rb | 11 -
...165053_change_column_target_in_legacy_images.rb | 11 +
src/db/migrate/20110207100700_create_assemblies.rb | 24 --
.../20110207100700_create_legacy_assemblies.rb | 24 ++
.../migrate/20110207100800_update_deployables.rb | 6 +-
src/db/migrate/20110207101000_update_instances.rb | 12 +-
src/db/migrate/20110207101100_deployment_roles.rb | 2 +-
...0110223132404_add_target_id_column_to_images.rb | 28 --
...132404_add_target_id_column_to_legacy_images.rb | 28 ++
...10322120000_add_legacy_template_creator_role.rb | 47 +++
.../20110322120000_add_template_creator_role.rb | 47 ---
src/db/migrate/20110427071851_add_owner_id.rb | 8 +-
src/db/seeds.rb | 12 +-
src/features/image_import.feature | 2 +-
src/features/legacy_template.feature | 228 +++++++++++++++
src/features/step_definitions/assembly_steps.rb | 25 --
src/features/step_definitions/instance_steps.rb | 2 +-
.../step_definitions/legacy_assembly_steps.rb | 25 ++
.../step_definitions/legacy_deployable_steps.rb | 2 +-
.../step_definitions/legacy_template_steps.rb | 130 +++++++++
src/features/step_definitions/template_steps.rb | 130 ---------
src/features/support/custom.rb | 2 +-
src/features/support/paths.rb | 8 +-
src/features/template.feature | 228 ---------------
src/lib/tasks/dc_tasks.rake | 4 +-
src/lib/tasks/demo_data.rake | 2 +-
src/spec/controllers/builds_controller_spec.rb | 32 +-
src/spec/controllers/instance_controller_spec.rb | 28 +-
.../legacy_templates_controller_spec.rb | 18 ++
src/spec/controllers/templates_controller_spec.rb | 18 --
src/spec/factories/assembly.rb | 6 -
src/spec/factories/build_job.rb | 2 +-
src/spec/factories/image.rb | 15 -
src/spec/factories/instance.rb | 2 +-
src/spec/factories/legacy_assembly.rb | 6 +
src/spec/factories/legacy_deployable.rb | 2 +-
src/spec/factories/legacy_image.rb | 15 +
src/spec/factories/legacy_provider_image.rb | 2 +-
src/spec/factories/legacy_template.rb | 11 +
src/spec/factories/template.rb | 11 -
src/spec/models/assembly_spec.rb | 25 --
src/spec/models/deployment_spec.rb | 8 +-
src/spec/models/image_spec.rb | 75 -----
src/spec/models/instance_spec.rb | 14 +-
src/spec/models/legacy_assembly_spec.rb | 25 ++
src/spec/models/legacy_deployable_spec.rb | 10 +-
src/spec/models/legacy_image_spec.rb | 75 +++++
src/spec/models/legacy_provider_image_spec.rb | 2 +-
src/spec/models/legacy_template_spec.rb | 46 +++
src/spec/models/template_spec.rb | 46 ---
src/spec/services/registration_service_spec.rb | 4 +-
src/warehouse_sync/warehouse_sync.rb | 6 +-
151 files changed, 2253 insertions(+), 2251 deletions(-)
delete mode 100644 src/app/controllers/assemblies_controller.rb
create mode 100644 src/app/controllers/legacy_assemblies_controller.rb
create mode 100644 src/app/controllers/legacy_templates_controller.rb
delete mode 100644 src/app/controllers/templates_controller.rb
create mode 100644 src/app/helpers/legacy_templates_helper.rb
delete mode 100644 src/app/helpers/templates_helper.rb
delete mode 100644 src/app/models/assembly.rb
delete mode 100644 src/app/models/image.rb
create mode 100644 src/app/models/legacy_assembly.rb
create mode 100644 src/app/models/legacy_image.rb
create mode 100644 src/app/models/legacy_template.rb
delete mode 100644 src/app/models/template.rb
delete mode 100644 src/app/views/assemblies/index.haml
create mode 100644 src/app/views/instances/select_legacy_template.haml
delete mode 100644 src/app/views/instances/select_template.haml
create mode 100644 src/app/views/legacy_assemblies/index.haml
create mode 100644 src/app/views/legacy_templates/_addbuttons.haml
create mode 100644 src/app/views/legacy_templates/_basics.haml
create mode 100644 src/app/views/legacy_templates/_builds.haml
create mode 100644 src/app/views/legacy_templates/_collections.haml
create mode 100644 src/app/views/legacy_templates/_form.haml
create mode 100644 src/app/views/legacy_templates/_hidden_fields.haml
create mode 100644 src/app/views/legacy_templates/_list.haml
create mode 100644 src/app/views/legacy_templates/_local_content_to_bundle.haml
create mode 100644 src/app/views/legacy_templates/_managed_content.haml
create mode 100644 src/app/views/legacy_templates/_metagroup_packages.haml
create mode 100644 src/app/views/legacy_templates/_metagroups.haml
create mode 100644 src/app/views/legacy_templates/_preboot_configuration.haml
create mode 100644 src/app/views/legacy_templates/_properties.haml
create mode 100644 src/app/views/legacy_templates/_search_packages.haml
create mode 100644 src/app/views/legacy_templates/_software_selection.haml
create mode 100644 src/app/views/legacy_templates/collections.haml
create mode 100644 src/app/views/legacy_templates/edit.haml
create mode 100644 src/app/views/legacy_templates/index.haml
create mode 100644 src/app/views/legacy_templates/managed_content.haml
create mode 100644 src/app/views/legacy_templates/metagroup_packages.haml
create mode 100644 src/app/views/legacy_templates/new.haml
create mode 100644 src/app/views/legacy_templates/search_packages.haml
create mode 100644 src/app/views/legacy_templates/show.haml
create mode 100644 src/app/views/legacy_templates/xml/_hardware_profile.xml.haml
create mode 100644
src/app/views/legacy_templates/xml/_hardware_profile_property.xml.haml
delete mode 100644 src/app/views/templates/_addbuttons.haml
delete mode 100644 src/app/views/templates/_basics.haml
delete mode 100644 src/app/views/templates/_builds.haml
delete mode 100644 src/app/views/templates/_collections.haml
delete mode 100644 src/app/views/templates/_form.haml
delete mode 100644 src/app/views/templates/_hidden_fields.haml
delete mode 100644 src/app/views/templates/_list.haml
delete mode 100644 src/app/views/templates/_local_content_to_bundle.haml
delete mode 100644 src/app/views/templates/_managed_content.haml
delete mode 100644 src/app/views/templates/_metagroup_packages.haml
delete mode 100644 src/app/views/templates/_metagroups.haml
delete mode 100644 src/app/views/templates/_preboot_configuration.haml
delete mode 100644 src/app/views/templates/_properties.haml
delete mode 100644 src/app/views/templates/_search_packages.haml
delete mode 100644 src/app/views/templates/_software_selection.haml
delete mode 100644 src/app/views/templates/collections.haml
delete mode 100644 src/app/views/templates/edit.haml
delete mode 100644 src/app/views/templates/index.haml
delete mode 100644 src/app/views/templates/managed_content.haml
delete mode 100644 src/app/views/templates/metagroup_packages.haml
delete mode 100644 src/app/views/templates/new.haml
delete mode 100644 src/app/views/templates/search_packages.haml
delete mode 100644 src/app/views/templates/show.haml
delete mode 100644 src/app/views/templates/xml/_hardware_profile.xml.haml
delete mode 100644 src/app/views/templates/xml/_hardware_profile_property.xml.haml
delete mode 100644 src/db/migrate/20090804140143_create_images.rb
create mode 100644 src/db/migrate/20090804140143_create_legacy_images.rb
create mode 100644 src/db/migrate/20100830150014_create_legacy_templates.rb
delete mode 100644 src/db/migrate/20100830150014_create_templates.rb
delete mode 100644 src/db/migrate/20110202165053_change_column_target_in_images.rb
create mode 100644
src/db/migrate/20110202165053_change_column_target_in_legacy_images.rb
delete mode 100644 src/db/migrate/20110207100700_create_assemblies.rb
create mode 100644 src/db/migrate/20110207100700_create_legacy_assemblies.rb
delete mode 100644 src/db/migrate/20110223132404_add_target_id_column_to_images.rb
create mode 100644
src/db/migrate/20110223132404_add_target_id_column_to_legacy_images.rb
create mode 100644 src/db/migrate/20110322120000_add_legacy_template_creator_role.rb
delete mode 100644 src/db/migrate/20110322120000_add_template_creator_role.rb
create mode 100644 src/features/legacy_template.feature
delete mode 100644 src/features/step_definitions/assembly_steps.rb
create mode 100644 src/features/step_definitions/legacy_assembly_steps.rb
create mode 100644 src/features/step_definitions/legacy_template_steps.rb
delete mode 100644 src/features/step_definitions/template_steps.rb
delete mode 100644 src/features/template.feature
create mode 100644 src/spec/controllers/legacy_templates_controller_spec.rb
delete mode 100644 src/spec/controllers/templates_controller_spec.rb
delete mode 100644 src/spec/factories/assembly.rb
delete mode 100644 src/spec/factories/image.rb
create mode 100644 src/spec/factories/legacy_assembly.rb
create mode 100644 src/spec/factories/legacy_image.rb
create mode 100644 src/spec/factories/legacy_template.rb
delete mode 100644 src/spec/factories/template.rb
delete mode 100644 src/spec/models/assembly_spec.rb
delete mode 100644 src/spec/models/image_spec.rb
create mode 100644 src/spec/models/legacy_assembly_spec.rb
create mode 100644 src/spec/models/legacy_image_spec.rb
create mode 100644 src/spec/models/legacy_template_spec.rb
delete mode 100644 src/spec/models/template_spec.rb
diff --git a/src/app/controllers/assemblies_controller.rb
b/src/app/controllers/assemblies_controller.rb
deleted file mode 100644
index c109039..0000000
--- a/src/app/controllers/assemblies_controller.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AssembliesController < ApplicationController
- before_filter :require_user
-
- def index
- end
-end
diff --git a/src/app/controllers/builds_controller.rb
b/src/app/controllers/builds_controller.rb
index b348b8b..18e891d 100644
--- a/src/app/controllers/builds_controller.rb
+++ b/src/app/controllers/builds_controller.rb
@@ -5,37 +5,37 @@ class BuildsController < ApplicationController
end
def create
- @tpl = Template.find(params[:template_id])
+ @tpl = LegacyTemplate.find(params[:legacy_template_id])
check_permission
errors = {}
warnings = []
begin
target = ProviderType.find(params[:target])
- Image.create_and_build!(@tpl, target)
+ LegacyImage.create_and_build!(@tpl, target)
rescue
flash[:error] = "Warning: #{$!.message}"
logger.error $!.message
logger.error $!.backtrace.join("\n ")
end
- redirect_to template_path(@tpl, :details_tab => 'builds')
+ redirect_to legacy_template_path(@tpl, :details_tab => 'builds')
end
def upload
- @tpl = Template.find(params[:template_id])
+ @tpl = LegacyTemplate.find(params[:template_id])
pimg = LegacyProviderImage.create!(
- :image => Image.find(params[:image_id]),
+ :legacy_image => LegacyImage.find(params[:image_id]),
:provider => Provider.find(params[:provider_id]),
:status => LegacyProviderImage::STATE_QUEUED
)
Delayed::Job.enqueue(PushJob.new(pimg.id))
- redirect_to template_path(@tpl, :details_tab => 'builds')
+ redirect_to legacy_template_path(@tpl, :details_tab => 'builds')
end
def delete
- @tpl = Template.find(params[:template_id])
+ @tpl = LegacyTemplate.find(params[:template_id])
# FIXME: add logic to delete image when v2 image factory lands
- redirect_to template_path(@tpl, :details_tab => 'builds')
+ redirect_to legacy_template_path(@tpl, :details_tab => 'builds')
end
def edit
@@ -47,11 +47,11 @@ class BuildsController < ApplicationController
end
def retry
- @tpl = Template.find(params[:template_id])
+ @tpl = LegacyTemplate.find(params[:legacy_template_id])
check_permission
begin
- if params[:image_id]
- image = Image.find(params[:image_id])
+ if params[:legacy_image_id]
+ image = LegacyImage.find(params[:legacy_image_id])
if image
errors = {}
warnings = []
@@ -76,11 +76,11 @@ class BuildsController < ApplicationController
logger.error $!.message
logger.error $!.backtrace.join("\n ")
end
- redirect_to template_path(@tpl, :details_tab => 'builds')
+ redirect_to legacy_template_path(@tpl, :details_tab => 'builds')
end
def update_status
- image = Image.find_by_uuid(params[:uuid])
+ image = LegacyImage.find_by_uuid(params[:uuid])
image = LegacyProviderImage.find_by_uuid(params[:uuid]) unless image
if image
@@ -97,7 +97,7 @@ class BuildsController < ApplicationController
end
private
- # TODO: DRY this, is used in templates controller too
+ # TODO: DRY this, is used in legacy_templates controller too
def get_order(default)
@order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
@order_field = params[:order_field] || default
diff --git a/src/app/controllers/deployments_controller.rb
b/src/app/controllers/deployments_controller.rb
index 355ac1f..900fe44 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -28,7 +28,7 @@ class DeploymentsController < ApplicationController
require_privilege(Privilege::CREATE, Deployment)
@deployment = Deployment.new(:legacy_deployable_id =>
params[:legacy_deployable_id])
respond_to do |format|
- if @deployment.legacy_deployable.assemblies.empty?
+ if @deployment.legacy_deployable.legacy_assemblies.empty?
flash[:warning] = "Deployable must have at least one assembly"
format.js do
load_deployments
diff --git a/src/app/controllers/image_imports_controller.rb
b/src/app/controllers/image_imports_controller.rb
index 90602d3..de73ad2 100644
--- a/src/app/controllers/image_imports_controller.rb
+++ b/src/app/controllers/image_imports_controller.rb
@@ -7,9 +7,9 @@ class ImageImportsController < ApplicationController
def create
begin
- Image.import(ProviderAccount.find(params[:provider_account_id]), params[:ami_id],
current_user)
+ LegacyImage.import(ProviderAccount.find(params[:provider_account_id]),
params[:ami_id], current_user)
flash[:notice]="Image successfully imported"
- redirect_to templates_path
+ redirect_to legacy_templates_path
rescue Exception => e
init_provider_vars
# The full message may be multiple lines, including the actual request, so only
include the first line:
diff --git a/src/app/controllers/instances_controller.rb
b/src/app/controllers/instances_controller.rb
index f75e5eb..73afd3d 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -24,8 +24,8 @@ class InstancesController < ApplicationController
@instance = Instance.new(params[:instance])
require_privilege(Privilege::CREATE, Instance, @instance.pool) if @instance.pool
- unless @instance.template
- redirect_to select_template_instances_path
+ unless @instance.legacy_template
+ redirect_to select_legacy_template_instances_path
return
end
@@ -37,23 +37,23 @@ class InstancesController < ApplicationController
end
end
- def select_template
- # FIXME: we need to list only templates for particular user,
+ def select_legacy_template
+ # FIXME: we need to list only legacy_templates for particular user,
# => TODO: add TEMPLATE_* permissions
- @templates = Template.paginate(
+ @legacy_templates = LegacyTemplate.paginate(
:page => params[:page] || 1,
- :include => {:images => :legacy_provider_images},
+ :include => {:legacy_images => :legacy_provider_images},
:conditions => "legacy_provider_images.status =
'#{LegacyProviderImage::STATE_COMPLETED}'"
)
respond_to do |format|
format.html
- format.json { render :json => @templates }
+ format.json { render :json => @legacy_templates }
end
end
def create
if params[:cancel]
- redirect_to select_template_instances_path
+ redirect_to select_legacy_template_instances_path
return
end
@@ -300,7 +300,7 @@ class InstancesController < ApplicationController
:include => :architecture,
:conditions => {
:provider_id => nil,
- 'hardware_profile_properties.value' =>
@instance.template.architecture
+ 'hardware_profile_properties.value' =>
@instance.legacy_template.architecture
}
)
end
@@ -309,7 +309,7 @@ class InstancesController < ApplicationController
@header = [
{:name => 'VM NAME', :sort_attr => 'name'},
{:name => 'STATUS', :sortable => false},
- {:name => 'TEMPLATE', :sort_attr => 'templates.name'},
+ {:name => 'TEMPLATE', :sort_attr =>
'legacy_templates.name'},
{:name => 'PUBLIC ADDRESS', :sort_attr =>
'public_addresses'},
{:name => 'PROVIDER', :sortable => false},
{:name => 'CREATED BY', :sort_attr => 'users.last_name'},
@@ -319,7 +319,7 @@ class InstancesController < ApplicationController
end
def load_instances
- @instances = Instance.all(:include => [:template, :owner],
+ @instances = Instance.all(:include => [:legacy_template, :owner],
:conditions => {:pool_id => @pools},
:order => (params[:order_field] || 'name')
+' '+ (params[:order_dir] || 'asc')
)
diff --git a/src/app/controllers/legacy_assemblies_controller.rb
b/src/app/controllers/legacy_assemblies_controller.rb
new file mode 100644
index 0000000..300db23
--- /dev/null
+++ b/src/app/controllers/legacy_assemblies_controller.rb
@@ -0,0 +1,6 @@
+class LegacyAssembliesController < ApplicationController
+ before_filter :require_user
+
+ def index
+ end
+end
diff --git a/src/app/controllers/legacy_deployables_controller.rb
b/src/app/controllers/legacy_deployables_controller.rb
index 6ef295b..0024cf7 100644
--- a/src/app/controllers/legacy_deployables_controller.rb
+++ b/src/app/controllers/legacy_deployables_controller.rb
@@ -4,7 +4,7 @@ class LegacyDeployablesController < ApplicationController
before_filter :load_deployable_with_assemblies, :only => [:remove_assemblies,
:add_assemblies, :pick_assemblies]
def index
- require_privilege(Privilege::VIEW, Template)
+ require_privilege(Privilege::VIEW, LegacyTemplate)
@search_term = params[:q]
return if @search_term.blank?
search = LegacyDeployable.search() do
@@ -34,12 +34,12 @@ class LegacyDeployablesController < ApplicationController
end
def new
- require_privilege(Privilege::CREATE, Template)
+ require_privilege(Privilege::CREATE, LegacyTemplate)
@deployable = LegacyDeployable.new
end
def create
- require_privilege(Privilege::CREATE, Template)
+ require_privilege(Privilege::CREATE, LegacyTemplate)
@deployable = LegacyDeployable.new(params[:legacy_deployable])
@deployable.owner = current_user
if @deployable.save
@@ -89,7 +89,7 @@ class LegacyDeployablesController < ApplicationController
def pick_assemblies
require_privilege(Privilege::MODIFY, @deployable)
- @assemblies = Assembly.all - @deployable.assemblies
+ @assemblies = LegacyAssembly.all - @deployable.legacy_assemblies
respond_to do |format|
format.js { render :partial => 'pick_assemblies' }
format.html { render 'pick_assemblies' }
@@ -99,7 +99,7 @@ class LegacyDeployablesController < ApplicationController
def add_assemblies
require_privilege(Privilege::MODIFY, @deployable)
if assemblies = params.delete(:assemblies_selected)
- @deployable.assembly_ids += assemblies.collect{|a| a.to_i}
+ @deployable.legacy_assembly_ids += assemblies.collect{|a| a.to_i}
@deployable.save!
flash[:notice] = "Assemblies saved."
end
@@ -112,7 +112,7 @@ class LegacyDeployablesController < ApplicationController
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.legacy_assembly_ids = @deployable.legacy_assembly_ids -
params[:assemblies_selected].collect{|a| a.to_i}
@deployable.save!
flash[:notice] = "Assemblies removed."
end
@@ -144,6 +144,6 @@ class LegacyDeployablesController < ApplicationController
end
def load_deployable_with_assemblies
- @deployable = LegacyDeployable.find(params[:id], :include => :assemblies)
+ @deployable = LegacyDeployable.find(params[:id], :include => :legacy_assemblies)
end
end
diff --git a/src/app/controllers/legacy_templates_controller.rb
b/src/app/controllers/legacy_templates_controller.rb
new file mode 100644
index 0000000..5870cb0
--- /dev/null
+++ b/src/app/controllers/legacy_templates_controller.rb
@@ -0,0 +1,301 @@
+require 'util/repository_manager'
+
+class LegacyTemplatesController < ApplicationController
+ before_filter :require_user
+ before_filter :set_view_vars, :only => [:index, :show]
+
+ def index
+ require_privilege(Privilege::VIEW, LegacyTemplate)
+ @params = params
+ @search_term = params[:q]
+ if @search_term.blank?
+ load_legacy_templates
+ return
+ end
+
+ # FIXME: Filter on Permissions
+ search = LegacyTemplate.search do
+ keywords(params[:q])
+ end
+ @legacy_templates = search.results
+ end
+
+ def show
+ load_legacy_templates
+ @tpl = LegacyTemplate.find(params[:id])
+ require_privilege(Privilege::VIEW, @tpl)
+ @url_params = params.clone
+ @tab_captions = ['Properties', 'Builds']
+ @details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
+ load_images(@tpl) if @details_tab == 'builds'
+ 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
+ check_create_permission
+ # can't use @template variable - is used by compass (or something other)
+ @tpl = LegacyTemplate.new(params[:tpl])
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ end
+
+ def add_selected
+ if params[:tpl] and not params[:tpl][:id].blank?
+ @tpl = LegacyTemplate.find(params[:tpl][:id])
+ check_edit_permission
+ @tpl.attributes = params[:tpl]
+ else
+ @tpl = LegacyTemplate.new(params[:tpl])
+ check_create_permission
+ end
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ @tpl.add_software(params[:packages].to_a + params[:selected_packages].to_a +
params[:cached_packages].to_a,
+ params[:groups].to_a + params[:selected_groups].to_a)
+ render :action => @tpl.id ? :edit : :new
+ end
+
+ def edit
+ @tpl = LegacyTemplate.find(params[:id])
+ check_edit_permission
+ @tpl.attributes = params[:tpl] unless params[:tpl].blank?
+ @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ end
+
+ def create
+ check_create_permission
+ @tpl = LegacyTemplate.new(params[:tpl])
+ @tpl.packages = params[:packages]
+ @tpl.owner = current_user
+ if @tpl.save
+ flash[:notice] = "Template saved."
+ @tpl.set_complete
+ if params[:create_deployable]
+ LegacyDeployable.create!(:name => @tpl.name, :legacy_assemblies =>
@tpl.legacy_assemblies, :owner => current_user)
+ end
+ redirect_to legacy_templates_path
+ else
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ render :new
+ end
+ end
+
+ def update
+ @tpl = LegacyTemplate.find(params[:id])
+ check_edit_permission
+ @tpl.packages = []
+ @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
+
+ if @tpl.update_attributes(params[:tpl])
+ @tpl.set_complete
+ flash[:notice] = "Template updated."
+ redirect_to legacy_templates_path
+ else
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ render :action => 'edit'
+ end
+ end
+
+ def search_packages
+ set_package_vars
+ @page = get_page
+ @cached_packages = params[:cached_packages].to_a + params[:selected_packages].to_a
+ @searched_packages = params[:package_search].empty? ? [] :
@repository_manager.search_package(
+ params[:package_search]).paginate(:page => @page, :per_page => 60)
+ if request.xhr?
+ render :partial => 'search_packages'
+ else
+ render 'search_packages'
+ end
+ end
+
+ def metagroup_packages
+ set_package_vars
+ group = params[:__rewrite] ? params[:__rewrite][:metagroup_packages] : nil
+ @metagroup_packages = @repository_manager.metagroup_packages(group)
+ if request.xhr?
+ render :partial => 'metagroup_packages'
+ end
+ end
+
+ def collections
+ if params[:package_search_button]
+ search_packages
+ return
+ end
+ set_package_vars
+ @collections = @repository_manager.groups
+ if request.xhr?
+ render :partial => 'collections'
+ end
+ end
+
+ def content_selection
+ set_package_vars(true)
+ @collections = @repository_manager.groups
+ if request.xhr?
+ render :partial => 'software_selection', :locals => {:view =>
'collections'}
+ else
+ render :collections
+ end
+ end
+
+ def managed_content
+ if params[:template_id].blank?
+ @tpl = LegacyTemplate.new
+ check_create_permission
+ else
+ @tpl = LegacyTemplate.find(params[:template_id])
+ check_edit_permission
+ end
+ @tpl.add_software(params[:packages].to_a + params[:selected_packages].to_a,
+ params[:groups].to_a + params[:selected_groups].to_a)
+ render :layout => false
+ end
+
+ def legacy_assembly
+ # FIXME: do we need perm check here?
+ end
+
+ def deployment_definition
+ # FIXME: do we need perm check here?
+ @all_targets = ProviderType.all(:conditions => {:build_supported => true})
+ end
+
+ def remove_package
+ params[:packages].delete(params[:name]) unless params[:name].blank?
+ if params[:tpl] and not params[:tpl][:id].blank?
+ @tpl = LegacyTemplate.find(params[:tpl][:id])
+ check_edit_permission
+ @tpl.attributes = params[:tpl]
+ else
+ @tpl = LegacyTemplate.new(params[:tpl])
+ check_create_permission
+ end
+ @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ render :action => @tpl.id ? :edit : :new
+ end
+
+ def multi_destroy
+ destroyed = []
+ failed = []
+ LegacyTemplate.find(params[:selected]).each do |template|
+ if check_privilege(Privilege::MODIFY, template) and template.destroy
+ destroyed << template.name
+ else
+ failed << template.name
+ end
+ end
+
+ unless destroyed.empty?
+ flash[:notice] = t('legacy_templates.index.deleted', :count =>
destroyed.length, :list => destroyed.join(', '))
+ end
+ unless failed.empty?
+ flash[:error] = t('legacy_templates.index.not_deleted', :count =>
failed.length, :list => failed.join(', '))
+ end
+ redirect_to legacy_templates_url
+ end
+
+ protected
+
+ def load_images(tpl)
+ @targets_not_built = {}
+
+ Provider.all.each do |p|
+ @targets_not_built[p.provider_type.id] = p.provider_type.name
+ end
+
+ tpl.legacy_images.each do |img|
+ @targets_not_built.delete(img.provider_type_id)
+ end
+ @targets_not_built = @targets_not_built.invert
+
+ @images = tpl.legacy_images
+ end
+
+ def set_view_vars
+ @header = [
+ {:name => 'NAME', :sort_attr => 'name'},
+ {:name => 'OS', :sort_attr => 'platform'},
+ {:name => 'VERSION', :sort_attr => 'platform_version'},
+ {:name => 'BOOTABLE', :sortable => false},
+ {:name => 'ARCH', :sort_attr => 'architecture'},
+ ]
+
+ @url_params = params.clone
+ end
+
+ def load_legacy_templates
+ @legacy_templates = LegacyTemplate.list_for_user(current_user,
+ Privilege::VIEW,
+ :include => :legacy_images,
+ :order => get_order('name')
+ )
+ end
+
+ def set_package_vars(set_all = false)
+ id = params[:id] || (params[:tpl] && params[:tpl][:id]) || nil
+ if id.blank?
+ @tpl = LegacyTemplate.new
+ check_create_permission
+ else
+ @tpl = LegacyTemplate.find(id)
+ check_edit_permission
+ end
+ @tpl.attributes = params[:tpl] unless params[:tpl].nil?
+ @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
+ @groups = @repository_manager.groups
+ @categories = @repository_manager.categories if not request.xhr? or set_all
+ @metagroups = @repository_manager.metagroups if not request.xhr? or set_all
+ @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
+ end
+
+ def get_order(default)
+ @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
+ @order_field = params[:order_field] || default
+ "#{@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_create_permission
+ require_privilege(Privilege::CREATE, LegacyTemplate)
+ end
+
+ def check_edit_permission
+ require_privilege(Privilege::MODIFY, @tpl)
+ end
+
+ def get_selected_id
+ ids = params[:ids].to_a
+ if ids.size != 1
+ flash[:warning] = ids.empty? ? 'No Template Selected' : 'You can select
only one template'
+ return
+ end
+ return ids.first
+ end
+
+ def get_page
+ if params[:page] == 'Previous'
+ return params[:old_page].to_i - 1
+ elsif params[:page] == 'Next'
+ return params[:old_page].to_i + 1
+ else
+ return params[:page].blank? ? 1 : params[:page].to_i
+ end
+ end
+
+end
diff --git a/src/app/controllers/templates_controller.rb
b/src/app/controllers/templates_controller.rb
deleted file mode 100644
index 7ab8e0a..0000000
--- a/src/app/controllers/templates_controller.rb
+++ /dev/null
@@ -1,301 +0,0 @@
-require 'util/repository_manager'
-
-class TemplatesController < ApplicationController
- before_filter :require_user
- before_filter :set_view_vars, :only => [:index, :show]
-
- def index
- require_privilege(Privilege::VIEW, Template)
- @params = params
- @search_term = params[:q]
- if @search_term.blank?
- load_templates
- return
- end
-
- # FIXME: Filter on Permissions
- search = Template.search do
- keywords(params[:q])
- end
- @templates = search.results
- end
-
- def show
- load_templates
- @tpl = Template.find(params[:id])
- require_privilege(Privilege::VIEW, @tpl)
- @url_params = params.clone
- @tab_captions = ['Properties', 'Builds']
- @details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
- load_images(@tpl) if @details_tab == 'builds'
- 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
- check_create_permission
- # can't use @template variable - is used by compass (or something other)
- @tpl = Template.new(params[:tpl])
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- end
-
- def add_selected
- if params[:tpl] and not params[:tpl][:id].blank?
- @tpl = Template.find(params[:tpl][:id])
- check_edit_permission
- @tpl.attributes = params[:tpl]
- else
- @tpl = Template.new(params[:tpl])
- check_create_permission
- end
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- @tpl.add_software(params[:packages].to_a + params[:selected_packages].to_a +
params[:cached_packages].to_a,
- params[:groups].to_a + params[:selected_groups].to_a)
- render :action => @tpl.id ? :edit : :new
- end
-
- def edit
- @tpl = Template.find(params[:id])
- check_edit_permission
- @tpl.attributes = params[:tpl] unless params[:tpl].blank?
- @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- end
-
- def create
- check_create_permission
- @tpl = Template.new(params[:tpl])
- @tpl.packages = params[:packages]
- @tpl.owner = current_user
- if @tpl.save
- flash[:notice] = "Template saved."
- @tpl.set_complete
- if params[:create_deployable]
- LegacyDeployable.create!(:name => @tpl.name, :assemblies =>
@tpl.assemblies, :owner => current_user)
- end
- redirect_to templates_path
- else
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- render :new
- end
- end
-
- def update
- @tpl = Template.find(params[:id])
- check_edit_permission
- @tpl.packages = []
- @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
-
- if @tpl.update_attributes(params[:tpl])
- @tpl.set_complete
- flash[:notice] = "Template updated."
- redirect_to templates_path
- else
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- render :action => 'edit'
- end
- end
-
- def search_packages
- set_package_vars
- @page = get_page
- @cached_packages = params[:cached_packages].to_a + params[:selected_packages].to_a
- @searched_packages = params[:package_search].empty? ? [] :
@repository_manager.search_package(
- params[:package_search]).paginate(:page => @page, :per_page => 60)
- if request.xhr?
- render :partial => 'search_packages'
- else
- render 'search_packages'
- end
- end
-
- def metagroup_packages
- set_package_vars
- group = params[:__rewrite] ? params[:__rewrite][:metagroup_packages] : nil
- @metagroup_packages = @repository_manager.metagroup_packages(group)
- if request.xhr?
- render :partial => 'metagroup_packages'
- end
- end
-
- def collections
- if params[:package_search_button]
- search_packages
- return
- end
- set_package_vars
- @collections = @repository_manager.groups
- if request.xhr?
- render :partial => 'collections'
- end
- end
-
- def content_selection
- set_package_vars(true)
- @collections = @repository_manager.groups
- if request.xhr?
- render :partial => 'software_selection', :locals => {:view =>
'collections'}
- else
- render :collections
- end
- end
-
- def managed_content
- if params[:template_id].blank?
- @tpl = Template.new
- check_create_permission
- else
- @tpl = Template.find(params[:template_id])
- check_edit_permission
- end
- @tpl.add_software(params[:packages].to_a + params[:selected_packages].to_a,
- params[:groups].to_a + params[:selected_groups].to_a)
- render :layout => false
- end
-
- def assembly
- # FIXME: do we need perm check here?
- end
-
- def deployment_definition
- # FIXME: do we need perm check here?
- @all_targets = ProviderType.all(:conditions => {:build_supported => true})
- end
-
- def remove_package
- params[:packages].delete(params[:name]) unless params[:name].blank?
- if params[:tpl] and not params[:tpl][:id].blank?
- @tpl = Template.find(params[:tpl][:id])
- check_edit_permission
- @tpl.attributes = params[:tpl]
- else
- @tpl = Template.new(params[:tpl])
- check_create_permission
- end
- @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- render :action => @tpl.id ? :edit : :new
- end
-
- def multi_destroy
- destroyed = []
- failed = []
- Template.find(params[:selected]).each do |template|
- if check_privilege(Privilege::MODIFY, template) and template.destroy
- destroyed << template.name
- else
- failed << template.name
- end
- end
-
- unless destroyed.empty?
- flash[:notice] = t('templates.index.deleted', :count =>
destroyed.length, :list => destroyed.join(', '))
- end
- unless failed.empty?
- flash[:error] = t('templates.index.not_deleted', :count =>
failed.length, :list => failed.join(', '))
- end
- redirect_to templates_url
- end
-
- protected
-
- def load_images(tpl)
- @targets_not_built = {}
-
- Provider.all.each do |p|
- @targets_not_built[p.provider_type.id] = p.provider_type.name
- end
-
- tpl.images.each do |img|
- @targets_not_built.delete(img.provider_type_id)
- end
- @targets_not_built = @targets_not_built.invert
-
- @images = tpl.images
- end
-
- def set_view_vars
- @header = [
- {:name => 'NAME', :sort_attr => 'name'},
- {:name => 'OS', :sort_attr => 'platform'},
- {:name => 'VERSION', :sort_attr => 'platform_version'},
- {:name => 'BOOTABLE', :sortable => false},
- {:name => 'ARCH', :sort_attr => 'architecture'},
- ]
-
- @url_params = params.clone
- end
-
- def load_templates
- @templates = Template.list_for_user(current_user,
- Privilege::VIEW,
- :include => :images,
- :order => get_order('name')
- )
- end
-
- def set_package_vars(set_all = false)
- id = params[:id] || (params[:tpl] && params[:tpl][:id]) || nil
- if id.blank?
- @tpl = Template.new
- check_create_permission
- else
- @tpl = Template.find(id)
- check_edit_permission
- end
- @tpl.attributes = params[:tpl] unless params[:tpl].nil?
- @repository_manager = RepositoryManager.new(:repositories => params[:repository]
|| @tpl.platform)
- @groups = @repository_manager.groups
- @categories = @repository_manager.categories if not request.xhr? or set_all
- @metagroups = @repository_manager.metagroups if not request.xhr? or set_all
- @tpl.add_software(params[:packages].to_a, params[:groups].to_a)
- end
-
- def get_order(default)
- @order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
- @order_field = params[:order_field] || default
- "#{@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_create_permission
- require_privilege(Privilege::CREATE, Template)
- end
-
- def check_edit_permission
- require_privilege(Privilege::MODIFY, @tpl)
- end
-
- def get_selected_id
- ids = params[:ids].to_a
- if ids.size != 1
- flash[:warning] = ids.empty? ? 'No Template Selected' : 'You can select
only one template'
- return
- end
- return ids.first
- end
-
- def get_page
- if params[:page] == 'Previous'
- return params[:old_page].to_i - 1
- elsif params[:page] == 'Next'
- return params[:old_page].to_i + 1
- else
- return params[:page].blank? ? 1 : params[:page].to_i
- end
- end
-
-end
diff --git a/src/app/helpers/legacy_templates_helper.rb
b/src/app/helpers/legacy_templates_helper.rb
new file mode 100644
index 0000000..10047bc
--- /dev/null
+++ b/src/app/helpers/legacy_templates_helper.rb
@@ -0,0 +1,8 @@
+module LegacyTemplatesHelper
+ class ButtonPaginationRenderer < WillPaginate::LinkRenderer
+ def page_link(page, text, attributes = {})
+ #submit_tag text, :name => 'page'
+ "<input type=submit value='#{text}' name='page'
class='#{attributes[:class]}' />"
+ end
+ end
+end
diff --git a/src/app/helpers/templates_helper.rb b/src/app/helpers/templates_helper.rb
deleted file mode 100644
index 1ffcd2f..0000000
--- a/src/app/helpers/templates_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module TemplatesHelper
- class ButtonPaginationRenderer < WillPaginate::LinkRenderer
- def page_link(page, text, attributes = {})
- #submit_tag text, :name => 'page'
- "<input type=submit value='#{text}' name='page'
class='#{attributes[:class]}' />"
- end
- end
-end
diff --git a/src/app/models/assembly.rb b/src/app/models/assembly.rb
deleted file mode 100644
index 9e2ac23..0000000
--- a/src/app/models/assembly.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# == Schema Information
-# Schema version: 20110207110131
-#
-# Table name: assemblies
-#
-# id :integer not null, primary key
-# uuid :string(255) not null
-# xml :binary not null
-# uri :string(255)
-# name :string(255)
-# architecture :string(255)
-# summary :text
-# uploaded :boolean
-# lock_version :integer default(0)
-# created_at :datetime
-# updated_at :datetime
-#
-
-#
-# 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 Assembly < ActiveRecord::Base
- include PermissionedObject
- include ImageWarehouseObject
- searchable do
- text :name, :as => :code_substring
- text :architecture, :as => :code_substring
- text :summary, :as => :code_substring
- end
-
- has_and_belongs_to_many :templates
- has_and_belongs_to_many :legacy_deployables
- has_many :instances
-
- 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 :architecture
- validates_presence_of :owner_id
-
- def self.default_privilege_target_type
- Template
- end
-
- def update_xml
- xml.name = self.name
- xml.description = self.summary
- xml.architecture = self.architecture
- write_attribute(:xml, xml.to_xml)
- end
-
- def self.find_or_create(id)
- id ? Assembly.find(id) : Assembly.new
- end
-
-end
diff --git a/src/app/models/build_job.rb b/src/app/models/build_job.rb
index 19dc1fa..02f6252 100644
--- a/src/app/models/build_job.rb
+++ b/src/app/models/build_job.rb
@@ -29,12 +29,12 @@ class BuildJob < Struct.new(:image_id, :hydra)
if (@hydra == nil)
@hydra = Typhoeus::Hydra.new
end
- image = Image.find(image_id)
+ image = LegacyImage.find(image_id)
request =
Typhoeus::Request.new(YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['buildurl'],
:method => :post,
:timeout => 60*1000, # in milliseconds
:params => {
- :template => image.template.warehouse_url,
+ :template =>
image.legacy_template.warehouse_url,
:target => image.provider_type.codename})
request.on_complete do |response|
if response.success?
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 336e92a..bbff404 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -113,7 +113,7 @@ 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 legacy_deployable.launchable?
- legacy_deployable.assemblies.each do |assembly|
+ legacy_deployable.legacy_assemblies.each do |assembly|
# TODO: for now we try to start all instances even if some of them fails
begin
Instance.transaction do
@@ -123,7 +123,7 @@ class Deployment < ActiveRecord::Base
:name => "#{name}/#{assembly.name}",
:frontend_realm => realm,
:pool => pool,
- :assembly => assembly,
+ :legacy_assembly => assembly,
:state => Instance::STATE_NEW,
:owner => user,
:hardware_profile => hw_profile ? HardwareProfile.find(hw_profile) : nil
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
deleted file mode 100644
index b4d2600..0000000
--- a/src/app/models/image.rb
+++ /dev/null
@@ -1,245 +0,0 @@
-# == Schema Information
-# Schema version: 20110223132404
-#
-# Table name: images
-#
-# id :integer not null, primary key
-# uuid :string(255)
-# name :string(255) not null
-# build_id :string(255)
-# uri :string(255)
-# status :string(255)
-# template_id :integer
-# created_at :datetime
-# updated_at :datetime
-# provider_type_id :integer default(100), not null
-#
-
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# 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.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-class ImageExistsError < Exception;end
-
-class Image < ActiveRecord::Base
- include SearchFilter
- include ImageWarehouseObject
-
- before_save :generate_uuid
-
- cattr_reader :per_page
- @@per_page = 15
-
- belongs_to :template, :counter_cache => true
- has_many :legacy_provider_images, :dependent => :destroy
- has_many :providers, :through => :legacy_provider_images
- belongs_to :provider_type
-
- validates_presence_of :name
- validates_length_of :name, :maximum => 1024
- validates_presence_of :status
- validates_presence_of :template_id
- validates_presence_of :provider_type_id
-
- validates_uniqueness_of :template_id, :scope => :provider_type_id
-
- SEARCHABLE_COLUMNS = %w(name)
-
- STATE_QUEUED = 'queued'
- STATE_CREATED = 'created'
- STATE_BUILDING = 'building'
- STATE_COMPLETED = 'completed'
- STATE_CANCELED = 'canceled'
- STATE_FAILED = 'failed'
-
- ACTIVE_STATES = [ STATE_QUEUED, STATE_CREATED, STATE_BUILDING ]
- INACTIVE_STATES = [STATE_COMPLETED, STATE_FAILED, STATE_CANCELED]
-
- def generate_uuid
- self.uuid ||= "image-#{self.template_id}-#{Time.now.to_f.to_s}"
- end
-
- # TODO: for now when build is finished we call upload automatically for all providers
- def after_update
- if not self.new_record? and self.status_changed? and self.status == STATE_COMPLETED
- safe_warehouse_sync
- upload_to_all_providers_with_account
- end
- end
-
- def rebuild!
- # TODO: remove this check when we have UI for pushing images
- if self.provider_type.providers.empty? or not self.provider_type.providers.detect
{|p| !p.provider_accounts.empty?}
- raise "Error: A valid provider and provider account are required to create and
build templates"
- end
- self.status = STATE_QUEUED
- self.save!
- self.legacy_provider_images.each {|pimg| pimg.destroy}
- Delayed::Job.enqueue(BuildJob.new(self.id))
- end
-
- def not_uploaded_providers
- uploaded = self.legacy_provider_images
- Provider.all(:conditions => {:provider_type_id =>
self.provider_type.id}).select do |p|
- not uploaded.detect {|pimg| pimg.provider_id == p.id}
- end
- end
-
- def self.create_and_build!(template, provider_type)
- if Image.find_by_template_id_and_provider_type_id(template.id, provider_type.id)
- raise ImageExistsError, "An attempted build of this template for the target
'#{provider_type.name}' already exists"
- end
- # TODO: remove this check when we have UI for pushing images
- if provider_type.providers.empty? or not provider_type.providers.detect {|p|
!p.provider_accounts.empty?}
- raise "Error: A valid provider and provider account are required to create and
build templates"
- end
- img = Image.create!(
- :name => "#{template.name}/#{provider_type.codename}",
- :provider_type_id => provider_type.id,
- :template_id => template.id,
- :status => Image::STATE_QUEUED
- )
- Delayed::Job.enqueue(BuildJob.new(img.id))
- img
- end
- def self.single_import(providername, username, password, image_id, user)
- account = Image.get_account(providername, username, password)
- Image.import(account, image_id, user)
- end
-
- def self.bulk_import(providername, username, password, images, user)
- account = Image.get_account(providername, username, password)
- images.each do |image|
- begin
- Image.import(account, image['id'], user)
- $stderr.puts "imported image with id '#{image['id']}'"
- rescue
- $stderr.puts "failed to import image with id
'#{image['id']}'"
- end
- end
- end
-
- def self.import(account, image_id, user)
- if image_id.blank?
- raise "image id should not be blank"
- end
- unless raw_image = account.connect.image(image_id)
- raise "There is no image with '#{image_id}' id"
- end
-
- if
LegacyProviderImage.find_by_provider_id_and_provider_image_key(account.provider.id,
image_id)
- raise "Image '#{image_id}' is already imported"
- end
-
- image = nil
- ActiveRecord::Base.transaction do
- template = Template.new(
- :name => raw_image.name + '_template',
- :summary => raw_image.description,
- :platform_hash => {:platform => 'unknown',
- :version => 'unknown',
- :architecture => raw_image.architecture},
- :complete => true,
- :uploaded => true,
- :imported => true,
- :owner => user
- )
- template.save!
-
- image = Image.new(
- :name => raw_image.name,
- :status => STATE_COMPLETED,
- :provider_type_id => account.provider.provider_type_id,
- :template_id => template.id
- )
- image.generate_uuid
- image.upload
- image.save!
-
- rep = LegacyProviderImage.new(
- :image_id => image.id,
- :provider_id => account.provider.id,
- :provider_image_key => image_id,
- :status => STATE_COMPLETED
- )
- rep.generate_uuid
- rep.upload
- rep.save!
-
- end
- image
- end
-
- def warehouse_bucket
- 'images'
- end
-
- def warehouse_sync
- bucket = warehouse.bucket(warehouse_bucket)
- raise WarehouseObjectNotFoundError unless bucket.include?(self.uuid)
- obj = bucket.object(self.uuid)
- attrs = obj.attrs([:uuid, :target, :template])
- unless attrs[:target]
- raise "target uuid is not set"
- end
- unless ptype = ProviderType.find_by_codename(attrs[:target])
- raise "provider type #{attrs[:target]} not found"
- end
- unless attrs[:template]
- raise "template uuid is not set"
- end
- unless tpl = Template.find_by_uuid(attrs[:template])
- raise "Template with uuid #{attrs[:template]} not found"
- end
- self.provider_type_id = ptype.id
- self.template_id = tpl.id
- end
-
- private
-
- def upload_to_all_providers_with_account
- provider_type.providers.each do |p|
- # upload only to providers with account
- unless p.provider_accounts.empty?
- pimg = LegacyProviderImage.create!(
- :image => self,
- :provider => p,
- :status => LegacyProviderImage::STATE_QUEUED
- )
- Delayed::Job.enqueue(PushJob.new(pimg.id))
- end
- end
- end
-
- def self.get_account(providername, username, password)
- unless provider = Provider.find_by_name(providername)
- raise "There is not provider with name '#{providername}'"
- end
-
- account = ProviderAccount.new(:provider => provider)
- account.credentials_hash = {:username => username, :password => password}
-
- unless account.valid_credentials?
- raise "Invalid credentials for provider '#{providername}'"
- end
-
- return account
- end
-end
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index c4820fa..947591f 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -78,8 +78,8 @@ class Instance < ActiveRecord::Base
belongs_to :deployment
belongs_to :hardware_profile
- belongs_to :template
- belongs_to :assembly
+ belongs_to :legacy_template
+ belongs_to :legacy_assembly
belongs_to :frontend_realm
belongs_to :owner, :class_name => "User", :foreign_key =>
"owner_id"
belongs_to :instance_hwp
@@ -93,8 +93,8 @@ class Instance < ActiveRecord::Base
validates_presence_of :pool_id
validates_presence_of :hardware_profile_id
- validates_presence_of :template_id, :unless => :deployment_id
- validates_presence_of :assembly_id, :if => :deployment_id
+ validates_presence_of :legacy_template_id, :unless => :deployment_id
+ validates_presence_of :legacy_assembly_id, :if => :deployment_id
#validates_presence_of :external_key
# TODO: can we do uniqueness validation on indirect association
@@ -136,9 +136,9 @@ class Instance < ActiveRecord::Base
USER_MUTABLE_ATTRS = ['name']
def validate
- if assembly and template
- errors.add(:assembly, "Please specify either template or assembly, but not
both")
- errors.add(:template, "Please specify either template or assembly, but not
both")
+ if legacy_assembly and legacy_template
+ errors.add(:legacy_assembly, "Please specify either template or
legacy_assembly, but not both")
+ errors.add(:legacy_template, "Please specify either template or
legacy_assembly, but not both")
end
end
@@ -294,7 +294,7 @@ class Instance < ActiveRecord::Base
def self.list_or_search(query,order_field,order_dir)
if query.blank?
- instances = Instance.all(:include => [ :template, :owner ],
+ instances = Instance.all(:include => [ :legacy_template, :owner ],
:order => (order_field || 'name') +' '+
(order_dir || 'asc'))
else
instances = search() { keywords(query) }.results
diff --git a/src/app/models/legacy_assembly.rb b/src/app/models/legacy_assembly.rb
new file mode 100644
index 0000000..075c55c
--- /dev/null
+++ b/src/app/models/legacy_assembly.rb
@@ -0,0 +1,86 @@
+# == Schema Information
+# Schema version: 20110207110131
+#
+# Table name: assemblies
+#
+# id :integer not null, primary key
+# uuid :string(255) not null
+# xml :binary not null
+# uri :string(255)
+# name :string(255)
+# architecture :string(255)
+# summary :text
+# uploaded :boolean
+# lock_version :integer default(0)
+# created_at :datetime
+# updated_at :datetime
+#
+
+#
+# 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 LegacyAssembly < ActiveRecord::Base
+ include PermissionedObject
+ include ImageWarehouseObject
+ searchable do
+ text :name, :as => :code_substring
+ text :architecture, :as => :code_substring
+ text :summary, :as => :code_substring
+ end
+
+ has_and_belongs_to_many :legacy_templates
+ has_and_belongs_to_many :legacy_deployables
+ has_and_belongs_to_many :legacy_templates
+ has_and_belongs_to_many :deployables
+ has_many :instances
+
+ 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 :architecture
+ validates_presence_of :owner_id
+
+ def self.default_privilege_target_type
+ LegacyTemplate
+ end
+
+ def update_xml
+ xml.name = self.name
+ xml.description = self.summary
+ xml.architecture = self.architecture
+ write_attribute(:xml, xml.to_xml)
+ end
+
+ def self.find_or_create(id)
+ id ? LegacyAssembly.find(id) : LegacyAssembly.new
+ end
+
+end
diff --git a/src/app/models/legacy_deployable.rb b/src/app/models/legacy_deployable.rb
index 853e4b5..b84ff13 100644
--- a/src/app/models/legacy_deployable.rb
+++ b/src/app/models/legacy_deployable.rb
@@ -43,7 +43,7 @@ class LegacyDeployable < ActiveRecord::Base
text :summary, :as => :code_substring
end
- has_and_belongs_to_many :assemblies
+ has_and_belongs_to_many :legacy_assemblies
has_many :deployments
has_many :permissions, :as => :permission_object, :dependent => :destroy,
@@ -65,7 +65,7 @@ class LegacyDeployable < ActiveRecord::Base
before_destroy :destroyable?
def self.default_privilege_target_type
- Template
+ LegacyTemplate
end
def update_xml
@@ -83,9 +83,9 @@ class LegacyDeployable < ActiveRecord::Base
end
def launchable?
- return false if assemblies.empty?
- assemblies.each do |a|
- return false if a.templates.empty?
+ return false if legacy_assemblies.empty?
+ legacy_assemblies.each do |a|
+ return false if a.legacy_templates.empty?
# TODO: should we check if there is an uploaded image for each template in
# assembly?
end
diff --git a/src/app/models/legacy_image.rb b/src/app/models/legacy_image.rb
new file mode 100644
index 0000000..ac1225b
--- /dev/null
+++ b/src/app/models/legacy_image.rb
@@ -0,0 +1,245 @@
+# == Schema Information
+# Schema version: 20110223132404
+#
+# Table name: images
+#
+# id :integer not null, primary key
+# uuid :string(255)
+# name :string(255) not null
+# build_id :string(255)
+# uri :string(255)
+# status :string(255)
+# template_id :integer
+# created_at :datetime
+# updated_at :datetime
+# provider_type_id :integer default(100), not null
+#
+
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ImageExistsError < Exception;end
+
+class LegacyImage < ActiveRecord::Base
+ include SearchFilter
+ include ImageWarehouseObject
+
+ before_save :generate_uuid
+
+ cattr_reader :per_page
+ @@per_page = 15
+
+ belongs_to :legacy_template, :counter_cache => true
+ has_many :legacy_provider_images, :dependent => :destroy
+ has_many :providers, :through => :legacy_provider_images
+ belongs_to :provider_type
+
+ validates_presence_of :name
+ validates_length_of :name, :maximum => 1024
+ validates_presence_of :status
+ validates_presence_of :legacy_template_id
+ validates_presence_of :provider_type_id
+
+ validates_uniqueness_of :legacy_template_id, :scope => :provider_type_id
+
+ SEARCHABLE_COLUMNS = %w(name)
+
+ STATE_QUEUED = 'queued'
+ STATE_CREATED = 'created'
+ STATE_BUILDING = 'building'
+ STATE_COMPLETED = 'completed'
+ STATE_CANCELED = 'canceled'
+ STATE_FAILED = 'failed'
+
+ ACTIVE_STATES = [ STATE_QUEUED, STATE_CREATED, STATE_BUILDING ]
+ INACTIVE_STATES = [STATE_COMPLETED, STATE_FAILED, STATE_CANCELED]
+
+ def generate_uuid
+ self.uuid ||= "image-#{self.legacy_template_id}-#{Time.now.to_f.to_s}"
+ end
+
+ # TODO: for now when build is finished we call upload automatically for all providers
+ def after_update
+ if not self.new_record? and self.status_changed? and self.status == STATE_COMPLETED
+ safe_warehouse_sync
+ upload_to_all_providers_with_account
+ end
+ end
+
+ def rebuild!
+ # TODO: remove this check when we have UI for pushing images
+ if self.provider_type.providers.empty? or not self.provider_type.providers.detect
{|p| !p.provider_accounts.empty?}
+ raise "Error: A valid provider and provider account are required to create and
build legacy_templates"
+ end
+ self.status = STATE_QUEUED
+ self.save!
+ self.legacy_provider_images.each {|pimg| pimg.destroy}
+ Delayed::Job.enqueue(BuildJob.new(self.id))
+ end
+
+ def not_uploaded_providers
+ uploaded = self.legacy_provider_images
+ Provider.all(:conditions => {:provider_type_id =>
self.provider_type.id}).select do |p|
+ not uploaded.detect {|pimg| pimg.provider_id == p.id}
+ end
+ end
+
+ def self.create_and_build!(legacy_template, provider_type)
+ if LegacyImage.find_by_legacy_template_id_and_provider_type_id(legacy_template.id,
provider_type.id)
+ raise ImageExistsError, "An attempted build of this template for the target
'#{provider_type.name}' already exists"
+ end
+ # TODO: remove this check when we have UI for pushing images
+ if provider_type.providers.empty? or not provider_type.providers.detect {|p|
!p.provider_accounts.empty?}
+ raise "Error: A valid provider and provider account are required to create and
build legacy_templates"
+ end
+ img = LegacyImage.create!(
+ :name => "#{legacy_template.name}/#{provider_type.codename}",
+ :provider_type_id => provider_type.id,
+ :legacy_template_id => legacy_template.id,
+ :status => LegacyImage::STATE_QUEUED
+ )
+ Delayed::Job.enqueue(BuildJob.new(img.id))
+ img
+ end
+ def self.single_import(providername, username, password, image_id, user)
+ account = LegacyImage.get_account(providername, username, password)
+ LegacyImage.import(account, image_id, user)
+ end
+
+ def self.bulk_import(providername, username, password, images, user)
+ account = LegacyImage.get_account(providername, username, password)
+ images.each do |image|
+ begin
+ LegacyImage.import(account, image['id'], user)
+ $stderr.puts "imported image with id '#{image['id']}'"
+ rescue
+ $stderr.puts "failed to import image with id
'#{image['id']}'"
+ end
+ end
+ end
+
+ def self.import(account, image_id, user)
+ if image_id.blank?
+ raise "image id should not be blank"
+ end
+ unless raw_image = account.connect.image(image_id)
+ raise "There is no image with '#{image_id}' id"
+ end
+
+ if
LegacyProviderImage.find_by_provider_id_and_provider_image_key(account.provider.id,
image_id)
+ raise "Image '#{image_id}' is already imported"
+ end
+
+ image = nil
+ ActiveRecord::Base.transaction do
+ template = LegacyTemplate.new(
+ :name => raw_image.name + '_template',
+ :summary => raw_image.description,
+ :platform_hash => {:platform => 'unknown',
+ :version => 'unknown',
+ :architecture => raw_image.architecture},
+ :complete => true,
+ :uploaded => true,
+ :imported => true,
+ :owner => user
+ )
+ template.save!
+
+ image = LegacyImage.new(
+ :name => raw_image.name,
+ :status => STATE_COMPLETED,
+ :provider_type_id => account.provider.provider_type_id,
+ :legacy_template_id => template.id
+ )
+ image.generate_uuid
+ image.upload
+ image.save!
+
+ rep = LegacyProviderImage.new(
+ :legacy_image_id => image.id,
+ :provider_id => account.provider.id,
+ :provider_image_key => image_id,
+ :status => STATE_COMPLETED
+ )
+ rep.generate_uuid
+ rep.upload
+ rep.save!
+
+ end
+ image
+ end
+
+ def warehouse_bucket
+ 'images'
+ end
+
+ def warehouse_sync
+ bucket = warehouse.bucket(warehouse_bucket)
+ raise WarehouseObjectNotFoundError unless bucket.include?(self.uuid)
+ obj = bucket.object(self.uuid)
+ attrs = obj.attrs([:uuid, :target, :template])
+ unless attrs[:target]
+ raise "target uuid is not set"
+ end
+ unless ptype = ProviderType.find_by_codename(attrs[:target])
+ raise "provider type #{attrs[:target]} not found"
+ end
+ unless attrs[:template]
+ raise "template uuid is not set"
+ end
+ unless tpl = LegacyTemplate.find_by_uuid(attrs[:template])
+ raise "Template with uuid #{attrs[:template]} not found"
+ end
+ self.provider_type_id = ptype.id
+ self.legacy_template_id = tpl.id
+ end
+
+ private
+
+ def upload_to_all_providers_with_account
+ provider_type.providers.each do |p|
+ # upload only to providers with account
+ unless p.provider_accounts.empty?
+ pimg = LegacyProviderImage.create!(
+ :legacy_image => self,
+ :provider => p,
+ :status => LegacyProviderImage::STATE_QUEUED
+ )
+ Delayed::Job.enqueue(PushJob.new(pimg.id))
+ end
+ end
+ end
+
+ def self.get_account(providername, username, password)
+ unless provider = Provider.find_by_name(providername)
+ raise "There is not provider with name '#{providername}'"
+ end
+
+ account = ProviderAccount.new(:provider => provider)
+ account.credentials_hash = {:username => username, :password => password}
+
+ unless account.valid_credentials?
+ raise "Invalid credentials for provider '#{providername}'"
+ end
+
+ return account
+ end
+end
diff --git a/src/app/models/legacy_provider_image.rb
b/src/app/models/legacy_provider_image.rb
index 0948348..2967d4c 100644
--- a/src/app/models/legacy_provider_image.rb
+++ b/src/app/models/legacy_provider_image.rb
@@ -15,13 +15,13 @@ class LegacyProviderImage < ActiveRecord::Base
include ImageWarehouseObject
belongs_to :provider
- belongs_to :image
+ belongs_to :legacy_image
has_one :icicle, :dependent => :destroy
validates_presence_of :provider_id
- validates_presence_of :image_id
+ validates_presence_of :legacy_image_id
validates_uniqueness_of :uuid, :allow_nil => true
- validates_uniqueness_of :image_id, :scope => :provider_id
+ validates_uniqueness_of :legacy_image_id, :scope => :provider_id
STATE_QUEUED = 'queued'
STATE_COMPLETED = 'completed'
@@ -55,7 +55,7 @@ class LegacyProviderImage < ActiveRecord::Base
unless attrs[:image]
raise "image uuid is not set"
end
- unless img = Image.find_by_uuid(attrs[:image])
+ unless img = LegacyImage.find_by_uuid(attrs[:image])
raise "image with uuid #{attrs[:image]} not found"
end
begin
@@ -63,7 +63,7 @@ class LegacyProviderImage < ActiveRecord::Base
rescue
logger.error "Failed to fetch icicle '#{attrs[:icicle]}', setting
icicle to nil: #{$!.message}"
end
- self.image_id = img.id
+ self.legacy_image_id = img.id
self.provider_image_key = attrs[:target_identifier]
end
end
diff --git a/src/app/models/legacy_template.rb b/src/app/models/legacy_template.rb
new file mode 100644
index 0000000..e236072
--- /dev/null
+++ b/src/app/models/legacy_template.rb
@@ -0,0 +1,186 @@
+# == Schema Information
+# Schema version: 20110207110131
+#
+# Table name: legacy_templates
+#
+# id :integer not null, primary key
+# uuid :string(255) not null
+# xml :binary not null
+# uri :string(255)
+# name :string(255)
+# platform :string(255)
+# platform_version :string(255)
+# architecture :string(255)
+# summary :text
+# complete :boolean
+# uploaded :boolean
+# imported :boolean
+# images_count :integer
+# created_at :datetime
+# updated_at :datetime
+#
+
+require 'util/image_descriptor_xml'
+require 'typhoeus'
+
+class LegacyTemplate < ActiveRecord::Base
+ include PermissionedObject
+ include ImageWarehouseObject
+
+ searchable do
+ text :name, :as => :code_substring
+ text :platform, :as => :code_substring
+ text :platform_version, :as => :code_substring
+ text :architecture, :as => :code_substring
+ text :summary, :as => :code_substring
+ end
+
+ has_many :legacy_images, :dependent => :destroy
+ has_many :instances
+ has_and_belongs_to_many :legacy_assemblies
+ before_validation :generate_uuid
+ before_save [:update_xml, :upload]
+ before_destroy [:no_instances?, :delete_in_warehouse]
+
+ 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)"
+ after_create :ensure_legacy_assembly
+
+ 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 :platform
+ validates_presence_of :platform_version
+ validates_presence_of :architecture
+ validates_presence_of :owner_id
+
+ def no_instances?
+ unless instances.empty?
+ errors.add(:base, 'There are instances for this template.')
+ return false
+ end
+
+ true
+ end
+
+ def update_xml
+ xml.name = self.name
+ xml.description = self.summary
+ xml.platform = {
+ 'id' => self.platform,
+ 'name' => platforms[self.platform] ?
platforms[self.platform]['name'] : '',
+ 'version' => self.platform_version,
+ 'arch' => self.architecture,
+ }
+ write_attribute(:xml, xml.to_xml)
+ end
+
+ def update_from_xml
+ self.name = xml.name
+ self.summary = xml.description
+ self.platform_hash = {
+ :platform => xml.platform,
+ :version => xml.platform_version,
+ :architecture => xml.architecture,
+ }
+ end
+
+ def providers
+ # TODO: rewrite cleanly
+ LegacyProviderImage.all(
+ :include => [:legacy_image, :provider],
+ :conditions => {:legacy_images => {:legacy_template_id => self.id}}
+ ).map {|p| p.provider}
+ end
+
+ def self.find_or_create(id)
+ id ? LegacyTemplate.find(id) : LegacyTemplate.new
+ end
+
+ def set_complete
+ update_attributes(:complete => true, :uploaded => false)
+ end
+
+ def platforms
+ @platforms ||=
YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_platform_repositories.yml")
+ end
+
+ def add_packages(packages)
+ packages.to_a.each {|pkg| xml.add_package(pkg)}
+ end
+
+ def add_groups(groups)
+ groups.to_a.each {|pkg| xml.add_group(pkg)}
+ end
+
+ def add_software(packages, groups)
+ add_packages(packages)
+ add_groups(groups)
+ end
+
+ # sets platform info from predefined platform list
+ def platform=(plat)
+ write_attribute(:platform, plat)
+ self.platform_version = platforms[plat]['version'].to_s
+ self.architecture = platforms[plat]['architecture']
+ end
+
+ def platform_name
+ platforms[self.platform] ? platforms[self.platform]['name'] : ''
+ end
+
+ # sets platform info from hash (used when importing images)
+ def platform_hash=(plat)
+ write_attribute(:platform, plat[:platform])
+ self.platform_version = plat[:version]
+ self.architecture = plat[:architecture]
+ end
+
+ # packages and groups are virtual attributes
+ def packages
+ xml.packages
+ end
+
+ def packages=(packages)
+ xml.clear_packages
+ packages.to_a.each {|pkg| xml.add_package(pkg)}
+ end
+
+ def groups
+ xml.groups
+ end
+
+ def groups=(groups)
+ xml.clear_groups
+ groups.to_a.each {|group| xml.add_group(group)}
+ end
+
+ def warehouse_body
+ self.xml.to_xml
+ end
+
+ def warehouse_bucket
+ 'templates'
+ end
+
+ def warehouse_sync
+ obj = warehouse.bucket(warehouse_bucket).object(self.uuid)
+ xml = obj.body
+ update_from_xml
+ end
+
+ private
+
+ def ensure_legacy_assembly
+ self.legacy_assemblies.create!({
+ :name => self.name,
+ :architecture => self.architecture,
+ :owner => self.owner
+ }) unless self.legacy_assemblies.count > 0
+ end
+end
diff --git a/src/app/models/permission.rb b/src/app/models/permission.rb
index f27a0af..9599549 100644
--- a/src/app/models/permission.rb
+++ b/src/app/models/permission.rb
@@ -57,9 +57,9 @@ class Permission < ActiveRecord::Base
:foreign_key =>
"permission_object_id"
belongs_to :provider_account, :class_name => "ProviderAccount",
:foreign_key =>
"permission_object_id"
- belongs_to :template, :class_name => "Template",
+ belongs_to :legacy_template, :class_name =>
"LegacyTemplate",
:foreign_key =>
"permission_object_id"
- belongs_to :assembly, :class_name => "Assembly",
+ belongs_to :legacy_assembly, :class_name =>
"LegacyAssembly",
:foreign_key =>
"permission_object_id"
belongs_to :legacy_deployable, :class_name =>
"LegacyDeployable",
:foreign_key =>
"permission_object_id"
diff --git a/src/app/models/privilege.rb b/src/app/models/privilege.rb
index 3c45586..047df6d 100644
--- a/src/app/models/privilege.rb
+++ b/src/app/models/privilege.rb
@@ -53,7 +53,7 @@ class Privilege < ActiveRecord::Base
ACTIONS = [ CREATE, MODIFY, USE, VIEW,
PERM_SET, PERM_VIEW]
TYPES = { BasePermissionObject => [MODIFY, PERM_SET, PERM_VIEW],
- Template => ACTIONS,
+ LegacyTemplate => ACTIONS,
Pool => ACTIONS - [USE],
PoolFamily => ACTIONS - [USE],
Instance => ACTIONS,
diff --git a/src/app/models/provider_type.rb b/src/app/models/provider_type.rb
index 8d41e00..e60ad0e 100644
--- a/src/app/models/provider_type.rb
+++ b/src/app/models/provider_type.rb
@@ -16,7 +16,7 @@
class ProviderType < ActiveRecord::Base
has_many :providers
- has_many :images
+ has_many :legacy_images
has_many :credential_definitions, :dependent => :destroy
validates_presence_of :name
diff --git a/src/app/models/push_job.rb b/src/app/models/push_job.rb
index d96d63e..953828e 100644
--- a/src/app/models/push_job.rb
+++ b/src/app/models/push_job.rb
@@ -29,7 +29,7 @@ class PushJob < Struct.new(:legacy_provider_image_id, :hydra)
# for now pick first account
provider_account = provider_image.provider.provider_accounts.first
cred_block = provider_account.build_credentials.to_xml.html_safe
- response =
RestClient.post(YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['pushurl'],
:image_id => provider_image.image.uuid,
+ response =
RestClient.post(YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['pushurl'],
:image_id => provider_image.legacy_image.uuid,
:provider => provider_image.provider.name,
:credentials => cred_block
)
diff --git a/src/app/models/template.rb b/src/app/models/template.rb
deleted file mode 100644
index d9fd831..0000000
--- a/src/app/models/template.rb
+++ /dev/null
@@ -1,186 +0,0 @@
-# == Schema Information
-# Schema version: 20110207110131
-#
-# Table name: templates
-#
-# id :integer not null, primary key
-# uuid :string(255) not null
-# xml :binary not null
-# uri :string(255)
-# name :string(255)
-# platform :string(255)
-# platform_version :string(255)
-# architecture :string(255)
-# summary :text
-# complete :boolean
-# uploaded :boolean
-# imported :boolean
-# images_count :integer
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'util/image_descriptor_xml'
-require 'typhoeus'
-
-class Template < ActiveRecord::Base
- include PermissionedObject
- include ImageWarehouseObject
-
- searchable do
- text :name, :as => :code_substring
- text :platform, :as => :code_substring
- text :platform_version, :as => :code_substring
- text :architecture, :as => :code_substring
- text :summary, :as => :code_substring
- end
-
- has_many :images, :dependent => :destroy
- has_many :instances
- has_and_belongs_to_many :assemblies
- before_validation :generate_uuid
- before_save [:update_xml, :upload]
- before_destroy [:no_instances?, :delete_in_warehouse]
-
- 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)"
- after_create :ensure_assembly
-
- 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 :platform
- validates_presence_of :platform_version
- validates_presence_of :architecture
- validates_presence_of :owner_id
-
- def no_instances?
- unless instances.empty?
- errors.add(:base, 'There are instances for this template.')
- return false
- end
-
- true
- end
-
- def update_xml
- xml.name = self.name
- xml.description = self.summary
- xml.platform = {
- 'id' => self.platform,
- 'name' => platforms[self.platform] ?
platforms[self.platform]['name'] : '',
- 'version' => self.platform_version,
- 'arch' => self.architecture,
- }
- write_attribute(:xml, xml.to_xml)
- end
-
- def update_from_xml
- self.name = xml.name
- self.summary = xml.description
- self.platform_hash = {
- :platform => xml.platform,
- :version => xml.platform_version,
- :architecture => xml.architecture,
- }
- end
-
- def providers
- # TODO: rewrite cleanly
- LegacyProviderImage.all(
- :include => [:image, :provider],
- :conditions => {:images => {:template_id => self.id}}
- ).map {|p| p.provider}
- end
-
- def self.find_or_create(id)
- id ? Template.find(id) : Template.new
- end
-
- def set_complete
- update_attributes(:complete => true, :uploaded => false)
- end
-
- def platforms
- @platforms ||=
YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_platform_repositories.yml")
- end
-
- def add_packages(packages)
- packages.to_a.each {|pkg| xml.add_package(pkg)}
- end
-
- def add_groups(groups)
- groups.to_a.each {|pkg| xml.add_group(pkg)}
- end
-
- def add_software(packages, groups)
- add_packages(packages)
- add_groups(groups)
- end
-
- # sets platform info from predefined platform list
- def platform=(plat)
- write_attribute(:platform, plat)
- self.platform_version = platforms[plat]['version'].to_s
- self.architecture = platforms[plat]['architecture']
- end
-
- def platform_name
- platforms[self.platform] ? platforms[self.platform]['name'] : ''
- end
-
- # sets platform info from hash (used when importing images)
- def platform_hash=(plat)
- write_attribute(:platform, plat[:platform])
- self.platform_version = plat[:version]
- self.architecture = plat[:architecture]
- end
-
- # packages and groups are virtual attributes
- def packages
- xml.packages
- end
-
- def packages=(packages)
- xml.clear_packages
- packages.to_a.each {|pkg| xml.add_package(pkg)}
- end
-
- def groups
- xml.groups
- end
-
- def groups=(groups)
- xml.clear_groups
- groups.to_a.each {|group| xml.add_group(group)}
- end
-
- def warehouse_body
- self.xml.to_xml
- end
-
- def warehouse_bucket
- 'templates'
- end
-
- def warehouse_sync
- obj = warehouse.bucket(warehouse_bucket).object(self.uuid)
- xml = obj.body
- update_from_xml
- end
-
- private
-
- def ensure_assembly
- self.assemblies.create!({
- :name => self.name,
- :architecture => self.architecture,
- :owner => self.owner
- }) unless self.assemblies.count > 0
- end
-end
diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb
index 31dd5bb..4278d06 100644
--- a/src/app/util/condormatic.rb
+++ b/src/app/util/condormatic.rb
@@ -35,7 +35,7 @@ end
def match(instance)
possibles = []
- template_id = instance.template ? instance.template.id :
instance.assembly.templates.first.id
+ legacy_template_id = instance.legacy_template ? instance.legacy_template.id :
instance.legacy_assembly.legacy_templates.first.id
PoolFamily.all.each do |pool_family|
if instance.pool.pool_family.id != pool_family.id
@@ -51,7 +51,7 @@ def match(instance)
provider_images = hwp.provider.legacy_provider_images.find(:all,
:conditions =>
['provider_image_key IS NOT NULL'])
provider_images.each do |pi|
- if pi.image.template.id != template_id
+ if pi.legacy_image.legacy_template.id != legacy_template_id
next
end
diff --git a/src/app/views/assemblies/index.haml b/src/app/views/assemblies/index.haml
deleted file mode 100644
index aba40ed..0000000
--- a/src/app/views/assemblies/index.haml
+++ /dev/null
@@ -1 +0,0 @@
-assemblies/index.haml
diff --git a/src/app/views/deployments/_new.haml b/src/app/views/deployments/_new.haml
index 99cb680..22b213c 100644
--- a/src/app/views/deployments/_new.haml
+++ b/src/app/views/deployments/_new.haml
@@ -15,9 +15,9 @@
%p
%h3 Assemblies hardware profiles
%ul
- - @deployment.legacy_deployable.assemblies.each do |assembly|
+ - @deployment.legacy_deployable.legacy_assemblies.each do |assembly|
%li
- - hwprofiles = @hardware_profiles.select {|hwp| hwp.architecture.value ==
assembly.templates.first.architecture}
+ - 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')
diff --git a/src/app/views/deployments/new.haml b/src/app/views/deployments/new.haml
index 949343a..b40557d 100644
--- a/src/app/views/deployments/new.haml
+++ b/src/app/views/deployments/new.haml
@@ -1 +1 @@
-= render :partial => 'new'
\ No newline at end of file
+= render :partial => 'new'
diff --git a/src/app/views/instances/_list.haml b/src/app/views/instances/_list.haml
index 2c6f9d7..c1f5888 100644
--- a/src/app/views/instances/_list.haml
+++ b/src/app/views/instances/_list.haml
@@ -1,6 +1,6 @@
- form_tag do
= restful_submit_tag 'Stop', 'stop', multi_stop_instances_path,
'GET'
- = restful_submit_tag 'Create', 'new', select_template_instances_path,
'GET'
+ = restful_submit_tag 'Create', 'new',
select_legacy_template_instances_path, 'GET'
= restful_submit_tag 'Remove failed', 'remove_failed',
remove_failed_instances_path, 'GET'
%p
@@ -17,7 +17,7 @@
%input{:name => 'instance_selected[]', :type =>
'checkbox', :value => inst.id, :id =>
"instance_checkbox_#{inst.id}", :checked => selected }
= link_to inst.name, instance_path(inst)
%td= inst.state
- %td= inst.template ? inst.template.name : "#{inst.assembly.name}
(assembly)"
+ %td= inst.legacy_template ? inst.legacy_template.name :
"#{inst.legacy_assembly.name} (assembly)"
%td= inst.public_addresses
%td= inst.provider_account ? inst.provider_account.provider.name : ''
%td= owner_name(inst)
diff --git a/src/app/views/instances/_new.haml b/src/app/views/instances/_new.haml
index 139d08d..82a3b99 100644
--- a/src/app/views/instances/_new.haml
+++ b/src/app/views/instances/_new.haml
@@ -1,14 +1,14 @@
= error_messages_for 'instance'
%h2 Launch instance
- form_for @instance, :url => instances_path do
- = hidden_field :instance, :template_id
+ = hidden_field :instance, :legacy_template_id
%ul
%li
= label :instance, :name
= text_field :instance, :name
%li
- = label :instance, :template
- = text_field_tag :template_name, @instance.template ? @instance.template.name :
'', :disabled => true
+ = label :instance, :legacy_template
+ = text_field_tag :template_name, @instance.legacy_template ?
@instance.legacy_template.name : '', :disabled => true
%li
= label :instance, :pool
- if @instance.pool
diff --git a/src/app/views/instances/_properties.haml
b/src/app/views/instances/_properties.haml
index cc5877d..7e1d9ed 100644
--- a/src/app/views/instances/_properties.haml
+++ b/src/app/views/instances/_properties.haml
@@ -14,17 +14,17 @@
%li
= label_tag :private_addresses, 'Private Addresses'
%span= @instance.private_addresses
- - if @instance.template
+ - if @instance.legacy_template
%li
= label_tag :operating_system, 'Operating system'
- %span= "#{(a)instance.template.xml.platform}
#{(a)instance.template.xml.platform_version}"
+ %span= "#{(a)instance.legacy_template.xml.platform}
#{(a)instance.legacy_template.xml.platform_version}"
%li
- = label_tag :base_template, 'Base Template'
- %span= @instance.template.name
+ = label_tag :base_legacy_template, 'Base Template'
+ %span= @instance.legacy_template.name
- else
%li
= label_tag :assembly, 'Assembly'
- %span= @instance.assembly.name
+ %span= @instance.legacy_assembly.name
%li
= label_tag :provider, 'Provider'
%span= @instance.provider_account.provider.name if @instance.provider_account
diff --git a/src/app/views/instances/new.haml b/src/app/views/instances/new.haml
index 949343a..b40557d 100644
--- a/src/app/views/instances/new.haml
+++ b/src/app/views/instances/new.haml
@@ -1 +1 @@
-= render :partial => 'new'
\ No newline at end of file
+= render :partial => 'new'
diff --git a/src/app/views/instances/select_legacy_template.haml
b/src/app/views/instances/select_legacy_template.haml
new file mode 100644
index 0000000..fe4b045
--- /dev/null
+++ b/src/app/views/instances/select_legacy_template.haml
@@ -0,0 +1,19 @@
+%h3 Show Templates
+%hr
+%ul
+ - @legacy_templates.each do |tpl|
+ %li
+ - form_tag new_instance_path do
+ = hidden_field :instance, :legacy_template_id, :value => tpl.id
+ - if tpl.platform != "unknown"
+ = image_tag "platform_#{tpl.platform}.png", :size =>
"32x32", :alt => tpl.platform
+ %h3= tpl.name
+ %p= tpl.summary
+ %p
+ %label Group:
+ System
+ %label Version:
+ 2.5
+ = submit_tag 'Launch', :name => 'launch'
+= will_paginate(@legacy_templates)
+= page_entries_info(@legacy_templates)
diff --git a/src/app/views/instances/select_template.haml
b/src/app/views/instances/select_template.haml
deleted file mode 100644
index a0c9117..0000000
--- a/src/app/views/instances/select_template.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-%h3 Show Templates
-%hr
-%ul
- - @templates.each do |tpl|
- %li
- - form_tag new_instance_path do
- = hidden_field :instance, :template_id, :value => tpl.id
- - if tpl.platform != "unknown"
- = image_tag "platform_#{tpl.platform}.png", :size =>
"32x32", :alt => tpl.platform
- %h3= tpl.name
- %p= tpl.summary
- %p
- %label Group:
- System
- %label Version:
- 2.5
- = submit_tag 'Launch', :name => 'launch'
-= will_paginate(@templates)
-= page_entries_info(@templates)
diff --git a/src/app/views/layouts/application.haml
b/src/app/views/layouts/application.haml
index 048cf46..609b315 100644
--- a/src/app/views/layouts/application.haml
+++ b/src/app/views/layouts/application.haml
@@ -29,7 +29,7 @@
- # navigation before the proper wireframes exist for all the sections.
- # Then we'll want to switch to the simple-nav gem or something else.
%li{:class => "#{'active' if controller.top_section ==
:design}" }
- = link_to 'Design & Deploy', templates_path
+ = link_to 'Design & Deploy', legacy_templates_path
%li{:class => "#{'active' unless [:design,
:administer].include? controller.top_section}" }
= link_to 'Monitor', pools_path
%li{:class => "#{'active' if controller.top_section ==
:administer}" }
diff --git a/src/app/views/legacy_assemblies/index.haml
b/src/app/views/legacy_assemblies/index.haml
new file mode 100644
index 0000000..aba40ed
--- /dev/null
+++ b/src/app/views/legacy_assemblies/index.haml
@@ -0,0 +1 @@
+assemblies/index.haml
diff --git a/src/app/views/legacy_deployables/_assemblies.haml
b/src/app/views/legacy_deployables/_assemblies.haml
index 4b6aaeb..e86efbb 100644
--- a/src/app/views/legacy_deployables/_assemblies.haml
+++ b/src/app/views/legacy_deployables/_assemblies.haml
@@ -9,7 +9,7 @@
%th
%th= "Name"
%th= "Created"
- -@deployable.assemblies(:include => :templates).each do |assembly|
+ -@deployable.legacy_assemblies(:include => :legacy_templates).each do |assembly|
%tr
%td
%input{:name => "assemblies_selected[]", :type =>
"checkbox", :value => assembly.id, :id =>
"assembly_checkbox_#{assembly.id}" }
diff --git a/src/app/views/legacy_templates/_addbuttons.haml
b/src/app/views/legacy_templates/_addbuttons.haml
new file mode 100644
index 0000000..7605ae8
--- /dev/null
+++ b/src/app/views/legacy_templates/_addbuttons.haml
@@ -0,0 +1,4 @@
+%fieldset.clear
+ - cancel_path = @tpl.id ? edit_legacy_template_path(@tpl) : new_legacy_template_path
+ = restful_submit_tag "Add Selected", "add_selected",
add_selected_legacy_templates_path, 'GET', {:class => "grid_2 alpha",
:id => "do_add_software"}
+ = restful_submit_tag "Cancel", "cancel_add_software", cancel_path,
'GET', {:class => "grid_2", :id =>
"cancel_add_software"}
diff --git a/src/app/views/legacy_templates/_basics.haml
b/src/app/views/legacy_templates/_basics.haml
new file mode 100644
index 0000000..72d2423
--- /dev/null
+++ b/src/app/views/legacy_templates/_basics.haml
@@ -0,0 +1,27 @@
+%h3 General Information
+%fieldset.clearfix
+ %label.grid_4.alpha.la Template Name:
+ %label.grid_7.la Summary:
+ %label.grid_3.suffix_2.omega.la Version:
+ = text_field :tpl, :name, :value => @tpl.name || 'Template Name', :class
=> "grid_4 alpha"
+ = text_field :tpl, :summary, :value => @tpl.summary || 'Template
Description', :class => "grid_7"
+ = text_field_tag 'current_version', 'Current Version', :disabled =>
true, :class => "grid_3"
+ %button{:type => 'button', :disabled => 'disabled', :class =>
"grid_2 omega"} New Version
+%fieldset.clearfix
+ %label.grid_4.alpha Choose Logo:
+ %input{:type => 'file', :disabled => 'disabled', :class =>
"grid_7"}
+%fieldset.clearfix
+ - default = @tpl.platforms['fedora']
+ = label :tpl, :platform, 'Platform Choice:', :class => "grid_4
alpha"
+ = select :tpl, :platform, @tpl.platforms.map {|id, p| ["#{p['name']}
#{p['version']} (#{p['architecture']})", id]}, {:selected =>
@tpl.platform || 'fedora'}, {:class => 'grid_7'}
+%fieldset.clearfix
+ = label_tag :bootable, 'Bootable:', :class => "grid_4 alpha"
+ .grid_12.omega
+ = radio_button_tag :bootable, 'yes', true, :disabled => true
+ = label_tag :bootable, 'Yes'
+ = radio_button_tag :bootable, 'no', false, :disabled => true
+ = label_tag :bootable, 'No'
+%fieldset.clearfix
+ %label{:for => :template_group, :class => 'grid_4 alpha'}
+ Template Group:
+ = select_tag(:template_group, options_for_select([['User Private', 1]]), :class
=> 'grid_4')
diff --git a/src/app/views/legacy_templates/_builds.haml
b/src/app/views/legacy_templates/_builds.haml
new file mode 100644
index 0000000..f6cc7bf
--- /dev/null
+++ b/src/app/views/legacy_templates/_builds.haml
@@ -0,0 +1,41 @@
+Builds for
+= @tpl.platform_name
+= @tpl.platform_version
+, legacy_template "#{(a)tpl.name}"
+
+- form_tag builds_path do
+ = hidden_field_tag :legacy_template_id, @tpl.id
+ - 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?
+ %li No Builds
+ - else
+ - @images.each do |img|
+ %li
+ - form_tag(retry_builds_path, { :method => :post }) do
+ = "#{img.name}-#{img.legacy_template.architecture}: #{img.status}"
+ = hidden_field_tag :template_id, @tpl.id
+ = hidden_field_tag :image_id, img.id
+ = submit_tag "Retry build", :name => "build"
+ - if img.status == LegacyImage::STATE_COMPLETED
+ %ul
+ - img.legacy_provider_images.each do |pimg|
+ %li
+ - form_tag(retry_builds_path, { :method => :post }) do
+ = "#{pimg.provider.name}: #{pimg.status}"
+ = hidden_field_tag :template_id, @tpl.id
+ = hidden_field_tag :provider_image_id, pimg.id
+ = submit_tag "Retry upload", :name => "build"
+ - unless @tpl.imported
+ - img.not_uploaded_providers.each do |provider|
+ %li
+ = "#{provider.name}: "
+ not uploaded
+ = link_to 'upload', upload_builds_path(:template_id =>
@tpl.id, :image_id => img.id, :provider_id => provider.id), {:class =>
'button'}
diff --git a/src/app/views/legacy_templates/_collections.haml
b/src/app/views/legacy_templates/_collections.haml
new file mode 100644
index 0000000..98ce959
--- /dev/null
+++ b/src/app/views/legacy_templates/_collections.haml
@@ -0,0 +1,8 @@
+%ul.collections
+ - @collections.each do |c|
+ %li
+ /- selected = c[:selected] ? true : false
+ - selected = false
+ = check_box_tag 'groups[]', c[:id], selected, {:disabled => selected,
:id => "group_#{c[:id]}", :class => "#{selected ? 'selected'
: ''}"}
+ = label_tag "group_#{c[:id]}", c[:name]
+= render :partial => 'addbuttons'
diff --git a/src/app/views/legacy_templates/_form.haml
b/src/app/views/legacy_templates/_form.haml
new file mode 100644
index 0000000..dba9f46
--- /dev/null
+++ b/src/app/views/legacy_templates/_form.haml
@@ -0,0 +1,120 @@
+:javascript
+ $(document).ready(function() {
+ var $content_container = $('#managed_content');
+ var $sel_pkg_container = $('#package_selection_list');
+ var $submit = $('#add_software_button');
+ $submit.click(function(e) {
+ e.preventDefault();
+ $submit.hide();
+ var data = {
+ 'packages[]':
$("input[name='packages[]']").map(function() {return
$(this).val()}).get(),
+ 'repository': $("select[name='tpl[platform]']").val()
|| ''
+ }
+ var url = '#{url_for :action => 'content_selection', :id =>
@id}';
+ //$content_container.empty().show();
+ $sel_pkg_container.empty().show().addClass('loading');
+ $sel_pkg_container.load(url, data, function(){
+ $sel_pkg_container.removeClass('loading');
+ var $groups = $('.softwaregroups .disclosure', this);
+ //search
+ $("input[name='package_search']").keypress(function(event) {
+ if (event.keyCode == '13') {
+ event.preventDefault();
+ $("input[name=package_search] ~ button").click();
+ }
+ });
+ $("input[name=package_search] ~ button").click(function(event) {
+ event.preventDefault();
+ var data = {
+ 'packages[]':
$("input:text[name='packages[]']").map(function() {return
$(this).val()}).get(),
+ 'package_search':
$("input[name='package_search']").val(),
+ 'repository':
$("select[name='tpl[platform]']").val()
+ };
+ var url = '#{url_for :action => 'search_packages', :id =>
@id}';
+ $('#metagrouppackages').empty().addClass('loading');
+ $('#metagrouppackages').load(url, data, function() {
+ $('#metagrouppackages').removeClass('loading');
+ });
+ });
+ });
+ });
+ //removing packages from the list
+ $('.remove_package').live('click', function (e) {
+ e.preventDefault();
+ $(this).parent().hide(300, function () {
+ $(this).remove();
+ });
+ });
+ //displaying extended package info and actions
+ $('.dropdown').hide();
+ $('.packagename').live('click', function () {
+ var dropdowncontent = $(this).siblings('.dropdown').html(),
+ $dropdown = $("#dropdown");
+ $('.packagewrap').removeClass('selected');
+ $(this).parent().addClass('selected');
+ $dropdown.empty().html(dropdowncontent).css({
+ 'top': $(this).positionAncestor('#content').top + 17,
+ 'left': $(this).positionAncestor('#content').left - 4
+ }).show();
+ });
+ //catch #content clicks and hide the #dropdown if it's not within it
+ $("#content").click(function (e) {
+ if(!e.target.id === 'dropdown' ||
!$(e.target).closest("#dropdown").length) {
+ $("#dropdown").hide();
+ $('.packagewrap').removeClass('selected');
+ }
+ });
+ // select correct package repo when we change platform
+ $("select[name='tpl[platform]']").change(function() {
+ if ($submit.is(':hidden')) {
+ $submit.trigger('click');
+ }
+ });
+ // add selected pkgs/groups
+ $('#do_add_software').live('click', function(e) {
+ e.preventDefault();
+ var $button = $(this).clone();
+ var label = "<span id='do_add_software' class='loading
fl'>Adding Packages</span>";
+ var url = '#{url_for :action => 'managed_content'}';
+ var new_pkgs =
$("input:checked[name='selected_packages[]']").map(function() {return
$(this).val()}).get();
+ var old_pkgs =
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get()
+ var cached_pkgs =
$("input:hidden[name='cached_packages[]']").map(function() {return
$(this).val()}).get()
+ var data = {
+ 'selected_packages[]': old_pkgs.concat(new_pkgs.concat(cached_pkgs)),
+ 'selected_groups[]':
$("input:checked[name='groups[]']").map(function() {return
$(this).val()}).get(),
+ 'collections': $("input:hidden[name=collections]").val(),
+ 'template_id' : '#{(a)id.nil? ? nil : @id}'
+ };
+ $(this).replaceWith(label);
+ $('#managed_content').load(url, data, function(){
+ $("input:checked[name='groups[]']").attr('disabled',
'disabled');
+ $("input:checked[name='packages[]']").attr('disabled',
'disabled');
+ // $('#add_software_button').show();
+ $('.dropdown').hide();
+ $('#do_add_software').replaceWith($button);
+ });
+ });
+ // hide sw selection panel
+ $('#cancel_add_software').live('click', function(e) {
+ e.preventDefault();
+ $('#package_selection_list').hide();
+ $('#add_software_button').show();
+ $('.dropdown').hide();
+ });
+ });
+
+#build
+ = error_messages_for :tpl, :object_name => 'template'
+ = render :partial => 'basics'
+ = render :partial => 'local_content_to_bundle'
+
+ #managed_content
+ = render :partial => 'managed_content'
+
+ .clearfix
+ .grid_16.alpha.omega
+ = restful_submit_tag "Add Software", 'collections',
collections_legacy_templates_path, 'GET', {:id =>
"add_software_button", :class => "iconbutton"}
+
+ #package_selection_list{:style => 'display: none'}
+
+ = render :partial => 'preboot_configuration'
diff --git a/src/app/views/legacy_templates/_hidden_fields.haml
b/src/app/views/legacy_templates/_hidden_fields.haml
new file mode 100644
index 0000000..5709087
--- /dev/null
+++ b/src/app/views/legacy_templates/_hidden_fields.haml
@@ -0,0 +1,8 @@
+= hidden_field :tpl, :id
+= hidden_field :tpl, :name
+= hidden_field :tpl, :summary
+= hidden_field :tpl, :platform
+= hidden_field :tpl, :platform_version
+= hidden_field :tpl, :architecture
+- @tpl.packages.each do |p|
+ = hidden_field_tag "packages[]", p, :id => "package_#{p}"
diff --git a/src/app/views/legacy_templates/_list.haml
b/src/app/views/legacy_templates/_list.haml
new file mode 100644
index 0000000..b33bbfc
--- /dev/null
+++ b/src/app/views/legacy_templates/_list.haml
@@ -0,0 +1,35 @@
+- form_tag do
+ = link_to "Create", new_legacy_template_path, :class => 'button'
+ = restful_submit_tag "Delete", 'destroy',
multi_destroy_legacy_templates_path, 'DELETE', :id => 'delete_button'
+
+ %table#legacy_templates_table
+ = sortable_table_header @header
+ %tbody
+ - if @legacy_templates.empty?
+ %tr
+ %td{:colspan => 6} No Templates
+ - else
+ - @legacy_templates.each do |template|
+ %tr
+ %td
+ = check_box_tag 'selected[]', template.id, @url_params[:select] ==
'all', :id => "selected_#{template.id}"
+ = image_tag "blnk.png", :alt => template.platform, :class
=> "icon platform #{template.platform}"
+ = link_to template.name, legacy_template_path(template)
+ %td= template.platform_name
+ %td= template.platform_version
+ %td= image_tag 'blnk.png', :alt => 'yes', :class =>
"icon yes"
+ %td= template.architecture
+
+:javascript
+ $(document).ready(function () {
+ $('#delete_button').click(function(e) {
+ if ($("#legacy_templates_table input[@type=radio]:checked").length == 0)
{
+ alert('Please select any template to be deleted before clicking Delete
button.');
+ e.preventDefault();
+ } else {
+ if (!confirm("Are you sure you want to delete this template?")) {
+ e.preventDefault();
+ }
+ }
+ });
+ });
diff --git a/src/app/views/legacy_templates/_local_content_to_bundle.haml
b/src/app/views/legacy_templates/_local_content_to_bundle.haml
new file mode 100644
index 0000000..109ce20
--- /dev/null
+++ b/src/app/views/legacy_templates/_local_content_to_bundle.haml
@@ -0,0 +1,21 @@
+%h3.disabled.gap Local Content to Bundle
+%fieldset.clearfix
+ = label_tag :local_bundle_name, 'Local:', :class => "disabled grid_2
alpha"
+ = text_field_tag 'local_bundle_name[]', 'Bundle Name', :disabled =>
true, :class => "grid_8"
+ .grid_6.omega
+ %button{:type => 'button', :disabled => 'disabled'} Browse
+ %button{:type => 'button', :disabled => 'disabled'} Config
+ %button{:type => 'button', :disabled => 'disabled'} Metadata
+ (
+ %a{:href => '#'} Remove
+ )
+ .grid_2.alpha
+
+ = text_field_tag 'local_bundle_name[]', 'Bundle Name', :disabled =>
true, :class => "grid_8"
+ .grid_6.omega
+ %button{:type => 'button', :disabled => 'disabled'} Browse
+ %button{:type => 'button', :disabled => 'disabled'} Config
+ %button{:type => 'button', :disabled => 'disabled'} Metadata
+ (
+ %a{:href => '#'} Remove
+ )
diff --git a/src/app/views/legacy_templates/_managed_content.haml
b/src/app/views/legacy_templates/_managed_content.haml
new file mode 100644
index 0000000..db4a190
--- /dev/null
+++ b/src/app/views/legacy_templates/_managed_content.haml
@@ -0,0 +1,21 @@
+#selected_packages
+ %h3.gap Managed Content to Bundle
+ .grid_16.alpha.omega
+ - if @tpl.packages.empty?
+ No selected packages
+ - else
+ /- repos = @repository_manager.repositories_hash
+ - @tpl.packages.sort.each do |pkg|
+ /- pkg_group = @groups.keys.find {|g| @groups[g][:packages][pkg]}
+ .packagewrap
+ %a.packagename{:id => "package_#{pkg}"}=pkg
+ = hidden_field_tag 'packages[]', pkg, :id =>
"package_#{pkg}"
+ = restful_submit_tag "Remove", "remove_package",
remove_package_legacy_templates_path(:name => pkg), 'GET', {:id =>
"remove_package_#{pkg}", :class => 'remove_package'}
+ .dropdown
+ / we don't display repository for now, it's pretty difficult with
current design
+ /%section
+ / Repository:
+ / %label= (pkg_group and repo = repos[@groups[pkg_group][:repository_id]]) ?
repo.name.to_s : ' '
+ %fieldset.nomargin
+ %button{:disabled => true} Browse
+ %button{:disabled => true} Config
diff --git a/src/app/views/legacy_templates/_metagroup_packages.haml
b/src/app/views/legacy_templates/_metagroup_packages.haml
new file mode 100644
index 0000000..82c2697
--- /dev/null
+++ b/src/app/views/legacy_templates/_metagroup_packages.haml
@@ -0,0 +1,19 @@
+- if @metagroup_packages.blank?
+ %span.disabled No group selected
+- else
+ %h4
+ = "#{@metagroup} Packages"
+ %ul.metagrouppackages
+ - @metagroup_packages.sort {|a, b| a[:name] <=> b[:name]}.each do |group|
+ %li
+ - selected = false
+ %h5
+ = check_box_tag 'selected_groups[]', group[:id], selected, {:disabled
=> selected, :id => "group_#{group[:id]}", :class =>
"softwaregroups #{selected ? 'selected' : ''}"}
+ = label_tag "group_#{group[:id]}", group[:label]
+ %ul
+ - group[:packages].each do |pkg|
+ %li
+ - selected = @packages.to_a.find {|p| p[:name] == pkg}
+ = check_box_tag 'selected_packages[]', pkg, selected, {:disabled
=> selected, :id => "pkg_#{group[:name]}_#{pkg}"}
+ = label_tag "pkg_#{group[:name]}_#{pkg}", pkg
+ = render :partial => 'addbuttons'
diff --git a/src/app/views/legacy_templates/_metagroups.haml
b/src/app/views/legacy_templates/_metagroups.haml
new file mode 100644
index 0000000..e6f36e5
--- /dev/null
+++ b/src/app/views/legacy_templates/_metagroups.haml
@@ -0,0 +1,13 @@
+%fieldset.clearfix
+ .search.grid_4.alpha
+ %input{:type => "search", :placeholder => "Search for
package", :name => 'package_search', :value => params[:package_search],
:id => 'package_search'}
+ %button.action{:id => 'package_search_button', :name =>
'package_search_button' , :value => 'true'}
+ .grid_8
+ %a.grid_4.omega Advanced Search
+
+%ul.metagroups{:class => 'packagegroupsidebar grid_4 alpha'}
+ %li
+ = restful_submit_tag 'Collections', 'collections',
collections_legacy_templates_path, 'GET', {:id => 'collections', :class
=> 'icon'}
+ - @metagroups.keys.sort.each do |cat|
+ %li
+ = restful_submit_tag cat, "metagroup_packages",
metagroup_packages_legacy_templates_path, 'GET', {:class => 'icon'}
diff --git a/src/app/views/legacy_templates/_preboot_configuration.haml
b/src/app/views/legacy_templates/_preboot_configuration.haml
new file mode 100644
index 0000000..79ae839
--- /dev/null
+++ b/src/app/views/legacy_templates/_preboot_configuration.haml
@@ -0,0 +1,11 @@
+%h3.clear.gap Preboot Configuration
+%fieldset.clearfix
+ .grid_4.alpha
+ = radio_button_tag :configure_via_script, 'no', :disabled => true
+ = label_tag :configure_via_script, 'Configure Via Script'
+ = file_field_tag 'script_file', :disabled => true, :class => 'grid_12
omega'
+%fieldset.clearfix
+ .grid_4.alpha
+ = radio_button_tag :configure_via_script, 'no', :disabled => true
+ = label_tag :configure_via_script, 'Configure Via Script'
+ = file_field_tag 'script_file', :disabled => true, :class => 'grid_12
omega'
diff --git a/src/app/views/legacy_templates/_properties.haml
b/src/app/views/legacy_templates/_properties.haml
new file mode 100644
index 0000000..e068197
--- /dev/null
+++ b/src/app/views/legacy_templates/_properties.haml
@@ -0,0 +1,4 @@
+%h3
+ Properties for
+ = @tpl.name
+= link_to "Edit", edit_legacy_template_path(@tpl), { :class =>
'button' }
diff --git a/src/app/views/legacy_templates/_search_packages.haml
b/src/app/views/legacy_templates/_search_packages.haml
new file mode 100644
index 0000000..1c6c25a
--- /dev/null
+++ b/src/app/views/legacy_templates/_search_packages.haml
@@ -0,0 +1,45 @@
+:javascript
+ $(document).ready(function() {
+ $('.pagination input[type=submit]').click(function(e) {
+ e.preventDefault();
+ var url = '#{url_for :action => 'search_packages', :id =>
@id}';
+ var old_pkgs =
$("input:hidden[name='cached_packages[]']").map(function() {return
$(this).val()}).get();
+ var new_pkgs =
$("input:checked[name='selected_packages[]']").map(function() {return
$(this).val()}).get();
+ var data = {
+ 'selected_packages[]':
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get(),
+ 'cached_packages[]': old_pkgs.concat(new_pkgs),
+ 'selected_groups[]':
$("input:checked[name='groups[]']").map(function() {return
$(this).val()}).get(),
+ 'package_search':
$("input[name='package_search']").val(),
+ 'old_page': '#{@page}',
+ 'template_id' : '#{(a)id.nil? ? nil : @id}',
+ 'page': $(this).val(),
+ 'repository': $("select[name='tpl[platform]']").val()
+ };
+ $('#metagrouppackages').empty().addClass('loading');
+ $('#metagrouppackages').load(url, data, function() {
+ $('#metagrouppackages').removeClass('loading');
+ })
+ });
+ });
+
+- @cached_packages.uniq.each do |pkg|
+ = hidden_field_tag 'cached_packages[]', pkg
+
+- if params[:package_search].empty?
+ Search string is empty.
+-else
+ %h4
+ = "Search Results for '#{params[:package_search]}'"
+ %ul.searchedpackages
+ - @searched_packages.sort {|a, b| a [:name] <=> b[:name]}.each do |pkg|
+ %li
+ - selected = (@packages.to_a.find {|p| p[:name] == pkg[:name]} or
@cached_packages.include?(pkg[:name]))
+ - disabled = @tpl.packages.include?(pkg[:name])
+ = check_box_tag 'selected_packages[]', pkg[:name], selected, {:disabled
=> disabled, :id => "pkg_#{pkg[:name]}"}
+ = label_tag "pkg_#{pkg[:name]}", pkg[:name]
+ .pageinfo
+ = page_entries_info @searched_packages, :entry_name => 'package'
+ = will_paginate @searched_packages, :params => {:package_search =>
params[:package_search]}, :renderer =>
LegacyTemplatesHelper::ButtonPaginationRenderer.new, :previous_label =>
'Previous', :next_label => 'Next'
+
+
+ = render :partial => 'addbuttons'
diff --git a/src/app/views/legacy_templates/_software_selection.haml
b/src/app/views/legacy_templates/_software_selection.haml
new file mode 100644
index 0000000..34606fc
--- /dev/null
+++ b/src/app/views/legacy_templates/_software_selection.haml
@@ -0,0 +1,41 @@
+:javascript
+ $(document).ready(function() {
+ var $metagrouppackages = $('#metagrouppackages');
+ $('.metagroups input').click(function(e) {
+ e.preventDefault();
+ var data = {
+ 'repository': $("select[name='tpl[platform]']").val(),
+ 'packages[]':
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get()
+ };
+ if ($(this).attr('name') == '__rewrite[collections]') {
+ var url = '#{url_for :action => 'collections', :id =>
@id}';
+ } else {
+ var url = '#{url_for :action => 'metagroup_packages', :id =>
@id}';
+ data.__rewrite = {
+ metagroup_packages: e.currentTarget.value
+ };
+ }
+ $metagrouppackages.empty().addClass('loading');
+ $metagrouppackages.load(url, data, function() {
+ $metagrouppackages.removeClass('loading');
+ //select all packages in collection
+ $(".softwaregroups").click(function() {
+ if ($(this).attr("checked") === true) {
+
$(this).parent().siblings("ul").find("input[type='checkbox']").attr("checked","checked");
+ } else {
+
$(this).parent().siblings("ul").find("input[type='checkbox']").removeAttr("checked");
+ }
+ });
+ });
+ });
+ });
+
+.grid_16
+ %h4 Managed Content Selection
+
+ - form_tag do
+ - unless request.xhr?
+ = render :partial => 'hidden_fields'
+ = render :partial => 'metagroups'
+ #metagrouppackages.grid_12.omega.gap
+ = render :partial => view
diff --git a/src/app/views/legacy_templates/collections.haml
b/src/app/views/legacy_templates/collections.haml
new file mode 100644
index 0000000..a899c85
--- /dev/null
+++ b/src/app/views/legacy_templates/collections.haml
@@ -0,0 +1 @@
+= render :partial => 'software_selection', :locals => {:view =>
'collections'}
diff --git a/src/app/views/legacy_templates/edit.haml
b/src/app/views/legacy_templates/edit.haml
new file mode 100644
index 0000000..7ccd0af
--- /dev/null
+++ b/src/app/views/legacy_templates/edit.haml
@@ -0,0 +1,9 @@
+#dropdown
+.grid_16
+ %h2 Edit Template
+ /- form_for @tpl, :url => legacy_template_path(@tpl), :html => { :method =>
:put } do |f|
+ - form_tag do
+ = hidden_field_tag :id, @tpl.id
+ = render :partial => 'form'
+ = restful_submit_tag "Save", 'update', legacy_template_path(@tpl),
'PUT', :class => "formbutton"
+ = link_to 'Cancel', legacy_templates_path, :class => 'button
formbutton'
diff --git a/src/app/views/legacy_templates/index.haml
b/src/app/views/legacy_templates/index.haml
new file mode 100644
index 0000000..62ccbc6
--- /dev/null
+++ b/src/app/views/legacy_templates/index.haml
@@ -0,0 +1,2 @@
+- content_for :list do
+ = render :partial => 'list'
diff --git a/src/app/views/legacy_templates/managed_content.haml
b/src/app/views/legacy_templates/managed_content.haml
new file mode 100644
index 0000000..926142d
--- /dev/null
+++ b/src/app/views/legacy_templates/managed_content.haml
@@ -0,0 +1 @@
+= render :partial => 'managed_content'
diff --git a/src/app/views/legacy_templates/metagroup_packages.haml
b/src/app/views/legacy_templates/metagroup_packages.haml
new file mode 100644
index 0000000..9703663
--- /dev/null
+++ b/src/app/views/legacy_templates/metagroup_packages.haml
@@ -0,0 +1 @@
+= render :partial => 'software_selection', :locals => {:view =>
'metagroup_packages'}
diff --git a/src/app/views/legacy_templates/new.haml
b/src/app/views/legacy_templates/new.haml
new file mode 100644
index 0000000..2c67cd2
--- /dev/null
+++ b/src/app/views/legacy_templates/new.haml
@@ -0,0 +1,10 @@
+#dropdown
+.grid_16
+ %h2 New Template
+ /- form_for @tpl, :url => legacy_templates_path do |f|
+ - form_tag do
+ = render :partial => 'form'
+ = check_box_tag :create_deployable
+ = label_tag :create_deployable, "Create Deployable for this template"
+ = restful_submit_tag "Save", 'create', legacy_templates_path,
'POST', :class => "formbutton"
+ = link_to 'Cancel', legacy_templates_path, :class => 'button
formbutton'
diff --git a/src/app/views/legacy_templates/search_packages.haml
b/src/app/views/legacy_templates/search_packages.haml
new file mode 100644
index 0000000..94e30f5
--- /dev/null
+++ b/src/app/views/legacy_templates/search_packages.haml
@@ -0,0 +1 @@
+= render :partial => 'software_selection', :locals => {:view =>
'search_packages'}
diff --git a/src/app/views/legacy_templates/show.haml
b/src/app/views/legacy_templates/show.haml
new file mode 100644
index 0000000..05eeedd
--- /dev/null
+++ b/src/app/views/legacy_templates/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/app/views/legacy_templates/xml/_hardware_profile.xml.haml
b/src/app/views/legacy_templates/xml/_hardware_profile.xml.haml
new file mode 100644
index 0000000..68ccc36
--- /dev/null
+++ b/src/app/views/legacy_templates/xml/_hardware_profile.xml.haml
@@ -0,0 +1,6 @@
+!!! XML
+%hardware_profile{ :href => hardware_profile_path(profile.id), :id =>
profile.external_key }<>
+ %name<>
+ = profile.name
+ - [profile.memory, profile.cpu, profile.architecture, profile.storage].each do |prop|
+ = render :partial =>
'legacy_templates/xml/hardware_profile_property.xml', :locals => { :property
=> prop }
diff --git a/src/app/views/legacy_templates/xml/_hardware_profile_property.xml.haml
b/src/app/views/legacy_templates/xml/_hardware_profile_property.xml.haml
new file mode 100644
index 0000000..bb0fa70
--- /dev/null
+++ b/src/app/views/legacy_templates/xml/_hardware_profile_property.xml.haml
@@ -0,0 +1,9 @@
+!!! XML
+- if property.kind == "range"
+ %property{ :kind => property.kind, :name => property.name, :unit =>
property.unit, :value => property.value, :first => property.range_first, :last =>
property.range_last }<>
+- else
+ %property{ :kind => property.kind, :name => property.name, :unit =>
property.unit, :value => property.value }<>
+ - if property.kind == "enum"
+ %enum<>
+ - property.property_enum_entries.each do |e|
+ %entry{ :value => e.value }<>
\ No newline at end of file
diff --git a/src/app/views/pools/_instances.haml b/src/app/views/pools/_instances.haml
index 44dcc1a..868f962 100644
--- a/src/app/views/pools/_instances.haml
+++ b/src/app/views/pools/_instances.haml
@@ -19,7 +19,7 @@
%input{:name => 'instance_selected[]', :type =>
'checkbox', :value => instance.id, :id =>
"instance_checkbox_#{instance.id}" }
= link_to instance.name, instance_path(instance)
%td
- = instance.assembly.present? ? link_to((instance.assembly.name),
assembly_path(instance.assembly)) : '—'
+ = instance.legacy_assembly.present? ? link_to((instance.legacy_assembly.name),
legacy_assembly_path(instance.legacy_assembly)) : '—'
%td
= instance.deployment.present? ? link_to((instance.deployment.name),
deployment_path(instance.deployment)) : '—'
%td
diff --git a/src/app/views/templates/_addbuttons.haml
b/src/app/views/templates/_addbuttons.haml
deleted file mode 100644
index 120f961..0000000
--- a/src/app/views/templates/_addbuttons.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-%fieldset.clear
- - cancel_path = @tpl.id ? edit_template_path(@tpl) : new_template_path
- = restful_submit_tag "Add Selected", "add_selected",
add_selected_templates_path, 'GET', {:class => "grid_2 alpha", :id
=> "do_add_software"}
- = restful_submit_tag "Cancel", "cancel_add_software", cancel_path,
'GET', {:class => "grid_2", :id =>
"cancel_add_software"}
diff --git a/src/app/views/templates/_basics.haml b/src/app/views/templates/_basics.haml
deleted file mode 100644
index 72d2423..0000000
--- a/src/app/views/templates/_basics.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-%h3 General Information
-%fieldset.clearfix
- %label.grid_4.alpha.la Template Name:
- %label.grid_7.la Summary:
- %label.grid_3.suffix_2.omega.la Version:
- = text_field :tpl, :name, :value => @tpl.name || 'Template Name', :class
=> "grid_4 alpha"
- = text_field :tpl, :summary, :value => @tpl.summary || 'Template
Description', :class => "grid_7"
- = text_field_tag 'current_version', 'Current Version', :disabled =>
true, :class => "grid_3"
- %button{:type => 'button', :disabled => 'disabled', :class =>
"grid_2 omega"} New Version
-%fieldset.clearfix
- %label.grid_4.alpha Choose Logo:
- %input{:type => 'file', :disabled => 'disabled', :class =>
"grid_7"}
-%fieldset.clearfix
- - default = @tpl.platforms['fedora']
- = label :tpl, :platform, 'Platform Choice:', :class => "grid_4
alpha"
- = select :tpl, :platform, @tpl.platforms.map {|id, p| ["#{p['name']}
#{p['version']} (#{p['architecture']})", id]}, {:selected =>
@tpl.platform || 'fedora'}, {:class => 'grid_7'}
-%fieldset.clearfix
- = label_tag :bootable, 'Bootable:', :class => "grid_4 alpha"
- .grid_12.omega
- = radio_button_tag :bootable, 'yes', true, :disabled => true
- = label_tag :bootable, 'Yes'
- = radio_button_tag :bootable, 'no', false, :disabled => true
- = label_tag :bootable, 'No'
-%fieldset.clearfix
- %label{:for => :template_group, :class => 'grid_4 alpha'}
- Template Group:
- = select_tag(:template_group, options_for_select([['User Private', 1]]), :class
=> 'grid_4')
diff --git a/src/app/views/templates/_builds.haml b/src/app/views/templates/_builds.haml
deleted file mode 100644
index b546ae8..0000000
--- a/src/app/views/templates/_builds.haml
+++ /dev/null
@@ -1,41 +0,0 @@
-Builds for
-= @tpl.platform_name
-= @tpl.platform_version
-, template "#{(a)tpl.name}"
-
-- form_tag builds_path do
- = hidden_field_tag :template_id, @tpl.id
- - 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?
- %li No Builds
- - else
- - @images.each do |img|
- %li
- - form_tag(retry_builds_path, { :method => :post }) do
- = "#{img.name}-#{img.template.architecture}: #{img.status}"
- = hidden_field_tag :template_id, @tpl.id
- = hidden_field_tag :image_id, img.id
- = submit_tag "Retry build", :name => "build"
- - if img.status == Image::STATE_COMPLETED
- %ul
- - img.legacy_provider_images.each do |pimg|
- %li
- - form_tag(retry_builds_path, { :method => :post }) do
- = "#{pimg.provider.name}: #{pimg.status}"
- = hidden_field_tag :template_id, @tpl.id
- = hidden_field_tag :provider_image_id, pimg.id
- = submit_tag "Retry upload", :name => "build"
- - unless @tpl.imported
- - img.not_uploaded_providers.each do |provider|
- %li
- = "#{provider.name}: "
- not uploaded
- = link_to 'upload', upload_builds_path(:template_id =>
@tpl.id, :image_id => img.id, :provider_id => provider.id), {:class =>
'button'}
diff --git a/src/app/views/templates/_collections.haml
b/src/app/views/templates/_collections.haml
deleted file mode 100644
index 98ce959..0000000
--- a/src/app/views/templates/_collections.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-%ul.collections
- - @collections.each do |c|
- %li
- /- selected = c[:selected] ? true : false
- - selected = false
- = check_box_tag 'groups[]', c[:id], selected, {:disabled => selected,
:id => "group_#{c[:id]}", :class => "#{selected ? 'selected'
: ''}"}
- = label_tag "group_#{c[:id]}", c[:name]
-= render :partial => 'addbuttons'
diff --git a/src/app/views/templates/_form.haml b/src/app/views/templates/_form.haml
deleted file mode 100644
index d326b18..0000000
--- a/src/app/views/templates/_form.haml
+++ /dev/null
@@ -1,120 +0,0 @@
-:javascript
- $(document).ready(function() {
- var $content_container = $('#managed_content');
- var $sel_pkg_container = $('#package_selection_list');
- var $submit = $('#add_software_button');
- $submit.click(function(e) {
- e.preventDefault();
- $submit.hide();
- var data = {
- 'packages[]':
$("input[name='packages[]']").map(function() {return
$(this).val()}).get(),
- 'repository': $("select[name='tpl[platform]']").val()
|| ''
- }
- var url = '#{url_for :action => 'content_selection', :id =>
@id}';
- //$content_container.empty().show();
- $sel_pkg_container.empty().show().addClass('loading');
- $sel_pkg_container.load(url, data, function(){
- $sel_pkg_container.removeClass('loading');
- var $groups = $('.softwaregroups .disclosure', this);
- //search
- $("input[name='package_search']").keypress(function(event) {
- if (event.keyCode == '13') {
- event.preventDefault();
- $("input[name=package_search] ~ button").click();
- }
- });
- $("input[name=package_search] ~ button").click(function(event) {
- event.preventDefault();
- var data = {
- 'packages[]':
$("input:text[name='packages[]']").map(function() {return
$(this).val()}).get(),
- 'package_search':
$("input[name='package_search']").val(),
- 'repository':
$("select[name='tpl[platform]']").val()
- };
- var url = '#{url_for :action => 'search_packages', :id =>
@id}';
- $('#metagrouppackages').empty().addClass('loading');
- $('#metagrouppackages').load(url, data, function() {
- $('#metagrouppackages').removeClass('loading');
- });
- });
- });
- });
- //removing packages from the list
- $('.remove_package').live('click', function (e) {
- e.preventDefault();
- $(this).parent().hide(300, function () {
- $(this).remove();
- });
- });
- //displaying extended package info and actions
- $('.dropdown').hide();
- $('.packagename').live('click', function () {
- var dropdowncontent = $(this).siblings('.dropdown').html(),
- $dropdown = $("#dropdown");
- $('.packagewrap').removeClass('selected');
- $(this).parent().addClass('selected');
- $dropdown.empty().html(dropdowncontent).css({
- 'top': $(this).positionAncestor('#content').top + 17,
- 'left': $(this).positionAncestor('#content').left - 4
- }).show();
- });
- //catch #content clicks and hide the #dropdown if it's not within it
- $("#content").click(function (e) {
- if(!e.target.id === 'dropdown' ||
!$(e.target).closest("#dropdown").length) {
- $("#dropdown").hide();
- $('.packagewrap').removeClass('selected');
- }
- });
- // select correct package repo when we change platform
- $("select[name='tpl[platform]']").change(function() {
- if ($submit.is(':hidden')) {
- $submit.trigger('click');
- }
- });
- // add selected pkgs/groups
- $('#do_add_software').live('click', function(e) {
- e.preventDefault();
- var $button = $(this).clone();
- var label = "<span id='do_add_software' class='loading
fl'>Adding Packages</span>";
- var url = '#{url_for :action => 'managed_content'}';
- var new_pkgs =
$("input:checked[name='selected_packages[]']").map(function() {return
$(this).val()}).get();
- var old_pkgs =
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get()
- var cached_pkgs =
$("input:hidden[name='cached_packages[]']").map(function() {return
$(this).val()}).get()
- var data = {
- 'selected_packages[]': old_pkgs.concat(new_pkgs.concat(cached_pkgs)),
- 'selected_groups[]':
$("input:checked[name='groups[]']").map(function() {return
$(this).val()}).get(),
- 'collections': $("input:hidden[name=collections]").val(),
- 'template_id' : '#{(a)id.nil? ? nil : @id}'
- };
- $(this).replaceWith(label);
- $('#managed_content').load(url, data, function(){
- $("input:checked[name='groups[]']").attr('disabled',
'disabled');
- $("input:checked[name='packages[]']").attr('disabled',
'disabled');
- // $('#add_software_button').show();
- $('.dropdown').hide();
- $('#do_add_software').replaceWith($button);
- });
- });
- // hide sw selection panel
- $('#cancel_add_software').live('click', function(e) {
- e.preventDefault();
- $('#package_selection_list').hide();
- $('#add_software_button').show();
- $('.dropdown').hide();
- });
- });
-
-#build
- = error_messages_for :tpl, :object_name => 'template'
- = render :partial => 'basics'
- = render :partial => 'local_content_to_bundle'
-
- #managed_content
- = render :partial => 'managed_content'
-
- .clearfix
- .grid_16.alpha.omega
- = restful_submit_tag "Add Software", 'collections',
collections_templates_path, 'GET', {:id => "add_software_button",
:class => "iconbutton"}
-
- #package_selection_list{:style => 'display: none'}
-
- = render :partial => 'preboot_configuration'
diff --git a/src/app/views/templates/_hidden_fields.haml
b/src/app/views/templates/_hidden_fields.haml
deleted file mode 100644
index 5709087..0000000
--- a/src/app/views/templates/_hidden_fields.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-= hidden_field :tpl, :id
-= hidden_field :tpl, :name
-= hidden_field :tpl, :summary
-= hidden_field :tpl, :platform
-= hidden_field :tpl, :platform_version
-= hidden_field :tpl, :architecture
-- @tpl.packages.each do |p|
- = hidden_field_tag "packages[]", p, :id => "package_#{p}"
diff --git a/src/app/views/templates/_list.haml b/src/app/views/templates/_list.haml
deleted file mode 100644
index 947a066..0000000
--- a/src/app/views/templates/_list.haml
+++ /dev/null
@@ -1,35 +0,0 @@
-- form_tag do
- = link_to "Create", new_template_path, :class => 'button'
- = restful_submit_tag "Delete", 'destroy',
multi_destroy_templates_path, 'DELETE', :id => 'delete_button'
-
- %table#templates_table
- = sortable_table_header @header
- %tbody
- - if @templates.empty?
- %tr
- %td{:colspan => 6} No Templates
- - else
- - @templates.each do |template|
- %tr
- %td
- = check_box_tag 'selected[]', template.id, @url_params[:select] ==
'all', :id => "selected_#{template.id}"
- = image_tag "blnk.png", :alt => template.platform, :class
=> "icon platform #{template.platform}"
- = link_to template.name, template_path(template)
- %td= template.platform_name
- %td= template.platform_version
- %td= image_tag 'blnk.png', :alt => 'yes', :class =>
"icon yes"
- %td= template.architecture
-
-:javascript
- $(document).ready(function () {
- $('#delete_button').click(function(e) {
- if ($("#templates_table input[@type=radio]:checked").length == 0) {
- alert('Please select any template to be deleted before clicking Delete
button.');
- e.preventDefault();
- } else {
- if (!confirm("Are you sure you want to delete this template?")) {
- e.preventDefault();
- }
- }
- });
- });
diff --git a/src/app/views/templates/_local_content_to_bundle.haml
b/src/app/views/templates/_local_content_to_bundle.haml
deleted file mode 100644
index 109ce20..0000000
--- a/src/app/views/templates/_local_content_to_bundle.haml
+++ /dev/null
@@ -1,21 +0,0 @@
-%h3.disabled.gap Local Content to Bundle
-%fieldset.clearfix
- = label_tag :local_bundle_name, 'Local:', :class => "disabled grid_2
alpha"
- = text_field_tag 'local_bundle_name[]', 'Bundle Name', :disabled =>
true, :class => "grid_8"
- .grid_6.omega
- %button{:type => 'button', :disabled => 'disabled'} Browse
- %button{:type => 'button', :disabled => 'disabled'} Config
- %button{:type => 'button', :disabled => 'disabled'} Metadata
- (
- %a{:href => '#'} Remove
- )
- .grid_2.alpha
-
- = text_field_tag 'local_bundle_name[]', 'Bundle Name', :disabled =>
true, :class => "grid_8"
- .grid_6.omega
- %button{:type => 'button', :disabled => 'disabled'} Browse
- %button{:type => 'button', :disabled => 'disabled'} Config
- %button{:type => 'button', :disabled => 'disabled'} Metadata
- (
- %a{:href => '#'} Remove
- )
diff --git a/src/app/views/templates/_managed_content.haml
b/src/app/views/templates/_managed_content.haml
deleted file mode 100644
index 29f9fd3..0000000
--- a/src/app/views/templates/_managed_content.haml
+++ /dev/null
@@ -1,21 +0,0 @@
-#selected_packages
- %h3.gap Managed Content to Bundle
- .grid_16.alpha.omega
- - if @tpl.packages.empty?
- No selected packages
- - else
- /- repos = @repository_manager.repositories_hash
- - @tpl.packages.sort.each do |pkg|
- /- pkg_group = @groups.keys.find {|g| @groups[g][:packages][pkg]}
- .packagewrap
- %a.packagename{:id => "package_#{pkg}"}=pkg
- = hidden_field_tag 'packages[]', pkg, :id =>
"package_#{pkg}"
- = restful_submit_tag "Remove", "remove_package",
remove_package_templates_path(:name => pkg), 'GET', {:id =>
"remove_package_#{pkg}", :class => 'remove_package'}
- .dropdown
- / we don't display repository for now, it's pretty difficult with
current design
- /%section
- / Repository:
- / %label= (pkg_group and repo = repos[@groups[pkg_group][:repository_id]]) ?
repo.name.to_s : ' '
- %fieldset.nomargin
- %button{:disabled => true} Browse
- %button{:disabled => true} Config
diff --git a/src/app/views/templates/_metagroup_packages.haml
b/src/app/views/templates/_metagroup_packages.haml
deleted file mode 100644
index 82c2697..0000000
--- a/src/app/views/templates/_metagroup_packages.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-- if @metagroup_packages.blank?
- %span.disabled No group selected
-- else
- %h4
- = "#{@metagroup} Packages"
- %ul.metagrouppackages
- - @metagroup_packages.sort {|a, b| a[:name] <=> b[:name]}.each do |group|
- %li
- - selected = false
- %h5
- = check_box_tag 'selected_groups[]', group[:id], selected, {:disabled
=> selected, :id => "group_#{group[:id]}", :class =>
"softwaregroups #{selected ? 'selected' : ''}"}
- = label_tag "group_#{group[:id]}", group[:label]
- %ul
- - group[:packages].each do |pkg|
- %li
- - selected = @packages.to_a.find {|p| p[:name] == pkg}
- = check_box_tag 'selected_packages[]', pkg, selected, {:disabled
=> selected, :id => "pkg_#{group[:name]}_#{pkg}"}
- = label_tag "pkg_#{group[:name]}_#{pkg}", pkg
- = render :partial => 'addbuttons'
diff --git a/src/app/views/templates/_metagroups.haml
b/src/app/views/templates/_metagroups.haml
deleted file mode 100644
index b313e55..0000000
--- a/src/app/views/templates/_metagroups.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-%fieldset.clearfix
- .search.grid_4.alpha
- %input{:type => "search", :placeholder => "Search for
package", :name => 'package_search', :value => params[:package_search],
:id => 'package_search'}
- %button.action{:id => 'package_search_button', :name =>
'package_search_button' , :value => 'true'}
- .grid_8
- %a.grid_4.omega Advanced Search
-
-%ul.metagroups{:class => 'packagegroupsidebar grid_4 alpha'}
- %li
- = restful_submit_tag 'Collections', 'collections',
collections_templates_path, 'GET', {:id => 'collections', :class =>
'icon'}
- - @metagroups.keys.sort.each do |cat|
- %li
- = restful_submit_tag cat, "metagroup_packages",
metagroup_packages_templates_path, 'GET', {:class => 'icon'}
diff --git a/src/app/views/templates/_preboot_configuration.haml
b/src/app/views/templates/_preboot_configuration.haml
deleted file mode 100644
index 79ae839..0000000
--- a/src/app/views/templates/_preboot_configuration.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-%h3.clear.gap Preboot Configuration
-%fieldset.clearfix
- .grid_4.alpha
- = radio_button_tag :configure_via_script, 'no', :disabled => true
- = label_tag :configure_via_script, 'Configure Via Script'
- = file_field_tag 'script_file', :disabled => true, :class => 'grid_12
omega'
-%fieldset.clearfix
- .grid_4.alpha
- = radio_button_tag :configure_via_script, 'no', :disabled => true
- = label_tag :configure_via_script, 'Configure Via Script'
- = file_field_tag 'script_file', :disabled => true, :class => 'grid_12
omega'
diff --git a/src/app/views/templates/_properties.haml
b/src/app/views/templates/_properties.haml
deleted file mode 100644
index d47a13a..0000000
--- a/src/app/views/templates/_properties.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-%h3
- Properties for
- = @tpl.name
-= link_to "Edit", edit_template_path(@tpl), { :class => 'button' }
diff --git a/src/app/views/templates/_search_packages.haml
b/src/app/views/templates/_search_packages.haml
deleted file mode 100644
index 78fa5b1..0000000
--- a/src/app/views/templates/_search_packages.haml
+++ /dev/null
@@ -1,45 +0,0 @@
-:javascript
- $(document).ready(function() {
- $('.pagination input[type=submit]').click(function(e) {
- e.preventDefault();
- var url = '#{url_for :action => 'search_packages', :id =>
@id}';
- var old_pkgs =
$("input:hidden[name='cached_packages[]']").map(function() {return
$(this).val()}).get();
- var new_pkgs =
$("input:checked[name='selected_packages[]']").map(function() {return
$(this).val()}).get();
- var data = {
- 'selected_packages[]':
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get(),
- 'cached_packages[]': old_pkgs.concat(new_pkgs),
- 'selected_groups[]':
$("input:checked[name='groups[]']").map(function() {return
$(this).val()}).get(),
- 'package_search':
$("input[name='package_search']").val(),
- 'old_page': '#{@page}',
- 'template_id' : '#{(a)id.nil? ? nil : @id}',
- 'page': $(this).val(),
- 'repository': $("select[name='tpl[platform]']").val()
- };
- $('#metagrouppackages').empty().addClass('loading');
- $('#metagrouppackages').load(url, data, function() {
- $('#metagrouppackages').removeClass('loading');
- })
- });
- });
-
-- @cached_packages.uniq.each do |pkg|
- = hidden_field_tag 'cached_packages[]', pkg
-
-- if params[:package_search].empty?
- Search string is empty.
--else
- %h4
- = "Search Results for '#{params[:package_search]}'"
- %ul.searchedpackages
- - @searched_packages.sort {|a, b| a [:name] <=> b[:name]}.each do |pkg|
- %li
- - selected = (@packages.to_a.find {|p| p[:name] == pkg[:name]} or
@cached_packages.include?(pkg[:name]))
- - disabled = @tpl.packages.include?(pkg[:name])
- = check_box_tag 'selected_packages[]', pkg[:name], selected, {:disabled
=> disabled, :id => "pkg_#{pkg[:name]}"}
- = label_tag "pkg_#{pkg[:name]}", pkg[:name]
- .pageinfo
- = page_entries_info @searched_packages, :entry_name => 'package'
- = will_paginate @searched_packages, :params => {:package_search =>
params[:package_search]}, :renderer => TemplatesHelper::ButtonPaginationRenderer.new,
:previous_label => 'Previous', :next_label => 'Next'
-
-
- = render :partial => 'addbuttons'
diff --git a/src/app/views/templates/_software_selection.haml
b/src/app/views/templates/_software_selection.haml
deleted file mode 100644
index 34606fc..0000000
--- a/src/app/views/templates/_software_selection.haml
+++ /dev/null
@@ -1,41 +0,0 @@
-:javascript
- $(document).ready(function() {
- var $metagrouppackages = $('#metagrouppackages');
- $('.metagroups input').click(function(e) {
- e.preventDefault();
- var data = {
- 'repository': $("select[name='tpl[platform]']").val(),
- 'packages[]':
$("input:hidden[name='packages[]']").map(function() {return
$(this).val()}).get()
- };
- if ($(this).attr('name') == '__rewrite[collections]') {
- var url = '#{url_for :action => 'collections', :id =>
@id}';
- } else {
- var url = '#{url_for :action => 'metagroup_packages', :id =>
@id}';
- data.__rewrite = {
- metagroup_packages: e.currentTarget.value
- };
- }
- $metagrouppackages.empty().addClass('loading');
- $metagrouppackages.load(url, data, function() {
- $metagrouppackages.removeClass('loading');
- //select all packages in collection
- $(".softwaregroups").click(function() {
- if ($(this).attr("checked") === true) {
-
$(this).parent().siblings("ul").find("input[type='checkbox']").attr("checked","checked");
- } else {
-
$(this).parent().siblings("ul").find("input[type='checkbox']").removeAttr("checked");
- }
- });
- });
- });
- });
-
-.grid_16
- %h4 Managed Content Selection
-
- - form_tag do
- - unless request.xhr?
- = render :partial => 'hidden_fields'
- = render :partial => 'metagroups'
- #metagrouppackages.grid_12.omega.gap
- = render :partial => view
diff --git a/src/app/views/templates/collections.haml
b/src/app/views/templates/collections.haml
deleted file mode 100644
index a899c85..0000000
--- a/src/app/views/templates/collections.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'software_selection', :locals => {:view =>
'collections'}
diff --git a/src/app/views/templates/edit.haml b/src/app/views/templates/edit.haml
deleted file mode 100644
index 959ed7a..0000000
--- a/src/app/views/templates/edit.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-#dropdown
-.grid_16
- %h2 Edit Template
- /- form_for @tpl, :url => template_path(@tpl), :html => { :method => :put } do
|f|
- - form_tag do
- = hidden_field_tag :id, @tpl.id
- = render :partial => 'form'
- = restful_submit_tag "Save", 'update', template_path(@tpl),
'PUT', :class => "formbutton"
- = link_to 'Cancel', templates_path, :class => 'button formbutton'
diff --git a/src/app/views/templates/index.haml b/src/app/views/templates/index.haml
deleted file mode 100644
index 62ccbc6..0000000
--- a/src/app/views/templates/index.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-- content_for :list do
- = render :partial => 'list'
diff --git a/src/app/views/templates/managed_content.haml
b/src/app/views/templates/managed_content.haml
deleted file mode 100644
index 926142d..0000000
--- a/src/app/views/templates/managed_content.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'managed_content'
diff --git a/src/app/views/templates/metagroup_packages.haml
b/src/app/views/templates/metagroup_packages.haml
deleted file mode 100644
index 9703663..0000000
--- a/src/app/views/templates/metagroup_packages.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'software_selection', :locals => {:view =>
'metagroup_packages'}
diff --git a/src/app/views/templates/new.haml b/src/app/views/templates/new.haml
deleted file mode 100644
index dcc6bfc..0000000
--- a/src/app/views/templates/new.haml
+++ /dev/null
@@ -1,10 +0,0 @@
-#dropdown
-.grid_16
- %h2 New Template
- /- form_for @tpl, :url => templates_path do |f|
- - form_tag do
- = render :partial => 'form'
- = check_box_tag :create_deployable
- = label_tag :create_deployable, "Create Deployable for this template"
- = restful_submit_tag "Save", 'create', templates_path,
'POST', :class => "formbutton"
- = link_to 'Cancel', templates_path, :class => 'button formbutton'
diff --git a/src/app/views/templates/search_packages.haml
b/src/app/views/templates/search_packages.haml
deleted file mode 100644
index 94e30f5..0000000
--- a/src/app/views/templates/search_packages.haml
+++ /dev/null
@@ -1 +0,0 @@
-= render :partial => 'software_selection', :locals => {:view =>
'search_packages'}
diff --git a/src/app/views/templates/show.haml b/src/app/views/templates/show.haml
deleted file mode 100644
index 05eeedd..0000000
--- a/src/app/views/templates/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/templates/xml/_hardware_profile.xml.haml
b/src/app/views/templates/xml/_hardware_profile.xml.haml
deleted file mode 100644
index c51691f..0000000
--- a/src/app/views/templates/xml/_hardware_profile.xml.haml
+++ /dev/null
@@ -1,6 +0,0 @@
-!!! XML
-%hardware_profile{ :href => hardware_profile_path(profile.id), :id =>
profile.external_key }<>
- %name<>
- = profile.name
- - [profile.memory, profile.cpu, profile.architecture, profile.storage].each do |prop|
- = render :partial => 'templates/xml/hardware_profile_property.xml',
:locals => { :property => prop }
diff --git a/src/app/views/templates/xml/_hardware_profile_property.xml.haml
b/src/app/views/templates/xml/_hardware_profile_property.xml.haml
deleted file mode 100644
index bb0fa70..0000000
--- a/src/app/views/templates/xml/_hardware_profile_property.xml.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-!!! XML
-- if property.kind == "range"
- %property{ :kind => property.kind, :name => property.name, :unit =>
property.unit, :value => property.value, :first => property.range_first, :last =>
property.range_last }<>
-- else
- %property{ :kind => property.kind, :name => property.name, :unit =>
property.unit, :value => property.value }<>
- - if property.kind == "enum"
- %enum<>
- - property.property_enum_entries.each do |e|
- %entry{ :value => e.value }<>
\ No newline at end of file
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 73ddb39..1ca4035 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -130,8 +130,8 @@ en:
index:
deleted: "Deleted the following Pool Families: %{list}."
not_deleted: "Could not delete the following Pool Families: %{list}."
- templates:
- templates: Templates
+ legacy_templates:
+ legacy_templates: Templates
index:
deleted:
one: "Template %{list} was deleted."
diff --git a/src/config/navigation.rb b/src/config/navigation.rb
index 805e5ff..caa711d 100644
--- a/src/config/navigation.rb
+++ b/src/config/navigation.rb
@@ -6,9 +6,9 @@ SimpleNavigation::Configuration.run do |navigation|
second_level.item :deployments,
t('deployments.deployments'),deployments_path, :highlights_on =>
/^\/$|\/deployments/
second_level.item :instances, t("instances.instances"), instances_path
end
- 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
+ first_level.item :image_factory, t(:image_factory), legacy_templates_path,
:highlights_on => /\/image_factory/ do |second_level|
+ second_level.item :legacy_templates,
t('legacy_templates.legacy_templates'), legacy_templates_path
+ second_level.item :assemblies, t(:assemblies), legacy_assemblies_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
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 63b2de5..100e960 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -34,15 +34,15 @@ ActionController::Routing::Routes.draw do |map|
map.resources :pools, :collection => { :multi_destroy => :delete }
map.resources :deployments, :collection => { :multi_stop => :get, :launch_new
=> :get }
- map.resources :instances, :collection => {:start => :get, :multi_stop => :get,
:select_template => :get, :remove_failed => :get, :can_start => :get, :can_create
=> :get }, :member => {:key => :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 }
map.can_create_instance
'/instances/:instance_id/can_create/:provider_account_id', :controller =>
'instances', :action => 'can_create', :conditions => { :method =>
:get }
- map.resources :assemblies
+ map.resources :legacy_assemblies
map.resources :image_imports
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.resources :legacy_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/20090804140143_create_images.rb
b/src/db/migrate/20090804140143_create_images.rb
deleted file mode 100644
index 3a31c49..0000000
--- a/src/db/migrate/20090804140143_create_images.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# 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.
-
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-
-class CreateImages < ActiveRecord::Migration
- def self.up
- create_table :images do |t|
- t.string :uuid
- t.string :name, :null => false
- t.string :build_id
- t.string :uri
- t.string :status
- t.string :target
- t.integer :template_id
- t.timestamps
- end
-
- create_table :replicated_images do |t|
- t.integer :image_id, :null => false
- t.integer :provider_id, :null => false
- t.string :provider_image_key
- t.boolean :uploaded, :default => false
- t.boolean :registered, :default => false
- end
- end
-
- def self.down
- drop_table :replicated_images
- drop_table :images
- end
-end
diff --git a/src/db/migrate/20090804140143_create_legacy_images.rb
b/src/db/migrate/20090804140143_create_legacy_images.rb
new file mode 100644
index 0000000..a6a3f4a
--- /dev/null
+++ b/src/db/migrate/20090804140143_create_legacy_images.rb
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class CreateLegacyImages < ActiveRecord::Migration
+ def self.up
+ create_table :legacy_images do |t|
+ t.string :uuid
+ t.string :name, :null => false
+ t.string :build_id
+ t.string :uri
+ t.string :status
+ t.string :target
+ t.integer :legacy_template_id
+ t.timestamps
+ end
+
+ create_table :replicated_images do |t|
+ t.integer :legacy_image_id, :null => false
+ t.integer :provider_id, :null => false
+ t.string :provider_image_key
+ t.boolean :uploaded, :default => false
+ t.boolean :registered, :default => false
+ end
+ end
+
+ def self.down
+ drop_table :replicated_images
+ drop_table :legacy_images
+ end
+end
diff --git a/src/db/migrate/20090804142049_create_instances.rb
b/src/db/migrate/20090804142049_create_instances.rb
index de5533d..e784c45 100644
--- a/src/db/migrate/20090804142049_create_instances.rb
+++ b/src/db/migrate/20090804142049_create_instances.rb
@@ -25,7 +25,7 @@ class CreateInstances < ActiveRecord::Migration
t.string :external_key
t.string :name, :null => false, :limit => 1024
t.integer :hardware_profile_id, :null => false
- t.integer :template_id, :null => false
+ t.integer :legacy_template_id, :null => false
t.integer :realm_id
t.integer :owner_id
t.integer :pool_id, :null => false
diff --git a/src/db/migrate/20100830150014_create_legacy_templates.rb
b/src/db/migrate/20100830150014_create_legacy_templates.rb
new file mode 100644
index 0000000..67ab6c3
--- /dev/null
+++ b/src/db/migrate/20100830150014_create_legacy_templates.rb
@@ -0,0 +1,23 @@
+class CreateLegacyTemplates < ActiveRecord::Migration
+ def self.up
+ create_table :legacy_templates do |t|
+ t.string :uuid, :null => false
+ t.binary :xml, :null => false
+ t.string :uri
+ t.string :name
+ t.string :platform
+ t.string :platform_version
+ t.string :architecture
+ t.text :summary
+ t.boolean :complete, :default => false
+ t.boolean :uploaded, :default => false
+ t.boolean :imported, :default => false
+ t.integer :legacy_images_count
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :legacy_templates
+ end
+end
diff --git a/src/db/migrate/20100830150014_create_templates.rb
b/src/db/migrate/20100830150014_create_templates.rb
deleted file mode 100644
index 4bf569d..0000000
--- a/src/db/migrate/20100830150014_create_templates.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class CreateTemplates < ActiveRecord::Migration
- def self.up
- create_table :templates do |t|
- t.string :uuid, :null => false
- t.binary :xml, :null => false
- t.string :uri
- t.string :name
- t.string :platform
- t.string :platform_version
- t.string :architecture
- t.text :summary
- t.boolean :complete, :default => false
- t.boolean :uploaded, :default => false
- t.boolean :imported, :default => false
- t.integer :images_count
- t.timestamps
- end
- end
-
- def self.down
- drop_table :templates
- end
-end
diff --git a/src/db/migrate/20110119000000_owner_roles.rb
b/src/db/migrate/20110119000000_owner_roles.rb
index 15ebd84..4220fea 100644
--- a/src/db/migrate/20110119000000_owner_roles.rb
+++ b/src/db/migrate/20110119000000_owner_roles.rb
@@ -24,7 +24,7 @@ class OwnerRoles < ActiveRecord::Migration
"Pool Owner",
"Provider Owner",
"Provider Account Owner",
- "Template Owner"]
+ "LegacyTemplate Owner"]
def self.up
add_column :roles, :assign_to_owner, :boolean, :default => false
diff --git a/src/db/migrate/20110202165053_change_column_target_in_images.rb
b/src/db/migrate/20110202165053_change_column_target_in_images.rb
deleted file mode 100644
index 135fddc..0000000
--- a/src/db/migrate/20110202165053_change_column_target_in_images.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class ChangeColumnTargetInImages < ActiveRecord::Migration
- def self.up
- remove_column :images, :target
- add_column :images, :target, :integer
- end
-
- def self.down
- remove_column :images, :target
- add_column :images, :target, :string
- end
-end
diff --git a/src/db/migrate/20110202165053_change_column_target_in_legacy_images.rb
b/src/db/migrate/20110202165053_change_column_target_in_legacy_images.rb
new file mode 100644
index 0000000..49650cc
--- /dev/null
+++ b/src/db/migrate/20110202165053_change_column_target_in_legacy_images.rb
@@ -0,0 +1,11 @@
+class ChangeColumnTargetInLegacyImages < ActiveRecord::Migration
+ def self.up
+ remove_column :legacy_images, :target
+ add_column :legacy_images, :target, :integer
+ end
+
+ def self.down
+ remove_column :legacy_images, :target
+ add_column :legacy_images, :target, :string
+ end
+end
diff --git a/src/db/migrate/20110207100700_create_assemblies.rb
b/src/db/migrate/20110207100700_create_assemblies.rb
deleted file mode 100644
index 7e4be57..0000000
--- a/src/db/migrate/20110207100700_create_assemblies.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-class CreateAssemblies < ActiveRecord::Migration
- def self.up
- create_table :assemblies do |t|
- t.string :uuid, :null => false
- t.binary :xml, :null => false
- t.string :uri
- t.string :name
- t.string :architecture
- t.text :summary
- t.boolean :uploaded, :default => false
- t.integer :lock_version, :default => 0
- t.timestamps
- end
- create_table :assemblies_templates, :id => false do |t|
- t.integer :assembly_id, :null => false
- t.integer :template_id, :null => false
- end
- end
-
- def self.down
- drop_table :assemblies_templates
- drop_table :assemblies
- end
-end
diff --git a/src/db/migrate/20110207100700_create_legacy_assemblies.rb
b/src/db/migrate/20110207100700_create_legacy_assemblies.rb
new file mode 100644
index 0000000..2c3a765
--- /dev/null
+++ b/src/db/migrate/20110207100700_create_legacy_assemblies.rb
@@ -0,0 +1,24 @@
+class CreateLegacyAssemblies < ActiveRecord::Migration
+ def self.up
+ create_table :legacy_assemblies do |t|
+ t.string :uuid, :null => false
+ t.binary :xml, :null => false
+ t.string :uri
+ t.string :name
+ t.string :architecture
+ t.text :summary
+ t.boolean :uploaded, :default => false
+ t.integer :lock_version, :default => 0
+ t.timestamps
+ end
+ create_table :legacy_assemblies_legacy_templates, :id => false do |t|
+ t.integer :legacy_assembly_id, :null => false
+ t.integer :legacy_template_id, :null => false
+ end
+ end
+
+ def self.down
+ drop_table :legacy_assemblies_legacy_templates
+ drop_table :legacy_assemblies
+ end
+end
diff --git a/src/db/migrate/20110207100800_update_deployables.rb
b/src/db/migrate/20110207100800_update_deployables.rb
index 58b3675..6ba39c7 100644
--- a/src/db/migrate/20110207100800_update_deployables.rb
+++ b/src/db/migrate/20110207100800_update_deployables.rb
@@ -9,14 +9,14 @@ class UpdateDeployables < ActiveRecord::Migration
t.boolean :uploaded, :default => false
end
- create_table :assemblies_legacy_deployables, :id => false do |t|
- t.integer :assembly_id, :null => false
+ create_table :legacy_assemblies_legacy_deployables, :id => false do |t|
+ t.integer :legacy_assembly_id, :null => false
t.integer :legacy_deployable_id, :null => false
end
end
def self.down
- drop_table :assemblies_legacy_deployables
+ drop_table :legacy_assemblies_legacy_deployables
change_table :legacy_deployables do |t|
t.remove :lock_version, :uuid, :xml, :uri, :summary, :uploaded
end
diff --git a/src/db/migrate/20110207101000_update_instances.rb
b/src/db/migrate/20110207101000_update_instances.rb
index f326e03..458d235 100644
--- a/src/db/migrate/20110207101000_update_instances.rb
+++ b/src/db/migrate/20110207101000_update_instances.rb
@@ -1,21 +1,21 @@
class UpdateInstances < ActiveRecord::Migration
def self.up
change_table :instances do |t|
- t.integer :assembly_id
+ t.integer :legacy_assembly_id
t.integer :deployment_id
- t.change :template_id, :integer, :null => true
+ t.change :legacy_template_id, :integer, :null => true
end
- create_table :assemblies_instances, :id => false do |t|
- t.integer :assembly_id, :null => false
+ create_table :instances_legacy_assemblies, :id => false do |t|
+ t.integer :legacy_assembly_id, :null => false
t.integer :legacy_deployable_id, :null => false
end
end
def self.down
change_table :instances do |t|
- t.remove :assembly_id, :deployment_id
- t.change :template_id, :integer, :null => false
+ t.remove :legacy_assembly_id, :deployment_id
+ t.change :legacy_template_id, :integer, :null => false
end
end
end
diff --git a/src/db/migrate/20110207101100_deployment_roles.rb
b/src/db/migrate/20110207101100_deployment_roles.rb
index 6799317..87dab6e 100644
--- a/src/db/migrate/20110207101100_deployment_roles.rb
+++ b/src/db/migrate/20110207101100_deployment_roles.rb
@@ -36,7 +36,7 @@ class DeploymentRoles < ActiveRecord::Migration
Deployment =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
Quota => [VIEW, MOD],
PoolFamily => [VIEW,
MOD,CRE,VPRM,GPRM],
- Template =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
+ LegacyTemplate =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
BasePermissionObject => [ MOD,
VPRM,GPRM]}]}}
def self.up
unless Role.all.size == 0
diff --git a/src/db/migrate/20110223132404_add_target_id_column_to_images.rb
b/src/db/migrate/20110223132404_add_target_id_column_to_images.rb
deleted file mode 100644
index c88953d..0000000
--- a/src/db/migrate/20110223132404_add_target_id_column_to_images.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-class AddTargetIdColumnToImages < ActiveRecord::Migration
-
- PROVIDER_TYPES = { 0 => "Mock", 1 => "Amazon EC2", 2 =>
"GoGrid", 3 => "Rackspace", 4 => "RHEV-M", 5 =>
"OpenNebula" }
- INVERTED_PROVIDER_TYPES = PROVIDER_TYPES.invert
-
- def self.up
- add_column :images, :provider_type_id, :integer, :null => false, :default =>
100
- transform_target_column
- remove_column :images, :target end
-
- def self.down
- add_column :images, :target, :integer
- transform_target_column_back
- remove_column :images, :provider_type_id
- end
-
- def self.transform_target_column
- Image.all.each do |image|
- image.update_attribute(:provider_type_id, ProviderType.first(:conditions =>
{:name => PROVIDER_TYPES[image.target] }).id)
- end
- end
-
- def self.transform_target_column_back
- Image.all.each do |image|
- image.update_attribute(:target, INVERTED_PROVIDER_TYPES[image.provider_type.name])
- end
- end
-end
diff --git a/src/db/migrate/20110223132404_add_target_id_column_to_legacy_images.rb
b/src/db/migrate/20110223132404_add_target_id_column_to_legacy_images.rb
new file mode 100644
index 0000000..62bb690
--- /dev/null
+++ b/src/db/migrate/20110223132404_add_target_id_column_to_legacy_images.rb
@@ -0,0 +1,28 @@
+class AddTargetIdColumnToLegacyImages < ActiveRecord::Migration
+
+ PROVIDER_TYPES = { 0 => "Mock", 1 => "Amazon EC2", 2 =>
"GoGrid", 3 => "Rackspace", 4 => "RHEV-M", 5 =>
"OpenNebula" }
+ INVERTED_PROVIDER_TYPES = PROVIDER_TYPES.invert
+
+ def self.up
+ add_column :legacy_images, :provider_type_id, :integer, :null => false, :default
=> 100
+ transform_target_column
+ remove_column :legacy_images, :target end
+
+ def self.down
+ add_column :legacy_images, :target, :integer
+ transform_target_column_back
+ remove_column :legacy_images, :provider_type_id
+ end
+
+ def self.transform_target_column
+ LegacyImage.all.each do |image|
+ image.update_attribute(:provider_type_id, ProviderType.first(:conditions =>
{:name => PROVIDER_TYPES[image.target] }).id)
+ end
+ end
+
+ def self.transform_target_column_back
+ LegacyImage.all.each do |image|
+ image.update_attribute(:target, INVERTED_PROVIDER_TYPES[image.provider_type.name])
+ end
+ end
+end
diff --git a/src/db/migrate/20110322120000_add_legacy_template_creator_role.rb
b/src/db/migrate/20110322120000_add_legacy_template_creator_role.rb
new file mode 100644
index 0000000..7b35532
--- /dev/null
+++ b/src/db/migrate/20110322120000_add_legacy_template_creator_role.rb
@@ -0,0 +1,47 @@
+#
+# 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.
+
+class AddLegacyTemplateCreatorRole < ActiveRecord::Migration
+
+
+ def self.up
+ unless Role.all.empty?
+ Role.transaction do
+ role_name = "LegacyTemplate Creator"
+ role = Role.find_or_initialize_by_name(role_name)
+ role.update_attributes({:name => role_name, :scope =>
BasePermissionObject.name,
+ :assign_to_owner => false})
+ role.save!
+ ["view","use","create"].each do |action|
+ Privilege.create!(:role => role, :target_type => LegacyTemplate.name,
+ :action => action)
+ end
+ end
+ settings = {"self_service_default_template_obj" =>
BasePermissionObject.general_permission_scope,
+ "self_service_default_template_role" =>
Role.find_by_name("LegacyTemplate Creator"),
+ "self_service_perms_list" =>
"[self_service_default_pool,self_service_default_role],
[self_service_default_template_obj,self_service_default_template_role]"}
+ settings.each_pair do |key, value|
+ MetadataObject.set(key, value)
+ end
+ end
+ end
+
+ def self.down
+ end
+end
diff --git a/src/db/migrate/20110322120000_add_template_creator_role.rb
b/src/db/migrate/20110322120000_add_template_creator_role.rb
deleted file mode 100644
index 301f048..0000000
--- a/src/db/migrate/20110322120000_add_template_creator_role.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# 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.
-
-class AddTemplateCreatorRole < ActiveRecord::Migration
-
-
- def self.up
- unless Role.all.empty?
- Role.transaction do
- role_name = "Template Creator"
- role = Role.find_or_initialize_by_name(role_name)
- role.update_attributes({:name => role_name, :scope =>
BasePermissionObject.name,
- :assign_to_owner => false})
- role.save!
- ["view","use","create"].each do |action|
- Privilege.create!(:role => role, :target_type => Template.name,
- :action => action)
- end
- end
- settings = {"self_service_default_template_obj" =>
BasePermissionObject.general_permission_scope,
- "self_service_default_template_role" =>
Role.find_by_name("Template Creator"),
- "self_service_perms_list" =>
"[self_service_default_pool,self_service_default_role],
[self_service_default_template_obj,self_service_default_template_role]"}
- settings.each_pair do |key, value|
- MetadataObject.set(key, value)
- end
- end
- end
-
- def self.down
- end
-end
diff --git a/src/db/migrate/20110427071851_add_owner_id.rb
b/src/db/migrate/20110427071851_add_owner_id.rb
index 2f568d3..8f23583 100644
--- a/src/db/migrate/20110427071851_add_owner_id.rb
+++ b/src/db/migrate/20110427071851_add_owner_id.rb
@@ -1,13 +1,13 @@
class AddOwnerId < ActiveRecord::Migration
def self.up
- add_column :templates, :owner_id, :integer
- add_column :assemblies, :owner_id, :integer
+ add_column :legacy_templates, :owner_id, :integer
+ add_column :legacy_assemblies, :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 :legacy_templates, :owner_id
+ remove_column :legacy_assemblies, :owner_id
remove_column :legacy_deployables, :owner_id
end
end
diff --git a/src/db/seeds.rb b/src/db/seeds.rb
index ad2c770..0d5c15b 100644
--- a/src/db/seeds.rb
+++ b/src/db/seeds.rb
@@ -41,9 +41,9 @@ roles =
ProviderAccount =>
{"Provider Account User" => [false, {ProviderAccount =>
[VIEW,USE]}],
"Provider Account Owner" => [true, {ProviderAccount =>
[VIEW,USE,MOD, VPRM,GPRM]}]},
- Template =>
- {"Template User" => [false, {Template => [VIEW,USE]}],
- "Template Owner" => [true, {Template => [VIEW,USE,MOD,
VPRM,GPRM]}]},
+ LegacyTemplate =>
+ {"Template User" => [false, {LegacyTemplate =>
[VIEW,USE]}],
+ "Template Owner" => [true, {LegacyTemplate =>
[VIEW,USE,MOD, VPRM,GPRM]}]},
BasePermissionObject =>
{"Provider Creator" => [false, {Provider => [
CRE]}],
"Provider Administrator" => [false, {Provider => [VIEW,
MOD,CRE,VPRM,GPRM],
@@ -56,8 +56,8 @@ roles =
Deployment =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
Quota => [VIEW, MOD],
PoolFamily => [VIEW,
MOD,CRE,VPRM,GPRM]}],
- "Template Administrator" => [false, {Template =>
[VIEW,USE,MOD,CRE,VPRM,GPRM]}],
- "Template Creator" => [false, {Template => [VIEW,USE,
CRE]}],
+ "Template Administrator" => [false, {LegacyTemplate =>
[VIEW,USE,MOD,CRE,VPRM,GPRM]}],
+ "Template Creator" => [false, {LegacyTemplate =>
[VIEW,USE, CRE]}],
"Administrator" => [false, {Provider => [VIEW,
MOD,CRE,VPRM,GPRM],
ProviderAccount =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
HardwareProfile => [
MOD,CRE,VPRM,GPRM],
@@ -68,7 +68,7 @@ roles =
Deployment =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
Quota => [VIEW, MOD],
PoolFamily => [VIEW,
MOD,CRE,VPRM,GPRM],
- Template =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
+ LegacyTemplate =>
[VIEW,USE,MOD,CRE,VPRM,GPRM],
BasePermissionObject => [ MOD,
VPRM,GPRM]}]}}
Role.transaction do
roles.each do |role_scope, scoped_hash|
diff --git a/src/features/image_import.feature b/src/features/image_import.feature
index 1f85309..248ec25 100644
--- a/src/features/image_import.feature
+++ b/src/features/image_import.feature
@@ -20,7 +20,7 @@ Feature: Import Images
And I fill in "ami_id" with "img1"
Given I press "Import"
Then I should see "Image successfully imported"
- And I should be on the templates page
+ And I should be on the legacy_templates page
Scenario: Import an already imported image
When I select "provider1" from "provider_account_id"
diff --git a/src/features/legacy_template.feature b/src/features/legacy_template.feature
new file mode 100644
index 0000000..c4648f9
--- /dev/null
+++ b/src/features/legacy_template.feature
@@ -0,0 +1,228 @@
+Feature: Manage Templates
+ In order to manage my cloud infrastructure
+ As a user
+ I want to manage legacy_templates
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+ And There is a mock pulp repository
+
+ Scenario: Create a new Template
+ Given I am on the templates page
+ When I follow "Create"
+ Then I should be on the new template page
+ When I fill in the following:
+ | tpl_name | mocktemplate |
+ | tpl_platform | fedora13 |
+ | tpl_summary | mockdesc |
+ When I press "Save"
+ Then I should be on the templates page
+ And I should see "Template saved"
+ And I should see "mocktemplate"
+
+ Scenario: Add a package to a new template
+ Given I am on the new template page
+ When I press "Add Software"
+ When I press "admin-tools"
+ Then I should see "System Tools"
+ And I should see "libdeltacloud"
+ When I check "libdeltacloud"
+ And I press "Add Selected"
+ Then I should see "New Template"
+ And I should see "libdeltacloud"
+
+ Scenario: Add a searched package to a new template
+ Given I am on the new template page
+ When I press "Add Software"
+ And I fill in "package_search" with "libdeltacloud"
+ And I press "package_search_button"
+ Then I should see "libdeltacloud"
+ When I check "libdeltacloud"
+ And I press "Add Selected"
+ Then I should see "New Template"
+ And I should see "libdeltacloud"
+
+ Scenario: Add group and remove package to/from the template
+ Given I am on the templates page
+ When I follow "Create"
+ Then I should be on the new template page
+ When I fill in the following:
+ | tpl_name | mocktemplate |
+ And I press "Add Software"
+ Then I should see "Managed Content Selection"
+ When I press "Collections"
+ And I check "group_system-tools"
+ And I press "Add Selected"
+ Then I should see "Managed Content to Bundle"
+ And the "tpl[name]" field by name should contain "mocktemplate"
+ And the page should contain "#package_libdeltacloud" selector
+ When I press "remove_package_libdeltacloud"
+ Then I should see "Managed Content to Bundle"
+ And the page should not contain "#package_libdeltacloud" selector
+ When I press "Save"
+ Then I should be on the templates page
+ And I should see "Template saved"
+ And I should see "mocktemplate"
+
+ Scenario: Add group of packages to existing template
+ Given there is a "mock1" template
+ And has package "deltacloud-aggregator"
+ When I edit the template
+ And I press "Add Software"
+ Then I should see "Managed Content Selection"
+ When I press "Collections"
+ And I check "group_system-tools"
+ And I press "Add Selected"
+ Then I should see "Managed Content to Bundle"
+ And the page should contain "#package_libdeltacloud" selector
+ When I press "Save"
+ Then I should be on the templates page
+ And I should see "Template updated"
+ When I edit the template
+ Then the page should contain "#package_libdeltacloud" selector
+
+ Scenario: Sorting legacy_templates
+ Given there is a "mock1" template
+ And there is a "mock2" template
+ And I am on the templates page
+ When I follow "Name" within "#legacy_templates_table"
+ Then I should see "mock1" followed by "mock2"
+ When I follow "Name" within "#legacy_templates_table"
+ Then I should see "mock2" followed by "mock1"
+
+ Scenario: Sorting template builds
+ Given there is a "mock1" build
+ And there is a "mock2" build
+ And I am on the template builds page
+ When I follow "Name"
+ Then I should see "mock1" followed by "mock2"
+ When I follow "Name"
+ Then I should see "mock2" followed by "mock1"
+
+ Scenario: Search software with empty string
+ Given I am on the new template page
+ When I press "Add Software"
+ And I fill in "package_search" with ""
+ And I press "package_search_button"
+ Then I should see "Search string is empty"
+
+ Scenario: Show software selection
+ Given I am on the new template page
+ And I press "Add Software"
+ Then I should see an input "Collections"
+ # test that we see a metagroup
+ Then I should see an input "admin-tools"
+ # test that we see a collection (collections are loaded by default)
+ And I should see an input "system-tools"
+
+ Scenario: See upload status
+ Given there is a "mock1" template
+ And there is Amazon AWS build and push for this template
+ And I am on the templates page
+ When I choose this template
+ And I follow "Builds"
+ Then I should see "amazon-ec2: complete"
+
+ Scenario: Build template
+ Given there is a "mock1" template
+ And there is Amazon AWS provider account
+ And I am on the templates page
+ When I choose this template
+ 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 legacy_template page
+ And I should see "mock1"
+
+ Scenario: Upload image
+ Given there is a "mock1" template
+ And I am on the templates page
+ And there is Amazon AWS build for this template
+ And there is Amazon AWS provider
+ And I am on the templates page
+ When I choose this template
+ And I follow "Builds"
+ Then I should see "amazon-ec2: not uploaded upload"
+ When I follow "upload"
+ Then I should see "Builds"
+ # TODO: fix status once uploaded field is replaced by status field
+ And I should see "amazon-ec2: queued"
+
+ Scenario: Build imported template
+ Given there is an imported template
+ And there is Amazon AWS provider account
+ And I am on the templates page
+ When I choose this template
+ And I follow "Builds"
+ Then I should see "Build imported template is not supported"
+
+ Scenario: Search for legacy_templates
+ Given there are these legacy_templates:
+ | name | platform | platform_version | architecture | summary
|
+ | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora
13 64 bit Description |
+ | Mock | fedora14 | 14 | i386 | Test Template Fedora
14 Description |
+ | Other | fedora14 | 10.04 | i386 | Test Template Ubuntu
10.04 32 bit Description |
+ And I am on the templates page
+ Then I should see the following:
+ | NAME | OS | VERSION | ARCH |
+ | Test1 | Fedora | 13 | x86_64 |
+ | Mock | Fedora | 14 | i386 |
+ | Other | Fedora | 10.04 | i386 |
+ When I fill in "q" with "test"
+ And I press "Search"
+ Then I should see "Test1"
+ And I should see "Mock"
+ And I should see "Other"
+ When I fill in "q" with "Mock"
+ And I press "Search"
+ Then I should see "Mock"
+ And I should not see "Test1"
+ And I should not see "Other"
+ When I fill in "q" with "13"
+ And I press "Search"
+ Then I should see "Test1"
+ And I should not see "Other"
+ And I should not see "Mock"
+ When I fill in "q" with "x86_64"
+ And I press "Search"
+ Then I should see "Test1"
+ And I should not see "Other"
+ And I should not see "Mock"
+ When I fill in "q" with "fedora"
+ And I press "Search"
+ Then I should see "Test1"
+ And I should see "Other"
+ And I should see "Mock"
+ When I fill in "q" with "32 bit Description"
+ And I press "Search"
+ Then I should not see "Test1"
+ And I should see "Other"
+ And I should not see "Mock"
+
+ Scenario: Delete multiple legacy_templates
+ Given there are these legacy_templates:
+ | name | platform | platform_version | architecture | summary
|
+ | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora
13 64 bit Description |
+ | Mock | fedora13 | 14 | i386 | Test Template Fedora
14 Description |
+ | Other | fedora13 | 10.04 | i386 | Test Template Ubuntu
10.04 32 bit Description |
+ And I am on the templates page
+ When I check "Test1" template
+ And I check "Mock" template
+ And I press "Delete"
+ Then I should be on the templates page
+ And I should see "Other"
+
+ Scenario: Create Assembly and Deployable
+ Given I am on the new template page
+ When I fill in the following:
+ | tpl_name | mocktemplate |
+ | tpl_platform | fedora13 |
+ | tpl_summary | mockdesc |
+ And I check "create_deployable"
+ And I press "Save"
+ Then I should be on the templates page
+ And I should see "mocktemplate"
+ When I go to the legacy_deployables page
+ And I should see "mocktemplate"
diff --git a/src/features/step_definitions/assembly_steps.rb
b/src/features/step_definitions/assembly_steps.rb
deleted file mode 100644
index 26fc4ce..0000000
--- a/src/features/step_definitions/assembly_steps.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-Given /^there is an assembly named "([^"]*)"$/ do |name|
- Assembly.create!(:name => name, :architecture => 'x86_64', :owner =>
user)
-end
-
-Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)"$/ do |assembly_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',
:legacy_deployable => Deployable.find_by_name(legacy_deployable))
-end
-
-Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)" template$/ do |assembly_name, template_name|
- template = Template.find_by_name(template_name)
- assembly = Assembly.find_by_name(assembly_name)
- unless assembly.nil?
- template.assemblies << assembly
- else
- template.assemblies.create!(:name => assembly_name, :architecture =>
'x86_64')
- end
-# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:legacy_deployable => Deployable.find_by_name(legacy_deployable))
-end
-
-When /^I check the "([^"]*)" assembly$/ do |name|
- assembly = Assembly.find_by_name(name)
- check("assembly_checkbox_#{assembly.id}")
-end
diff --git a/src/features/step_definitions/instance_steps.rb
b/src/features/step_definitions/instance_steps.rb
index ea2e7ec..5b0ac61 100644
--- a/src/features/step_definitions/instance_steps.rb
+++ b/src/features/step_definitions/instance_steps.rb
@@ -119,7 +119,7 @@ end
When /^I create mock instance$/ do
inst = Factory.build :mock_running_instance
- visit instances_url, :post, 'instance[name]' => inst.name,
'instance[template_id]' => inst.template_id
+ visit instances_url, :post, 'instance[name]' => inst.name,
'instance[legacy_template_id]' => inst.legacy_template_id
end
Then /^I should see mock instance in JSON format$/ do
diff --git a/src/features/step_definitions/legacy_assembly_steps.rb
b/src/features/step_definitions/legacy_assembly_steps.rb
new file mode 100644
index 0000000..b1d0f70
--- /dev/null
+++ b/src/features/step_definitions/legacy_assembly_steps.rb
@@ -0,0 +1,25 @@
+Given /^there is an assembly named "([^"]*)"$/ do |name|
+ LegacyAssembly.create!(:name => name, :architecture => 'x86_64', :owner
=> user)
+end
+
+Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)"$/ do |assembly_name, deployable_name|
+ deployable = LegacyDeployable.find_by_name(deployable_name)
+ deployable.legacy_assemblies.create!(:name => assembly_name, :architecture =>
'x86_64', :owner => user)
+# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:deployable => Deployable.find_by_name(deployable))
+end
+
+Given /^there is an assembly named "([^"]*)" belonging to
"([^"]*)" template$/ do |assembly_name, template_name|
+ template = LegacyTemplate.find_by_name(template_name)
+ assembly = LegacyAssembly.find_by_name(assembly_name)
+ unless assembly.nil?
+ template.legacy_assemblies << assembly
+ else
+ template.legacy_assemblies.create!(:name => assembly_name, :architecture =>
'x86_64')
+ end
+# Assembly.create!(:name => assembly, :architecture => 'x86_64',
:legacy_deployable => Deployable.find_by_name(legacy_deployable))
+end
+
+When /^I check the "([^"]*)" assembly$/ do |name|
+ assembly = LegacyAssembly.find_by_name(name)
+ check("assembly_checkbox_#{assembly.id}")
+end
diff --git a/src/features/step_definitions/legacy_deployable_steps.rb
b/src/features/step_definitions/legacy_deployable_steps.rb
index 545e15c..0bcb410 100644
--- a/src/features/step_definitions/legacy_deployable_steps.rb
+++ b/src/features/step_definitions/legacy_deployable_steps.rb
@@ -29,7 +29,7 @@ end
When /^I select default hardware profile for assemblies in "([^"]*)"$/ do
|arg1|
deployable = LegacyDeployable.find_by_name(arg1)
- deployable.assemblies.each do |a|
+ deployable.legacy_assemblies.each do |a|
select('mock_profile', :from => "hw_profiles_#{a.id}")
end
end
diff --git a/src/features/step_definitions/legacy_template_steps.rb
b/src/features/step_definitions/legacy_template_steps.rb
new file mode 100644
index 0000000..5a6b154
--- /dev/null
+++ b/src/features/step_definitions/legacy_template_steps.rb
@@ -0,0 +1,130 @@
+Given /^There is a mock pulp repository$/ do
+ dir = File.join(Rails.root, 'spec', 'fixtures')
+ hydra = Typhoeus::Hydra.hydra
+ hydra.stub(:get, "http://pulptest/repositories/").and_return(
+ Typhoeus::Response.new(:code => 200,
+ :body => File.read(File.join(dir,
'repositories.json'))))
+ hydra.stub(:get,
"http://pulptest/repositories/fedora/packagegroups/").and_return(
+ Typhoeus::Response.new(:code => 200,
+ :body => File.read(File.join(dir,
'packagegroups.json'))))
+ hydra.stub(:get,
"http://pulptest/repositories/fedora/packages/").and_return(
+ Typhoeus::Response.new(:code => 200,
+ :body => File.read(File.join(dir,
'packages.json'))))
+ hydra.stub(:get,
"http://pulptest/repositories/fedora/packagegroupcategories/").and_return(
+ Typhoeus::Response.new(:code => 200,
+ :body => File.read(File.join(dir,
'packagegroupcategories.json'))))
+ hydra.stub(:get,
"http://pulptest/repositories/fedora/packages/?name=libdeltacloud").and_return(
+ Typhoeus::Response.new(:code => 200,
+ :body => File.read(File.join(dir,
'packagesearch_libdeltacloud.json'))))
+end
+
+Given /^there is a "([^"]*)" template$/ do |name|
+ @template = Factory.build :legacy_template, :name => name
+ @template.save!
+end
+
+Given /^there is a package group$/ do
+ RepositoryManager.new.all_groups.should have_at_least(1).item
+end
+
+Given /^no package is selected$/ do
+ @template.packages = []
+end
+
+Given /^there is one selected package$/ do
+ pkg = RepositoryManager.new.all_packages.first
+ @template.packages = [pkg['name']]
+ @template.save!
+end
+
+# "I jump" is used instead of "I am" because "I am" is
already defined in
+# web_steps.rb and in this case I have to use @template as parameter which "I
+# am" doesn't support
+Given /^I jump on the "([^"]*)" template software page$/ do |name|
+ visit url_for(:action => 'software', :controller =>
'legacy_templates', :id => @template)
+end
+
+Given /^there are these legacy_templates:$/ do |table|
+ table.hashes.each do |hash|
+ @template = Factory.build(:legacy_template, :name => hash['name'],
+ :platform => hash['platform'])
+ @template.save!
+ @template.platform_version = hash['platform_version']
+ @template.architecture = hash['architecture']
+ @template.summary = hash['summary']
+ @template.save!
+ end
+end
+
+Then /^I should have a template named "([^"]*)"$/ do |name|
+ LegacyTemplate.first(:order => 'created_at DESC').xml.name.should eql(name)
+end
+
+Then /^the "([^"]*)" field by name should contain
"([^"]*)"$/ do |field, value|
+ field_value = field_named(field).value
+ if field_value.respond_to? :should
+ field_value.should =~ /#{value}/
+ else
+ assert_match(/#{value}/, field_value)
+ end
+end
+
+Then /^the page should contain "([^"]*)" selector$/ do |selector|
+ response.should have_selector(selector)
+end
+
+Then /^the page should not contain "([^"]*)" selector$/ do |selector|
+ response.should_not have_selector(selector)
+end
+
+Then /^I should see "([^"]*)" followed by "([^"]*)"$/ do
|arg1, arg2|
+ # webrat doesn't support checking order of elements on a page, so
+ # this seems to be siplest check
+ (response.body =~ /#{Regexp.escape(arg1)}.*#{Regexp.escape(arg2)}/m).should_not be_nil
+end
+
+Given /^there is a "([^"]*)" build$/ do |arg1|
+ @template = Factory.build :legacy_template, :name => arg1
+ @template.save!
+ image = Factory.build(:legacy_image, :legacy_template => @template)
+ image.save!
+end
+
+When /^I choose this template$/ do
+ click_link((a)template.name)
+end
+Given /^there is Amazon AWS provider account$/ do
+ account = Factory.build(:ec2_provider_account)
+ account.save!
+end
+
+Given /^there is Amazon AWS build and push for this template$/ do
+ image = Factory.create(:legacy_image, :legacy_template => @template, :status =>
LegacyImage::STATE_COMPLETED)
+ Factory.create(:ec2_provider_image, :legacy_image => image)
+end
+
+Given /^there is Amazon AWS build for this template$/ do
+ Factory.create(:legacy_image, :legacy_template => @template, :status =>
LegacyImage::STATE_COMPLETED)
+end
+
+Given /^there is Amazon AWS provider$/ do
+ Factory.create(:ec2_provider)
+end
+
+Given /^there is an imported template$/ do
+ @template = Factory.build :legacy_template, :name => name, :imported => true
+ @template.save!
+end
+
+Given /^has package "([^"]*)"$/ do |arg1|
+ @template.add_packages [arg1]
+end
+
+When /^I edit the template$/ do
+ visit edit_legacy_template_url(@template)
+end
+
+When /^(?:|I )check "([^"]*)" template$/ do |template_name|
+ template = LegacyTemplate.find_by_name(template_name)
+ check("selected_#{template.id}")
+end
diff --git a/src/features/step_definitions/template_steps.rb
b/src/features/step_definitions/template_steps.rb
deleted file mode 100644
index db07c6a..0000000
--- a/src/features/step_definitions/template_steps.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-Given /^There is a mock pulp repository$/ do
- dir = File.join(Rails.root, 'spec', 'fixtures')
- hydra = Typhoeus::Hydra.hydra
- hydra.stub(:get, "http://pulptest/repositories/").and_return(
- Typhoeus::Response.new(:code => 200,
- :body => File.read(File.join(dir,
'repositories.json'))))
- hydra.stub(:get,
"http://pulptest/repositories/fedora/packagegroups/").and_return(
- Typhoeus::Response.new(:code => 200,
- :body => File.read(File.join(dir,
'packagegroups.json'))))
- hydra.stub(:get,
"http://pulptest/repositories/fedora/packages/").and_return(
- Typhoeus::Response.new(:code => 200,
- :body => File.read(File.join(dir,
'packages.json'))))
- hydra.stub(:get,
"http://pulptest/repositories/fedora/packagegroupcategories/").and_return(
- Typhoeus::Response.new(:code => 200,
- :body => File.read(File.join(dir,
'packagegroupcategories.json'))))
- hydra.stub(:get,
"http://pulptest/repositories/fedora/packages/?name=libdeltacloud").and_return(
- Typhoeus::Response.new(:code => 200,
- :body => File.read(File.join(dir,
'packagesearch_libdeltacloud.json'))))
-end
-
-Given /^there is a "([^"]*)" template$/ do |name|
- @template = Factory.build :template, :name => name
- @template.save!
-end
-
-Given /^there is a package group$/ do
- RepositoryManager.new.all_groups.should have_at_least(1).item
-end
-
-Given /^no package is selected$/ do
- @template.packages = []
-end
-
-Given /^there is one selected package$/ do
- pkg = RepositoryManager.new.all_packages.first
- @template.packages = [pkg['name']]
- @template.save!
-end
-
-# "I jump" is used instead of "I am" because "I am" is
already defined in
-# web_steps.rb and in this case I have to use @template as parameter which "I
-# am" doesn't support
-Given /^I jump on the "([^"]*)" template software page$/ do |name|
- visit url_for(:action => 'software', :controller => 'templates',
:id => @template)
-end
-
-Given /^there are these templates:$/ do |table|
- table.hashes.each do |hash|
- @template = Factory.build(:template, :name => hash['name'],
- :platform => hash['platform'])
- @template.save!
- @template.platform_version = hash['platform_version']
- @template.architecture = hash['architecture']
- @template.summary = hash['summary']
- @template.save!
- end
-end
-
-Then /^I should have a template named "([^"]*)"$/ do |name|
- Template.first(:order => 'created_at DESC').xml.name.should eql(name)
-end
-
-Then /^the "([^"]*)" field by name should contain
"([^"]*)"$/ do |field, value|
- field_value = field_named(field).value
- if field_value.respond_to? :should
- field_value.should =~ /#{value}/
- else
- assert_match(/#{value}/, field_value)
- end
-end
-
-Then /^the page should contain "([^"]*)" selector$/ do |selector|
- response.should have_selector(selector)
-end
-
-Then /^the page should not contain "([^"]*)" selector$/ do |selector|
- response.should_not have_selector(selector)
-end
-
-Then /^I should see "([^"]*)" followed by "([^"]*)"$/ do
|arg1, arg2|
- # webrat doesn't support checking order of elements on a page, so
- # this seems to be siplest check
- (response.body =~ /#{Regexp.escape(arg1)}.*#{Regexp.escape(arg2)}/m).should_not be_nil
-end
-
-Given /^there is a "([^"]*)" build$/ do |arg1|
- @template = Factory.build :template, :name => arg1
- @template.save!
- image = Factory.build(:image, :template => @template)
- image.save!
-end
-
-When /^I choose this template$/ do
- click_link((a)template.name)
-end
-Given /^there is Amazon AWS provider account$/ do
- account = Factory.build(:ec2_provider_account)
- account.save!
-end
-
-Given /^there is Amazon AWS build and push for this template$/ do
- image = Factory.create(:image, :template => @template, :status =>
Image::STATE_COMPLETED)
- Factory.create(:ec2_provider_image, :image => image)
-end
-
-Given /^there is Amazon AWS build for this template$/ do
- Factory.create(:image, :template => @template, :status =>
Image::STATE_COMPLETED)
-end
-
-Given /^there is Amazon AWS provider$/ do
- Factory.create(:ec2_provider)
-end
-
-Given /^there is an imported template$/ do
- @template = Factory.build :template, :name => name, :imported => true
- @template.save!
-end
-
-Given /^has package "([^"]*)"$/ do |arg1|
- @template.add_packages [arg1]
-end
-
-When /^I edit the template$/ do
- visit edit_template_url(@template)
-end
-
-When /^(?:|I )check "([^"]*)" template$/ do |template_name|
- template = Template.find_by_name(template_name)
- check("selected_#{template.id}")
-end
diff --git a/src/features/support/custom.rb b/src/features/support/custom.rb
index 89a2006..08323f9 100644
--- a/src/features/support/custom.rb
+++ b/src/features/support/custom.rb
@@ -43,7 +43,7 @@ RepositoryManager.class_eval do
end
end
-Template.class_eval do
+LegacyTemplate.class_eval do
def upload
true
end
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index 7007fb8..d69ef13 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -78,22 +78,22 @@ module NavigationHelpers
url_for new_permission_path
when /the new template page/
- url_for new_template_path
+ url_for new_legacy_template_path
when /the new template build page/
url_for new_build_path
when /the template builds page/
- url_for template_path(@template, :details_tab => 'builds')
+ url_for legacy_template_path(@template, :details_tab => 'builds')
when /the pool family provider accounts page/
url_for pool_family_path(@pool_family, :details_tab =>
'provider_accounts')
when /the templates page/
- templates_path
+ legacy_templates_path
when /the create template page/
- url_for create_template_path
+ url_for create_legacy_template_path
when /the self service settings page/
url_for :action => 'self_service', :controller => 'settings',
:only_path => true
diff --git a/src/features/template.feature b/src/features/template.feature
deleted file mode 100644
index 4f41f61..0000000
--- a/src/features/template.feature
+++ /dev/null
@@ -1,228 +0,0 @@
-Feature: Manage Templates
- In order to manage my cloud infrastructure
- As a user
- I want to manage templates
-
- Background:
- Given I am an authorised user
- And I am logged in
- And There is a mock pulp repository
-
- Scenario: Create a new Template
- Given I am on the templates page
- When I follow "Create"
- Then I should be on the new template page
- When I fill in the following:
- | tpl_name | mocktemplate |
- | tpl_platform | fedora13 |
- | tpl_summary | mockdesc |
- When I press "Save"
- Then I should be on the templates page
- And I should see "Template saved"
- And I should see "mocktemplate"
-
- Scenario: Add a package to a new template
- Given I am on the new template page
- When I press "Add Software"
- When I press "admin-tools"
- Then I should see "System Tools"
- And I should see "libdeltacloud"
- When I check "libdeltacloud"
- And I press "Add Selected"
- Then I should see "New Template"
- And I should see "libdeltacloud"
-
- Scenario: Add a searched package to a new template
- Given I am on the new template page
- When I press "Add Software"
- And I fill in "package_search" with "libdeltacloud"
- And I press "package_search_button"
- Then I should see "libdeltacloud"
- When I check "libdeltacloud"
- And I press "Add Selected"
- Then I should see "New Template"
- And I should see "libdeltacloud"
-
- Scenario: Add group and remove package to/from the template
- Given I am on the templates page
- When I follow "Create"
- Then I should be on the new template page
- When I fill in the following:
- | tpl_name | mocktemplate |
- And I press "Add Software"
- Then I should see "Managed Content Selection"
- When I press "Collections"
- And I check "group_system-tools"
- And I press "Add Selected"
- Then I should see "Managed Content to Bundle"
- And the "tpl[name]" field by name should contain "mocktemplate"
- And the page should contain "#package_libdeltacloud" selector
- When I press "remove_package_libdeltacloud"
- Then I should see "Managed Content to Bundle"
- And the page should not contain "#package_libdeltacloud" selector
- When I press "Save"
- Then I should be on the templates page
- And I should see "Template saved"
- And I should see "mocktemplate"
-
- Scenario: Add group of packages to existing template
- Given there is a "mock1" template
- And has package "deltacloud-aggregator"
- When I edit the template
- And I press "Add Software"
- Then I should see "Managed Content Selection"
- When I press "Collections"
- And I check "group_system-tools"
- And I press "Add Selected"
- Then I should see "Managed Content to Bundle"
- And the page should contain "#package_libdeltacloud" selector
- When I press "Save"
- Then I should be on the templates page
- And I should see "Template updated"
- When I edit the template
- Then the page should contain "#package_libdeltacloud" selector
-
- Scenario: Sorting templates
- Given there is a "mock1" template
- And there is a "mock2" template
- And I am on the templates page
- When I follow "Name" within "#templates_table"
- Then I should see "mock1" followed by "mock2"
- When I follow "Name" within "#templates_table"
- Then I should see "mock2" followed by "mock1"
-
- Scenario: Sorting template builds
- Given there is a "mock1" build
- And there is a "mock2" build
- And I am on the template builds page
- When I follow "Name"
- Then I should see "mock1" followed by "mock2"
- When I follow "Name"
- Then I should see "mock2" followed by "mock1"
-
- Scenario: Search software with empty string
- Given I am on the new template page
- When I press "Add Software"
- And I fill in "package_search" with ""
- And I press "package_search_button"
- Then I should see "Search string is empty"
-
- Scenario: Show software selection
- Given I am on the new template page
- And I press "Add Software"
- Then I should see an input "Collections"
- # test that we see a metagroup
- Then I should see an input "admin-tools"
- # test that we see a collection (collections are loaded by default)
- And I should see an input "system-tools"
-
- Scenario: See upload status
- Given there is a "mock1" template
- And there is Amazon AWS build and push for this template
- And I am on the templates page
- When I choose this template
- And I follow "Builds"
- Then I should see "amazon-ec2: complete"
-
- Scenario: Build template
- Given there is a "mock1" template
- And there is Amazon AWS provider account
- And I am on the templates page
- When I choose this template
- 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 template page
- And I should see "mock1"
-
- Scenario: Upload image
- Given there is a "mock1" template
- And I am on the templates page
- And there is Amazon AWS build for this template
- And there is Amazon AWS provider
- And I am on the templates page
- When I choose this template
- And I follow "Builds"
- Then I should see "amazon-ec2: not uploaded upload"
- When I follow "upload"
- Then I should see "Builds"
- # TODO: fix status once uploaded field is replaced by status field
- And I should see "amazon-ec2: queued"
-
- Scenario: Build imported template
- Given there is an imported template
- And there is Amazon AWS provider account
- And I am on the templates page
- When I choose this template
- And I follow "Builds"
- Then I should see "Build imported template is not supported"
-
- Scenario: Search for templates
- Given there are these templates:
- | name | platform | platform_version | architecture | summary
|
- | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora
13 64 bit Description |
- | Mock | fedora14 | 14 | i386 | Test Template Fedora
14 Description |
- | Other | fedora14 | 10.04 | i386 | Test Template Ubuntu
10.04 32 bit Description |
- And I am on the templates page
- Then I should see the following:
- | NAME | OS | VERSION | ARCH |
- | Test1 | Fedora | 13 | x86_64 |
- | Mock | Fedora | 14 | i386 |
- | Other | Fedora | 10.04 | i386 |
- When I fill in "q" with "test"
- And I press "Search"
- Then I should see "Test1"
- And I should see "Mock"
- And I should see "Other"
- When I fill in "q" with "Mock"
- And I press "Search"
- Then I should see "Mock"
- And I should not see "Test1"
- And I should not see "Other"
- When I fill in "q" with "13"
- And I press "Search"
- Then I should see "Test1"
- And I should not see "Other"
- And I should not see "Mock"
- When I fill in "q" with "x86_64"
- And I press "Search"
- Then I should see "Test1"
- And I should not see "Other"
- And I should not see "Mock"
- When I fill in "q" with "fedora"
- And I press "Search"
- Then I should see "Test1"
- And I should see "Other"
- And I should see "Mock"
- When I fill in "q" with "32 bit Description"
- And I press "Search"
- Then I should not see "Test1"
- And I should see "Other"
- And I should not see "Mock"
-
- Scenario: Delete multiple templates
- Given there are these templates:
- | name | platform | platform_version | architecture | summary
|
- | Test1 | fedora13 | 13 | x86_64 | Test Template Fedora
13 64 bit Description |
- | Mock | fedora13 | 14 | i386 | Test Template Fedora
14 Description |
- | Other | fedora13 | 10.04 | i386 | Test Template Ubuntu
10.04 32 bit Description |
- And I am on the templates page
- When I check "Test1" template
- And I check "Mock" template
- And I press "Delete"
- Then I should be on the templates page
- And I should see "Other"
-
- Scenario: Create Assembly and Deployable
- Given I am on the new template page
- When I fill in the following:
- | tpl_name | mocktemplate |
- | tpl_platform | fedora13 |
- | tpl_summary | mockdesc |
- And I check "create_deployable"
- And I press "Save"
- Then I should be on the templates page
- And I should see "mocktemplate"
- When I go to the legacy_deployables page
- And I should see "mocktemplate"
diff --git a/src/lib/tasks/dc_tasks.rake b/src/lib/tasks/dc_tasks.rake
index ea775a9..9be5a5d 100644
--- a/src/lib/tasks/dc_tasks.rake
+++ b/src/lib/tasks/dc_tasks.rake
@@ -92,7 +92,7 @@ namespace :dc do
exit(1)
end
#account = get_account(args.provider, args.account)
- img = Image.single_import(args.provider, args.username, args.password, args.image,
User.find_by_login('admin'))
+ img = LegacyImage.single_import(args.provider, args.username, args.password,
args.image, User.find_by_login('admin'))
puts "Imported image with id '#{args.image}'"
end
@@ -103,7 +103,7 @@ namespace :dc do
exit(1)
end
list = YAML.load_file(args.yml_file)
- Image.bulk_import(args.provider, args.username, args.password, list,
User.find_by_login('admin'))
+ LegacyImage.bulk_import(args.provider, args.username, args.password, list,
User.find_by_login('admin'))
end
def get_account(provider_name, account_name)
diff --git a/src/lib/tasks/demo_data.rake b/src/lib/tasks/demo_data.rake
index f3326fd..8a58ede 100644
--- a/src/lib/tasks/demo_data.rake
+++ b/src/lib/tasks/demo_data.rake
@@ -47,7 +47,7 @@ namespace :db do
def create_instance(cloud_account)
instance = Instance.new({:name => "instance" + Time.now.to_s,
:hardware_profile_id => HardwareProfile.find(:first),
- :image_id => Image.find(:first),
+ :image_id => LegacyImage.find(:first),
:state => Instance::STATE_NEW,
:pool_id => 1,
:cloud_account_id => cloud_account.id
diff --git a/src/spec/controllers/builds_controller_spec.rb
b/src/spec/controllers/builds_controller_spec.rb
index 3d0debf..2c20be7 100644
--- a/src/spec/controllers/builds_controller_spec.rb
+++ b/src/spec/controllers/builds_controller_spec.rb
@@ -11,8 +11,8 @@ describe BuildsController do
it "update_status should change image status" do
UserSession.create(@tuser)
- @template = Factory.create(:template)
- @image = Factory.create(:image)
+ @template = Factory.create(:legacy_template)
+ @image = Factory.create(:legacy_image)
@request.env["HTTP_ACCEPT"] = "application/xml"
@image.status.should == "queued"
@@ -24,8 +24,8 @@ describe BuildsController do
it "update_status should change provider image status" do
UserSession.create(@tuser)
@provider = Factory.create(:mock_provider)
- @template = Factory.create(:template)
- @image = Factory.create(:image)
+ @template = Factory.create(:legacy_template)
+ @image = Factory.create(:legacy_image)
@provider_image = Factory.create(:mock_provider_image)
@request.env["HTTP_ACCEPT"] = "application/xml"
@@ -35,35 +35,35 @@ describe BuildsController do
response.should be_success
end
- context "when a user has permission to build templates" do
+ context "when a user has permission to build legacy_templates" do
#FIXME: The following functionality needs to come out of the controller
before(:each) do
UserSession.create(@admin)
- @template = Factory.create(:template)
+ @template = Factory.create(:legacy_template)
hydra = Typhoeus::Hydra.hydra
- hydra.stub(:put, %r{http://localhost:9090/templates/.*}).and_return(
+ hydra.stub(:put, %r{http://localhost:9090/legacy_templates/.*}).and_return(
Typhoeus::Response.new(:code => 200))
Factory.create(:mock_provider_account)
Factory.create(:mock_provider)
end
- it "should create a new Image" do
+ it "should create a new LegacyImage" do
lambda do
- post :create, :template_id => @template.id, :target =>
ProviderType.find_by_codename("mock").id
- end.should change(Image, :count).by(1)
+ post :create, :legacy_template_id => @template.id, :target =>
ProviderType.find_by_codename("mock").id
+ end.should change(LegacyImage, :count).by(1)
end
- it "retry build should update Image status" do
+ it "retry build should update LegacyImage status" do
lambda do
- post :create, :template_id => @template.id, :target =>
ProviderType.find_by_codename("mock").id
- end.should change(Image, :count).by(1)
- @template.images.size.should == 1
- image = @template.images[0]
+ post :create, :legacy_template_id => @template.id, :target =>
ProviderType.find_by_codename("mock").id
+ end.should change(LegacyImage, :count).by(1)
+ @template.legacy_images.size.should == 1
+ image = @template.legacy_images[0]
image.reload.status.should == "queued"
post :update_status, :uuid => image.uuid, :status => 'failed'
image.reload.status.should == "failed"
- post :retry, :image_id => image.id, :template_id => @template.id
+ post :retry, :legacy_image_id => image.id, :legacy_template_id =>
@template.id
image.reload.status.should == "queued"
end
diff --git a/src/spec/controllers/instance_controller_spec.rb
b/src/spec/controllers/instance_controller_spec.rb
index 9ef0548..4ad4406 100644
--- a/src/spec/controllers/instance_controller_spec.rb
+++ b/src/spec/controllers/instance_controller_spec.rb
@@ -11,7 +11,7 @@ describe InstancesController do
it "should provide ui to create new instance" do
UserSession.create(@admin)
get :new
- response.should redirect_to(select_template_instances_path)
+ response.should redirect_to(select_legacy_template_instances_path)
end
it "should fail to grant access to new pool ui for unauthenticated user" do
@@ -24,14 +24,14 @@ describe InstancesController do
@pool_user = @pool_user_permission.user
UserSession.create(@pool_user)
pool = Permission.first(:conditions => {:permission_object_type =>
'Pool', :user_id => @pool_user.id}).permission_object
- template = Factory.build(:template)
+ template = Factory.build(:legacy_template)
template.save!
hwp = Factory.build(:mock_hwp1)
hwp.save!
lambda do
post :create, :instance => { :name => 'mockinstance',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
end.should change(Instance, :count).by(1)
inst = Instance.find(:first, :conditions => ['name = ?',
'mockinstance'])
@@ -45,14 +45,14 @@ describe InstancesController do
@pool_user2 = @pool_user2_permission.user
UserSession.create(@pool_user)
pool = Permission.first(:conditions => {:permission_object_type =>
'Pool', :user_id => @pool_user.id}).permission_object
- template = Factory.build(:template)
+ template = Factory.build(:legacy_template)
template.save!
hwp = Factory.build(:mock_hwp1)
hwp.save!
lambda do
post :create, :instance => { :name => 'mockinstance',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
end.should change(Instance, :count).by(1)
inst = Instance.find_by_name('mockinstance')
@@ -72,11 +72,11 @@ describe InstancesController do
#instance.pool.enabled = false
UserSession.create(@admin)
pool = Factory(:pool, :enabled => false)
- template = Factory(:template)
+ template = Factory(:legacy_template)
hwp = Factory(:mock_hwp1)
post :create, :instance => { :name => 'mockinstance',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
response.flash[:warning].should == "Failed to launch instance: Pool is not
enabled"
end
@@ -84,11 +84,11 @@ describe InstancesController do
it "should respond to restful delete for a single instance" do
UserSession.create(@admin)
pool = Factory(:pool)
- template = Factory(:template)
+ template = Factory(:legacy_template)
hwp = Factory(:mock_hwp1)
post :create, :instance => { :name => 'mockinstance2',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
instance = Instance.find_by_name('mockinstance2')
# An instance in 'new' state is not destroyable, so we have to fake it:
@@ -102,18 +102,18 @@ describe InstancesController do
it "should respond to restful delete for multiple instances" do
UserSession.create(@admin)
pool = Factory(:pool)
- template = Factory(:template)
+ template = Factory(:legacy_template)
hwp = Factory(:mock_hwp1)
lambda do
post :create, :instance => { :name => 'mockinstance3',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
end.should change(Instance, :count).by(1)
lambda do
post :create, :instance => { :name => 'mockinstance4',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
end.should change(Instance, :count).by(1)
instance1 = Instance.find_by_name('mockinstance3')
@@ -130,12 +130,12 @@ describe InstancesController do
it "should not allow editing of protected attributes by users" do
UserSession.create(@admin)
pool = Factory(:pool)
- template = Factory(:template)
+ template = Factory(:legacy_template)
hwp = Factory(:mock_hwp1)
lambda do
post :create, :instance => { :name => 'mockinstance5',
:pool_id => pool.id,
- :template_id => template.id,
+ :legacy_template_id => template.id,
:hardware_profile_id => hwp.id }
end.should change(Instance, :count).by(1)
instance = Instance.find_by_name('mockinstance5')
diff --git a/src/spec/controllers/legacy_templates_controller_spec.rb
b/src/spec/controllers/legacy_templates_controller_spec.rb
new file mode 100644
index 0000000..fdf2dc5
--- /dev/null
+++ b/src/spec/controllers/legacy_templates_controller_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe LegacyTemplatesController do
+
+ fixtures :all
+ before(:each) do
+ @admin_permission = Factory :admin_permission
+ @admin = @admin_permission.user
+ @tuser = Factory :tuser
+ activate_authlogic
+ end
+
+ it "should deny access to new legacy_template ui without image modify
permission" do
+ UserSession.create(@tuser)
+ get :new
+ response.should_not render_template("new")
+ end
+end
diff --git a/src/spec/controllers/templates_controller_spec.rb
b/src/spec/controllers/templates_controller_spec.rb
deleted file mode 100644
index 1ace2cc..0000000
--- a/src/spec/controllers/templates_controller_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'spec_helper'
-
-describe TemplatesController do
-
- fixtures :all
- before(:each) do
- @admin_permission = Factory :admin_permission
- @admin = @admin_permission.user
- @tuser = Factory :tuser
- activate_authlogic
- end
-
- it "should deny access to new template ui without image modify permission"
do
- UserSession.create(@tuser)
- get :new
- response.should_not render_template("new")
- end
-end
diff --git a/src/spec/factories/assembly.rb b/src/spec/factories/assembly.rb
deleted file mode 100644
index dd55e0b..0000000
--- a/src/spec/factories/assembly.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-Factory.define :assembly do |a|
- a.sequence(:name) { |n| "assembly#{n}" }
- a.architecture 'x86_64'
- a.association :owner, :factory => :user
- a.templates { |t| [t.association(:template)] }
-end
diff --git a/src/spec/factories/build_job.rb b/src/spec/factories/build_job.rb
index b9faa9c..b614f5f 100644
--- a/src/spec/factories/build_job.rb
+++ b/src/spec/factories/build_job.rb
@@ -2,6 +2,6 @@ Factory.define :build_job do |p|
hydra = Typhoeus::Hydra.new
response = Typhoeus::Response.new(:code => 200, :headers => "", :body
=> "<?xml version=\"1.0\"
encoding=\"UTF-8\"><image><uuid>build-job-stub-uuid</uuid></image>",
:time => 0.1)
hydra.stub(:post,
YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['buildurl']).and_return(response)
- p.image_id { Factory.create(:image).id }
+ p.image_id { Factory.create(:legacy_image).id }
p.hydra hydra
end
diff --git a/src/spec/factories/image.rb b/src/spec/factories/image.rb
deleted file mode 100644
index e2bcd25..0000000
--- a/src/spec/factories/image.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# Should have an image factory, that specifies name, key and arch
-# pool_image, and provider_image factories should extend image factory.
-
-Factory.define :image do |i|
- i.sequence(:name) { |n| "image#{n}" }
- i.status 'queued'
- i.provider_type_id { ProviderType.find_by_codename("ec2").id }
- i.association(:template)
- i.after_build do |img|
- if img.respond_to?(:stub!)
- img.stub!(:build).and_return(true)
- img.stub!(:upload).and_return(true)
- end
- end
-end
diff --git a/src/spec/factories/instance.rb b/src/spec/factories/instance.rb
index 9c2ac54..8571355 100644
--- a/src/spec/factories/instance.rb
+++ b/src/spec/factories/instance.rb
@@ -3,7 +3,7 @@ Factory.define :instance do |i|
i.sequence(:external_key) { |n| "key#{n}" }
i.association :hardware_profile, :factory => :mock_hwp1
i.provider_account { Factory.build(:mock_provider_account) }
- i.association :template, :factory => :template
+ i.association :legacy_template, :factory => :legacy_template
i.association :pool, :factory => :pool
i.association :owner, :factory => :user
i.state "running"
diff --git a/src/spec/factories/legacy_assembly.rb
b/src/spec/factories/legacy_assembly.rb
new file mode 100644
index 0000000..6906036
--- /dev/null
+++ b/src/spec/factories/legacy_assembly.rb
@@ -0,0 +1,6 @@
+Factory.define :legacy_assembly do |a|
+ a.sequence(:name) { |n| "assembly#{n}" }
+ a.architecture 'x86_64'
+ a.association :owner, :factory => :user
+ a.legacy_templates { |t| [t.association(:legacy_template)] }
+end
diff --git a/src/spec/factories/legacy_deployable.rb
b/src/spec/factories/legacy_deployable.rb
index 40051f6..de73e81 100644
--- a/src/spec/factories/legacy_deployable.rb
+++ b/src/spec/factories/legacy_deployable.rb
@@ -1,5 +1,5 @@
Factory.define :legacy_deployable do |a|
a.sequence(:name) { |n| "deployable#{n}" }
- a.assemblies { |t| [t.association(:assembly)] }
+ a.legacy_assemblies { |t| [t.association(:legacy_assembly)] }
a.association :owner, :factory => :user
end
diff --git a/src/spec/factories/legacy_image.rb b/src/spec/factories/legacy_image.rb
new file mode 100644
index 0000000..eaa49a1
--- /dev/null
+++ b/src/spec/factories/legacy_image.rb
@@ -0,0 +1,15 @@
+# Should have an image factory, that specifies name, key and arch
+# pool_image, and provider_image factories should extend image factory.
+
+Factory.define :legacy_image do |i|
+ i.sequence(:name) { |n| "image#{n}" }
+ i.status 'queued'
+ i.provider_type_id { ProviderType.find_by_codename("ec2").id }
+ i.association(:legacy_template)
+ i.after_build do |img|
+ if img.respond_to?(:stub!)
+ img.stub!(:build).and_return(true)
+ img.stub!(:upload).and_return(true)
+ end
+ end
+end
diff --git a/src/spec/factories/legacy_provider_image.rb
b/src/spec/factories/legacy_provider_image.rb
index a00728c..d13be9d 100644
--- a/src/spec/factories/legacy_provider_image.rb
+++ b/src/spec/factories/legacy_provider_image.rb
@@ -1,5 +1,5 @@
Factory.define :legacy_provider_image do |ri|
- ri.association :image
+ ri.association :legacy_image
ri.association :provider
ri.sequence(:provider_image_key) { |n| "provider_image_key#(n)" }
ri.status "completed"
diff --git a/src/spec/factories/legacy_template.rb
b/src/spec/factories/legacy_template.rb
new file mode 100644
index 0000000..7371a37
--- /dev/null
+++ b/src/spec/factories/legacy_template.rb
@@ -0,0 +1,11 @@
+Factory.define :legacy_template do |i|
+ i.sequence(:name) { |n| "template#{n}" }
+ i.platform 'fedora13'
+ i.association :owner, :factory => :user
+ i.after_build do |tpl|
+ if tpl.respond_to?(:stub!)
+ tpl.stub!(:upload).and_return(true)
+ tpl.stub!(:delete_in_warehouse).and_return(true)
+ end
+ end
+end
diff --git a/src/spec/factories/template.rb b/src/spec/factories/template.rb
deleted file mode 100644
index 3c71acd..0000000
--- a/src/spec/factories/template.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-Factory.define :template do |i|
- i.sequence(:name) { |n| "template#{n}" }
- i.platform 'fedora13'
- i.association :owner, :factory => :user
- i.after_build do |tpl|
- if tpl.respond_to?(:stub!)
- tpl.stub!(:upload).and_return(true)
- tpl.stub!(:delete_in_warehouse).and_return(true)
- end
- end
-end
diff --git a/src/spec/models/assembly_spec.rb b/src/spec/models/assembly_spec.rb
deleted file mode 100644
index 2693116..0000000
--- a/src/spec/models/assembly_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'spec_helper'
-
-describe Assembly do
-
- it "should have automatically generated uuid after validation" do
- a = Factory.build(:assembly)
- a.uuid = nil
- a.save
- a.uuid.should_not be_nil
- end
-
- it "should not be valid if assembly name is too long" do
- a = Factory.build(:assembly)
- a.name = ('a' * 256)
- a.valid?.should be_false
- a.errors[:name].should_not be_nil
- a.errors[:name].should =~ /^is too long.*/
- end
-
- it "should have associated template" do
- a = Factory.build(:assembly)
- a.templates.size.should eql(1)
- end
-
-end
diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
index 4b1f3b4..4287a79 100644
--- a/src/spec/models/deployment_spec.rb
+++ b/src/spec/models/deployment_spec.rb
@@ -59,16 +59,16 @@ describe Deployment do
hwp = Factory(:mock_hwp1)
hwp_ids = {}
@deployment.save!
- @deployment.legacy_deployable.assemblies.each {|a| hwp_ids[a.id.to_s] = hwp.id}
+ @deployment.legacy_deployable.legacy_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.legacy_deployable.assemblies.count
+ @deployment.instances.count.should ==
@deployment.legacy_deployable.legacy_assemblies.count
end
- it "should not launch a deployment if deployable has not assemblies" do
+ it "should not launch a deployment if deployable has not legacy_assemblies"
do
@deployment.save!
- @deployment.legacy_deployable.assemblies = []
+ @deployment.legacy_deployable.legacy_assemblies = []
lambda {(a)deployment.launch}.should raise_exception
end
diff --git a/src/spec/models/image_spec.rb b/src/spec/models/image_spec.rb
deleted file mode 100644
index 6299aef..0000000
--- a/src/spec/models/image_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'spec_helper'
-
-describe Image do
- it "should have a name" do
- i = Factory.build(:image, :name => nil)
- i.should_not be_valid
-
- i.name = ''
- i.should_not be_valid
-
- i.name = "valid name"
- i.should be_valid
- end
-
- it "should not have a name that is too long" do
- i = Factory.build(:image)
- i.name = 'x' * 1025
- i.should_not be_valid
-
- i.name = 'x' * 1024
- i.should be_valid
- end
-
- it "should have automatically generated uuid after save" do
- i = Factory.build(:image)
- i.save
- i.uuid.should_not be_nil
- end
-
- it "should have template_id" do
- i = Factory.build(:image, :template_id => nil)
- i.should_not be_valid
-
- i.template_id = 1
- i.should be_valid
- end
-
- it "should not create and build image if image already exists for specified
target" do
- old = Factory(:image)
- lambda {Image.create_and_build!(old.template, old.provider_type)}.should
raise_error(ImageExistsError)
- end
-
- it "should build image if there is provider and cloud account for specified
target" do
- acc = Factory.build(:mock_provider_account)
- acc.stub!(:valid_credentials?).and_return(true)
- acc.save!
- tpl = Factory.build(:template)
- tpl.save!
- img = Image.create_and_build!(tpl, ProviderType.find_by_codename("mock"))
- Image.find(img).should == img
- end
-
- it "should import image" do
- image = OpenStruct.new(:id => 'mock', :name => 'mock',
:description => 'imported mock', :architecture => 'i386')
- client = mock('DeltaCloud', :feature? => false, :image => image)
- account = Factory.build(:ec2_provider_account)
- account.stub!(:connect).and_return(client)
- account.stub!(:valid_credentials?).and_return(true)
- account.save!
-
- # Stub the `upload` class method. This saves us from requining
- # Image Warehouse daemon to be running for the tests.
- ImageWarehouseObject.send(:define_method, :upload) { nil }
-
- lambda do
- lambda do
- lambda do
- img = Image.import(account, 'mock', Factory(:user))
- img.should_not be_nil
- img.template.uploaded.should be_true
- end.should change(Image, :count).by(1)
- end.should change(Template, :count).by(1)
- end.should change(LegacyProviderImage, :count).by(1)
- end
-end
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
index 8d279de..136e391 100644
--- a/src/spec/models/instance_spec.rb
+++ b/src/spec/models/instance_spec.rb
@@ -24,22 +24,22 @@ describe Instance do
@instance.should be_valid
end
- it "should require template to be set if there no deployment" do
- @instance.template_id = nil
+ it "should require legacy_template to be set if there no deployment" do
+ @instance.legacy_template_id = nil
@instance.deployment_id = nil
@instance.should_not be_valid
- @instance.template_id = 1
+ @instance.legacy_template_id = 1
@instance.should be_valid
end
- it "should not allow template to be set if there's a deployment" do
+ it "should not allow legacy_template to be set if there's a deployment"
do
@instance.deployment_id = 1
- @instance.template_id = 1
+ @instance.legacy_template_id = 1
@instance.should_not be_valid
- @instance.template_id = nil
- @instance.assembly_id = 1
+ @instance.legacy_template_id = nil
+ @instance.legacy_assembly_id = 1
@instance.should be_valid
end
diff --git a/src/spec/models/legacy_assembly_spec.rb
b/src/spec/models/legacy_assembly_spec.rb
new file mode 100644
index 0000000..b5a911c
--- /dev/null
+++ b/src/spec/models/legacy_assembly_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe LegacyAssembly do
+
+ it "should have automatically generated uuid after validation" do
+ a = Factory.build(:legacy_assembly)
+ a.uuid = nil
+ a.save
+ a.uuid.should_not be_nil
+ end
+
+ it "should not be valid if legacy_assembly name is too long" do
+ a = Factory.build(:legacy_assembly)
+ a.name = ('a' * 256)
+ a.valid?.should be_false
+ a.errors[:name].should_not be_nil
+ a.errors[:name].should =~ /^is too long.*/
+ end
+
+ it "should have associated legacy_template" do
+ a = Factory.build(:legacy_assembly)
+ a.legacy_templates.size.should eql(1)
+ end
+
+end
diff --git a/src/spec/models/legacy_deployable_spec.rb
b/src/spec/models/legacy_deployable_spec.rb
index 2a5be81..45dda19 100644
--- a/src/spec/models/legacy_deployable_spec.rb
+++ b/src/spec/models/legacy_deployable_spec.rb
@@ -19,15 +19,15 @@ describe LegacyDeployable do
it "should have associated assembly" do
d = Factory.build(:legacy_deployable)
- d.assemblies.size.should eql(1)
+ d.legacy_assemblies.size.should eql(1)
end
it "should not be destroyable when it has running instances" do
deployable = Factory.create(:legacy_deployable)
deployment = Factory.create(:deployment, :legacy_deployable_id => deployable.id)
- assembly = Factory.create(:assembly)
+ assembly = Factory.create(:legacy_assembly)
- instance = Factory.create(:instance, :deployment_id => deployment.id, :assembly_id
=> assembly.id, :template_id => nil)
+ instance = Factory.create(:instance, :deployment_id => deployment.id,
:legacy_assembly_id => assembly.id, :legacy_template_id => nil)
LegacyDeployable.find(deployable).should_not be_destroyable
instance.state = Instance::STATE_STOPPED
@@ -39,9 +39,9 @@ describe LegacyDeployable do
deployable = Factory.build(:legacy_deployable)
deployment = Factory.build(:deployment, :legacy_deployable_id => deployable.id)
deployable.deployments << deployment
- assembly = Factory.build(:assembly)
+ assembly = Factory.build(:legacy_assembly)
- instance = Factory.build(:instance, :deployment_id => deployment.id, :assembly_id
=> assembly.id, :template_id => nil)
+ instance = Factory.build(:instance, :deployment_id => deployment.id,
:legacy_assembly_id => assembly.id, :legacy_template_id => nil)
instance.stub!(:restartable?).and_return(true)
deployment.instances << instance
deployable.should_not be_destroyable
diff --git a/src/spec/models/legacy_image_spec.rb b/src/spec/models/legacy_image_spec.rb
new file mode 100644
index 0000000..4385b21
--- /dev/null
+++ b/src/spec/models/legacy_image_spec.rb
@@ -0,0 +1,75 @@
+require 'spec_helper'
+
+describe LegacyImage do
+ it "should have a name" do
+ i = Factory.build(:legacy_image, :name => nil)
+ i.should_not be_valid
+
+ i.name = ''
+ i.should_not be_valid
+
+ i.name = "valid name"
+ i.should be_valid
+ end
+
+ it "should not have a name that is too long" do
+ i = Factory.build(:legacy_image)
+ i.name = 'x' * 1025
+ i.should_not be_valid
+
+ i.name = 'x' * 1024
+ i.should be_valid
+ end
+
+ it "should have automatically generated uuid after save" do
+ i = Factory.build(:legacy_image)
+ i.save
+ i.uuid.should_not be_nil
+ end
+
+ it "should have legacy_template_id" do
+ i = Factory.build(:legacy_image, :legacy_template_id => nil)
+ i.should_not be_valid
+
+ i.legacy_template_id = 1
+ i.should be_valid
+ end
+
+ it "should not create and build image if image already exists for specified
target" do
+ old = Factory(:legacy_image)
+ lambda {LegacyImage.create_and_build!(old.legacy_template, old.provider_type)}.should
raise_error(ImageExistsError)
+ end
+
+ it "should build image if there is provider and cloud account for specified
target" do
+ acc = Factory.build(:mock_provider_account)
+ acc.stub!(:valid_credentials?).and_return(true)
+ acc.save!
+ tpl = Factory.build(:legacy_template)
+ tpl.save!
+ img = LegacyImage.create_and_build!(tpl,
ProviderType.find_by_codename("mock"))
+ LegacyImage.find(img).should == img
+ end
+
+ it "should import image" do
+ image = OpenStruct.new(:id => 'mock', :name => 'mock',
:description => 'imported mock', :architecture => 'i386')
+ client = mock('DeltaCloud', :feature? => false, :image => image)
+ account = Factory.build(:ec2_provider_account)
+ account.stub!(:connect).and_return(client)
+ account.stub!(:valid_credentials?).and_return(true)
+ account.save!
+
+ # Stub the `upload` class method. This saves us from requining
+ # Image Warehouse daemon to be running for the tests.
+ ImageWarehouseObject.send(:define_method, :upload) { nil }
+
+ lambda do
+ lambda do
+ lambda do
+ img = LegacyImage.import(account, 'mock', Factory(:user))
+ img.should_not be_nil
+ img.legacy_template.uploaded.should be_true
+ end.should change(LegacyImage, :count).by(1)
+ end.should change(LegacyTemplate, :count).by(1)
+ end.should change(LegacyProviderImage, :count).by(1)
+ end
+end
diff --git a/src/spec/models/legacy_provider_image_spec.rb
b/src/spec/models/legacy_provider_image_spec.rb
index d2a7f2f..331927c 100644
--- a/src/spec/models/legacy_provider_image_spec.rb
+++ b/src/spec/models/legacy_provider_image_spec.rb
@@ -11,7 +11,7 @@ describe LegacyProviderImage do
it "should have an image_id" do
i = Factory.build(:mock_provider_image)
i.should be_valid
- i.image = nil
+ i.legacy_image = nil
i.should_not be_valid
end
diff --git a/src/spec/models/legacy_template_spec.rb
b/src/spec/models/legacy_template_spec.rb
new file mode 100644
index 0000000..e1d9e57
--- /dev/null
+++ b/src/spec/models/legacy_template_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe LegacyTemplate do
+ it "should have automatically generated uuid after validation" do
+ t = Factory.build(:legacy_template)
+ t.uuid = nil
+ t.save
+ t.uuid.should_not be_nil
+ end
+
+ it "should return list of providers who provides images built from this
legacy_template" do
+ rimg = Factory.build(:mock_provider_image)
+ rimg.save!
+ rimg.legacy_image.legacy_template.providers.size.should eql(1)
+ end
+
+ it "should not be valid if legacy_template name is too long" do
+ t = Factory.build(:legacy_template)
+ t.name = ('a' * 256)
+ t.valid?.should be_false
+ t.errors[:name].should_not be_nil
+ t.errors[:name].should =~ /^is too long.*/
+ end
+
+ it "should not destroy legacy_template if there are instances created from this
legacy_template" do
+ inst = Factory.build(:instance)
+ inst.save!
+ lambda do
+ inst.legacy_template.destroy
+ end.should_not change(LegacyTemplate, :count)
+ end
+
+ it "should update xml when legacy_template is saved" do
+ tpl = Factory.build(:legacy_template)
+ tpl.packages = ['test']
+ tpl.save!
+ tpl2 = LegacyTemplate.find(tpl)
+ tpl2.packages.should == ['test']
+ end
+
+ it "should have warehouse url" do
+ t = Factory.build(:legacy_template)
+ t.uuid = "uuid"
+ t.warehouse_url.should ==
YAML.load_file("#{RAILS_ROOT}/config/image_warehouse.yml")['baseurl'] +
"/templates/" + t.uuid
+ end
+end
diff --git a/src/spec/models/template_spec.rb b/src/spec/models/template_spec.rb
deleted file mode 100644
index 21df655..0000000
--- a/src/spec/models/template_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'spec_helper'
-
-describe Template do
- it "should have automatically generated uuid after validation" do
- t = Factory.build(:template)
- t.uuid = nil
- t.save
- t.uuid.should_not be_nil
- end
-
- it "should return list of providers who provides images built from this
template" do
- rimg = Factory.build(:mock_provider_image)
- rimg.save!
- rimg.image.template.providers.size.should eql(1)
- end
-
- it "should not be valid if template name is too long" do
- t = Factory.build(:template)
- t.name = ('a' * 256)
- t.valid?.should be_false
- t.errors[:name].should_not be_nil
- t.errors[:name].should =~ /^is too long.*/
- end
-
- it "should not destroy template if there are instances created from this
template" do
- inst = Factory.build(:instance)
- inst.save!
- lambda do
- inst.template.destroy
- end.should_not change(Template, :count)
- end
-
- it "should update xml when template is saved" do
- tpl = Factory.build(:template)
- tpl.packages = ['test']
- tpl.save!
- tpl2 = Template.find(tpl)
- tpl2.packages.should == ['test']
- end
-
- it "should have warehouse url" do
- t = Factory.build(:template)
- t.uuid = "uuid"
- t.warehouse_url.should ==
YAML.load_file("#{RAILS_ROOT}/config/image_warehouse.yml")['baseurl'] +
"/templates/" + t.uuid
- end
-end
diff --git a/src/spec/services/registration_service_spec.rb
b/src/spec/services/registration_service_spec.rb
index ea38412..628b03b 100644
--- a/src/spec/services/registration_service_spec.rb
+++ b/src/spec/services/registration_service_spec.rb
@@ -33,8 +33,8 @@ describe RegistrationService do
@user.quota.maximum_running_instances.should == @quota.maximum_running_instances
@user.quota.maximum_total_instances.should == @quota.maximum_total_instances
-
BasePermissionObject.general_permission_scope.has_privilege(@user,Privilege::CREATE,
Template).should == true
- BasePermissionObject.general_permission_scope.has_privilege(@user,Privilege::USE,
Template).should == true
+
BasePermissionObject.general_permission_scope.has_privilege(@user,Privilege::CREATE,
LegacyTemplate).should == true
+ BasePermissionObject.general_permission_scope.has_privilege(@user,Privilege::USE,
LegacyTemplate).should == true
end
end
diff --git a/src/warehouse_sync/warehouse_sync.rb b/src/warehouse_sync/warehouse_sync.rb
index adcbb5e..4eb8529 100644
--- a/src/warehouse_sync/warehouse_sync.rb
+++ b/src/warehouse_sync/warehouse_sync.rb
@@ -19,15 +19,15 @@ class WarehouseSync
while true
begin
@logger.info "***** Runnning warehouse sync"
- # TODO: I disabled template sync - templates should never
+ # TODO: I disabled template sync - legacy_templates should never
# be changed by anything else than conductor
- #(a)logger.info "*** syncing templates"
+ #(a)logger.info "*** syncing legacy_templates"
#Template.all.each do |i|
# i.safe_warehouse_sync
# i.save! if i.changed?
#end
@logger.info "*** syncing images"
- Image.all.each do |i|
+ LegacyImage.all.each do |i|
i.safe_warehouse_sync
if i.changed?
i.save! rescue @logger.error "failed to save image #{i.uuid}:
#{$!.message}"
--
1.7.4.4