From: Jan Provaznik <[email protected]>
---
src/app/controllers/image_controller.rb | 8 ++++-
.../image_descriptor_target_controller.rb | 8 ------
src/app/controllers/instance_controller.rb | 13 +++++++--
src/app/controllers/templates_controller.rb | 27 +++++++++++++------
src/app/views/image/_images.haml | 7 +---
src/app/views/instance/_instances.haml | 2 +-
src/app/views/instance/new.haml | 6 ++--
src/app/views/templates/_targets.haml | 14 +++++-----
src/app/views/templates/software.haml | 2 +-
9 files changed, 48 insertions(+), 39 deletions(-)
delete mode 100644 src/app/controllers/image_descriptor_target_controller.rb
diff --git a/src/app/controllers/image_controller.rb
b/src/app/controllers/image_controller.rb
index b75f692..e399225 100644
--- a/src/app/controllers/image_controller.rb
+++ b/src/app/controllers/image_controller.rb
@@ -25,6 +25,11 @@ class ImageController < ApplicationController
def index
end
+ def cancel
+ Image.update(params[:id], :status => Image::STATE_CANCELED)
+ redirect_to :controller => 'templates', :action => 'new', :params =>
{'image_descriptor[id]' => params[:template_id], :tab => 'software'}
+ end
+
def show
if params[:create_instance]
redirect_to :controller => 'instance', :action => 'new',
'instance[image_id]' => (params[:ids] || []).first
@@ -37,8 +42,7 @@ class ImageController < ApplicationController
@images = Image.search_filter(params[:search],
Image::SEARCHABLE_COLUMNS).paginate(
:page => params[:page] || 1,
:order => @order + ' ' + @order_dir,
- :include => :instances,
- :conditions => {:provider_id => nil}
+ :include => :instances
)
if request.xhr? and params[:partial]
diff --git a/src/app/controllers/image_descriptor_target_controller.rb
b/src/app/controllers/image_descriptor_target_controller.rb
deleted file mode 100644
index 6f01018..0000000
--- a/src/app/controllers/image_descriptor_target_controller.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class ImageDescriptorTargetController < ApplicationController
- before_filter :require_user
-
- def cancel
- ImageDescriptorTarget.update(params[:id], :status =>
ImageDescriptorTarget::STATE_CANCELED)
- redirect_to :controller => 'templates', :action => 'new', :params =>
{'image_descriptor[id]' => params[:descriptor_id], :tab => 'software'}
- end
-end
diff --git a/src/app/controllers/instance_controller.rb
b/src/app/controllers/instance_controller.rb
index e94eea9..44a6f6e 100644
--- a/src/app/controllers/instance_controller.rb
+++ b/src/app/controllers/instance_controller.rb
@@ -56,10 +56,17 @@ class InstanceController < ApplicationController
require_privilege(Privilege::IMAGE_VIEW)
@order_dir = params[:order_dir] == 'desc' ? 'desc' : 'asc'
@order = params[:order] || 'name'
- @images = Image.search_filter(params[:search],
Image::SEARCHABLE_COLUMNS).paginate(
+ #...@images = Image.search_filter(params[:search],
Image::SEARCHABLE_COLUMNS).paginate(
+ # :page => params[:page] || 1,
+ # :order => @order + ' ' + @order_dir,
+ # :conditions => {:status => Image::STATE_COMPLETE}
+ #)
+ # FIXME: this is temmp, add pagination and searching
+ @images = ImageProvider.paginate(
:page => params[:page] || 1,
- :order => @order + ' ' + @order_dir,
- :conditions => {:provider_id => nil}
+ #:order => @order + ' ' + @order_dir,
+ :include => [:image, :provider]
+ #:conditions => ['image.status = ?', Image::STATE_COMPLETE]
)
@single_select = true
diff --git a/src/app/controllers/templates_controller.rb
b/src/app/controllers/templates_controller.rb
index 975d46d..f7b010c 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -26,7 +26,7 @@ class TemplatesController < ApplicationController
def software
@repository_manager = RepositoryManager.new
- @image_descriptor = params[:id] ? ImageDescriptor.find(params[:id]) :
ImageDescriptor.new
+ @image_descriptor = params[:id] ? Template.find(params[:id]) : Template.new
@groups = @repository_manager.all_groups(params[:repository])
if params[:tab].to_s == 'packages'
@selected_tab = 'packages'
@@ -45,33 +45,42 @@ class TemplatesController < ApplicationController
if params[:back]
redirect_to :action => 'services', :id => @image_descriptor
elsif params[:next]
+ # template is complete, upload it
+ @image_descriptor.upload_template
+ @image_descriptor.update_attribute(:complete, true)
redirect_to :action => 'summary', :id => @image_descriptor
end
end
def summary
update_xml
- @all_targets = ImageDescriptorTarget.available_targets
+ @all_targets = Image.available_targets
if params[:build]
if params[:targets]
params[:targets].each do |target|
- ImageDescriptorTarget.new_if_not_exists(:name => target,
:image_descriptor_id => params[:id], :status =>
ImageDescriptorTarget::STATE_QUEUED)
+ Image.new_if_not_exists(
+ # FIXME - this is temp uuid generation
+ # template version id not supported for now
+ :uuid => "#{params[:id]}-#{target}",
+ :name => "#...@image_descriptor.xml.name}/#{target}",
+ :target => target,
+ :template_id => params[:id],
+ :status => Image::STATE_QUEUED
+ )
end
end
else
if params[:back]
redirect_to :action => 'software', :id => @image_descriptor
elsif params[:done]
- @image_descriptor.complete = true
- @image_descriptor.save!
redirect_to :controller => 'dashboard', :action => 'index'
end
end
end
def targets
- @image_descriptor = ImageDescriptor.find(params[:id])
- @all_targets = ImageDescriptorTarget.available_targets
+ @image_descriptor = Template.find(params[:id])
+ @all_targets = Image.available_targets
end
def select_group
@@ -101,7 +110,7 @@ class TemplatesController < ApplicationController
end
def update_group_or_package(method, *args)
- @image_descriptor = params[:id] ? ImageDescriptor.find(params[:id]) :
ImageDescriptor.new
+ @image_descriptor = params[:id] ? Template.find(params[:id]) : Template.new
@image_descriptor.xml.send(method, *args)
@image_descriptor.save_xml!
if request.xhr?
@@ -112,7 +121,7 @@ class TemplatesController < ApplicationController
end
def update_xml
- @image_descriptor = params[:id] ? ImageDescriptor.find(params[:id]) :
ImageDescriptor.new
+ @image_descriptor = params[:id] ? Template.find(params[:id]) : Template.new
@image_descriptor.update_xml_attributes!(params[:xml] || {})
end
diff --git a/src/app/views/image/_images.haml b/src/app/views/image/_images.haml
index 4dfeaa0..d37f1d3 100644
--- a/src/app/views/image/_images.haml
+++ b/src/app/views/image/_images.haml
@@ -1,8 +1,6 @@
- columns = [ |
{:id => 'id', :header => ''}, |
{:id => 'name', :header => 'Name', :sortable => true}, |
- {:id => 'architecture', :header => 'Architecture', :sortable => true}, |
- {:id => 'instances', :header => 'Instances'}, |
] |
- opts = { :order => @order,
@@ -16,6 +14,5 @@
= paginated_table('images_table', columns, @images, opts) do |rec|
%tr{:class => "#{cycle('even', 'odd')}"}
%td= check_box_tag 'ids[]', rec.id
- %td{:class => 'image_name'}= rec.name
- %td= rec.architecture
- %td= rec.instances.count
+ %td{:class => 'image_name'}= rec.image.name
+ /%td= rec.instances.count
diff --git a/src/app/views/instance/_instances.haml
b/src/app/views/instance/_instances.haml
index 391bdba..f268ba5 100644
--- a/src/app/views/instance/_instances.haml
+++ b/src/app/views/instance/_instances.haml
@@ -19,6 +19,6 @@
%td= rec.get_action_list.map {|action| link_to action, :controller =>
"instance", :action => "instance_action", :id => rec, :instance_action =>
action}.join(" | ")
%td= rec.name
%td Details
- %td= rec.image.name
+ %td= rec.image_provider.image.name
%td= rec.state
%td= rec.time_last_running
diff --git a/src/app/views/instance/new.haml b/src/app/views/instance/new.haml
index d797d57..164bd17 100644
--- a/src/app/views/instance/new.haml
+++ b/src/app/views/instance/new.haml
@@ -17,7 +17,7 @@
if (id !== undefined) {
var name = $(".image_name", checkbox.parent().parent()).text();
$(".select_image").text(name);
- $("input[name='instance[image_id]']").val(id);
+ $("input[name='instance[image_provider_id]']").val(id);
}
$("#select_template_dialog").dialog('close');
return false;
@@ -45,8 +45,8 @@
%label
Template
%span Choose a template to use
- = link_to(@instance.image ? @instance.image.name : "Select
template...", {:action => 'select_image'}, {:class => 'actionlink
select_image'})
- %input{:name => "instance[image_id]", :type => "hidden", :value =>
@instance.image ? @instance.image.id : ''}/
+ = link_to(@instance.image_provider ?
@instance.image_provider.image.name : "Select template...", {:action =>
'select_image'}, {:class => 'actionlink select_image'})
+ %input{:name => "instance[image_provider_id]", :type => "hidden", :value
=> @instance.image_provider ? @instance.image_provider.id : ''}/
- if @instance.pool
%input{:name => "instance[pool_id]", :type => "hidden", :value =>
@instance.pool_id}/
- if (@pools.size > 1)
diff --git a/src/app/views/templates/_targets.haml
b/src/app/views/templates/_targets.haml
index 1b242e1..ba8f7f1 100644
--- a/src/app/views/templates/_targets.haml
+++ b/src/app/views/templates/_targets.haml
@@ -1,18 +1,18 @@
#image_target_list{:class => 'target_list'}
- - if @image_descriptor.image_descriptor_targets.empty?
+ - if @image_descriptor.images.empty?
.empty No images have been created yet.
-else
%ul
- - @image_descriptor.image_descriptor_targets.each do |target|
+ - @image_descriptor.images.each do |image|
%li
%span{:class => 'actions'}
- - if ImageDescriptorTarget::ACTIVE_STATES.include?(target.status)
- = link_to 'Cancel', {:controller => 'image_descriptor_target',
:action => 'cancel', :id => target, :descriptor_id => @image_descriptor}
+ - if Image::ACTIVE_STATES.include?(image.status)
+ = link_to 'Cancel', {:controller => 'image', :action =>
'cancel', :id => image, :template_id => @image_descriptor}
%span{:class => 'status'}
- = target.status
- = @all_targets[target.name]['name']
+ = image.status
+ = @all_targets[image.target]['name']
%p
- = target.created_at
+ = image.created_at
//%span{:style => 'float:right'}
// Cancel
diff --git a/src/app/views/templates/software.haml
b/src/app/views/templates/software.haml
index 998ce9b..9d11b5e 100644
--- a/src/app/views/templates/software.haml
+++ b/src/app/views/templates/software.haml
@@ -82,7 +82,7 @@
%li{ :class => "#{selection_style} ui-state-default
ui-corner-top", :style => 'clear: none' }
= "<a href=\"#{url_for(:action => "software", :id =>
@image_descriptor, :tab => item[:tab])}\"><span>#{item[:text]}</span></a>"
%li{ :class => "select_repository"}
- = select_tag("repository", ["<option value='all'
selected='selected'>All</option>"] +
@repository_manager.repositories.map{|repid, rep| "<option
value=\"#{repid}\">#{rep['name']}</option>"}, {:onchange =>
"get_repository(event)"})
+ = select_tag("repository", ["<option value='all'
selected='selected'>All</option>"] + @repository_manager.repositories.map{|rep|
"<option value=\"#{rep.id}\">#{rep.name}</option>"}, {:onchange =>
"get_repository(event)"})
- unless request.xhr?
= render :partial => @selected_tab
.pkglist{:style => "margin-left: 30px", :class => "left-pkglist"}
--
1.7.2.2
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel