Make provider page have a table, and try to make new instance form fail less horribly. Now at least it brings you back to a (blank) for for the correct pool so you can start over, but not showing any errors. Surely I am overlooking something silly, but at least there wont be a stack trace if you mess up on that form now.
Signed-off-by: Jason Guiditta jason.guiditta@gmail.com --- src/app/controllers/instance_controller.rb | 31 +++++++++++++++++++--------- src/app/views/layouts/dcloud.rhtml | 8 +++++- src/app/views/portal_pool/show.html.erb | 8 ++++++- src/app/views/provider/show.html.erb | 17 +++++++++++++- 4 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/src/app/controllers/instance_controller.rb b/src/app/controllers/instance_controller.rb index 42b1cb8..c6cbc7f 100644 --- a/src/app/controllers/instance_controller.rb +++ b/src/app/controllers/instance_controller.rb @@ -2,6 +2,10 @@ class InstanceController < ApplicationController def index end
+ # Right now this is essentially a duplicate of PortalPoolController#show, + # but really it should be a single instance should we decide to have a page + # for that. Redirect on create was all that brought you here anyway, so + # should be unused for the moment. def show @instances = Instance.find(:all, :conditions => {:portal_pool_id => params[:id]}) @pool = PortalPool.find(params[:id]) @@ -9,11 +13,7 @@ class InstanceController < ApplicationController end
def new - @flavors = Flavor.find(:all, :conditions => {:provider_id => params[:provider]}) - @images = Image.find(:all, :conditions => {:provider_id => params[:provider]}) - @realms = Realm.find(:all, :conditions => {:provider_id => params[:provider]}) - @instance = Instance.new({:portal_pool_id => params[:id]}) - @provider_id = params[:provider] + _new(params[:provider],params[:id]) end
def create @@ -25,15 +25,16 @@ class InstanceController < ApplicationController @task = InstanceTask.new({:user => @instance.portal_pool.cloud_account.username, :task_target => @instance, :action => InstanceTask::ACTION_CREATE}) - if @task.save! + if @task.save flash[:notice] = "Instance added." - redirect_to :action => 'show', :id => @instance.portal_pool_id, :provider => params[:provider_id] + redirect_to :controller => "portal_pool", :action => 'show', :id => @instance.portal_pool_id else - render :action => 'new', :id => [:instance][:portal_pool_id] + _new(params[:provider_id],params[:instance][:portal_pool_id]) + render :action => 'new' end else - puts "Instance did not save: " + @instance.inspect - render :action => 'new', :id => @instance.portal_pool_id, :provider => params[:provider_id] + _new(params[:provider_id],params[:instance][:portal_pool_id]) + render :action => 'new' end end
@@ -57,4 +58,14 @@ class InstanceController < ApplicationController def delete end
+ private + + def _new(provider, pool) + @flavors = Flavor.find(:all, :conditions => {:provider_id => provider}) + @images = Image.find(:all, :conditions => {:provider_id => provider}) + @realms = Realm.find(:all, :conditions => {:provider_id => provider}) + @instance = Instance.new({:portal_pool_id => pool}) + @provider_id = provider + end + end diff --git a/src/app/views/layouts/dcloud.rhtml b/src/app/views/layouts/dcloud.rhtml index 4c2f103..dde8018 100644 --- a/src/app/views/layouts/dcloud.rhtml +++ b/src/app/views/layouts/dcloud.rhtml @@ -71,10 +71,14 @@ <%#= render :partial => '/layouts/tree' %> <ul id="providers"> <% @providers.each { |provider| %> - <li><%= link_to provider.name, {:controller => "provider", :action => "show", :id => provider}, :class => "providername"%> + <li><%= link_to provider.name, + {:controller => "provider", :action => "show", :id => provider}, + :class => "providername"%> <% provider.portal_pools.each { |pool| %> <ul id="portal_pool-<%=provider.id%>"> - <li><%= link_to pool.name, {:controller => "portal_pool", :action => "show", :id => pool}, :class => "poolname" %></li> + <li><%= link_to pool.name, + {:controller => "portal_pool", :action => "show", :id => pool}, + :class => "poolname" %></li> </ul> <% } %> </li> diff --git a/src/app/views/portal_pool/show.html.erb b/src/app/views/portal_pool/show.html.erb index 2a550d8..88d8e3f 100644 --- a/src/app/views/portal_pool/show.html.erb +++ b/src/app/views/portal_pool/show.html.erb @@ -6,6 +6,9 @@ <tr> <th scope="col">Actions</th> <th scope="col">Name</th> + <th scope="col">State</th> + <th scope="col">Flavor</th> + <th scope="col">Image</th> </tr> </thead> <tbody> @@ -20,7 +23,10 @@ <br/> <% } %> </td> - <td><div><%= instance.name %></div></td> + <td><%= instance.name %></td> + <td><%= instance.state %></td> + <td><%= instance.flavor.name %></td> + <td><%= instance.image.name %></td> </tr> <% } %> </tbody> diff --git a/src/app/views/provider/show.html.erb b/src/app/views/provider/show.html.erb index 07e0d4d..bfeacdb 100644 --- a/src/app/views/provider/show.html.erb +++ b/src/app/views/provider/show.html.erb @@ -1,9 +1,22 @@ <% if @provider.portal_pools.size == 0 %> <h1>There are no pools to display</h1> <% else %> + <table> + <thead> + <tr> + <th scope="col">Name</th> + <th scope="col">Instances</th> + </tr> + </thead> + <tbody> <%@provider.portal_pools.each {|pool| %> - <%= pool.name %><br/> - <% } %> + <tr> + <td><%= pool.name %></td> + <td><%= pool.instances.count %></td> + </tr> + <% } %> + </tbody> + </table> <% end %> <%= link_to "Add a pool", :controller => "portal_pool", :action => "new", :provider => @provider%> <% form_tag :action => 'destroy' do %>
deltacloud-devel@lists.fedorahosted.org