[email protected] wrote: > From: martyntaylor <[email protected]> > > --- > src/app/controllers/cloud_accounts_controller.rb | 7 +++ > src/app/controllers/pool_controller.rb | 7 +++ > src/app/services/registration_service.rb | 7 +++ > src/app/views/quota/new.html.erb | 21 --------- > src/app/views/quota/show.html.erb | 53 > +++++----------------- > 5 files changed, 32 insertions(+), 63 deletions(-) > delete mode 100644 src/app/views/quota/new.html.erb > > diff --git a/src/app/controllers/cloud_accounts_controller.rb > b/src/app/controllers/cloud_accounts_controller.rb > index 29be676..96eb9af 100644 > --- a/src/app/controllers/cloud_accounts_controller.rb > +++ b/src/app/controllers/cloud_accounts_controller.rb > @@ -32,6 +32,13 @@ class CloudAccountsController < ApplicationController > @provider = Provider.find(params[:cloud_account][:provider_id]) > require_privilege(Privilege::ACCOUNT_MODIFY,@provider) > @cloud_account = CloudAccount.new(params[:cloud_account]) > + > + quota = Quota.new > + quota.save! > + > + @cloud_account.quota_id = quota.id > + @cloud_account.save! > + > if request.post? && @cloud_account.save && > @cloud_account.populate_realms_and_images > flash[:notice] = "Provider account added." > redirect_to :controller => "provider", :action => "accounts", :id => > @provider > diff --git a/src/app/controllers/pool_controller.rb > b/src/app/controllers/pool_controller.rb > index de3bd3e..e687c0b 100644 > --- a/src/app/controllers/pool_controller.rb > +++ b/src/app/controllers/pool_controller.rb > @@ -75,6 +75,13 @@ class PoolController < ApplicationController > perm.save! > # FIXME: do we need any more handling around save failures? What if perm > # creation fails? > + > + quota = Quota.new > + quota.save! > + > + @pool.quota_id = quota.id > + @pool.save! > + > flash[:notice] = "Pool added." > redirect_to :action => 'show', :id => @pool.id > end > diff --git a/src/app/services/registration_service.rb > b/src/app/services/registration_service.rb > index b2de097..2083803 100644 > --- a/src/app/services/registration_service.rb > +++ b/src/app/services/registration_service.rb > @@ -10,6 +10,13 @@ class RegistrationService > User.transaction do > @user.save! > @pool = Pool.create!({ :name => @user.login, :owner => @user}) > + > + @quota = Quota.new > + @quota.save! > + > + @pool.quota_id = @quota.id > + @pool.save! > + > Permission.create!({:user => @user, > :role => Role.find_by_name("Instance Creator and > User"), > :permission_object => @pool}) > diff --git a/src/app/views/quota/new.html.erb > b/src/app/views/quota/new.html.erb > deleted file mode 100644 > index 1f99bd9..0000000 > --- a/src/app/views/quota/new.html.erb > +++ /dev/null > @@ -1,21 +0,0 @@ > -<div class="dcloud_form"> > - <%= error_messages_for @parent_type %> > - <%= error_messages_for 'quota' %> > - > - <h2>Create Quota for <%= @parent_type + ": " + @name%></legend></h2><br /> > - > - <% form_tag :action => 'create' do -%> > - <%=hidden_field_tag 'id', @parent.id %> > - <%=hidden_field_tag 'parent_type', @parent_type %> > - > - <ul> > - <li><label>Max Running Instances</label><%= text_field :quota, > :maximum_running_instances %></li> > - <li><label>Max Running Memory</label><%= text_field :quota, > :maximum_running_memory %></li> > - <li><label>Max Running CPUs</label><%= text_field :quota, > :maximum_running_cpus %></li> > - <li><label>Max Total Instances</label><%= text_field :quota, > :maximum_total_instances %></li> > - <li><label>Max Total Storage</label><%= text_field :quota, > :maximum_total_storage %></li> > - </ul> > - </fieldset> > - <%= submit_tag "Save", :class => "submit" %> > - <% end %> > -</div> > \ No newline at end of file > diff --git a/src/app/views/quota/show.html.erb > b/src/app/views/quota/show.html.erb > index 03a4fc5..136f65a 100644 > --- a/src/app/views/quota/show.html.erb > +++ b/src/app/views/quota/show.html.erb > @@ -1,58 +1,27 @@ > <% if !...@quota %> > <h1>There is no Quota on this <%= @parent_type %></h1> > -<%= link_to "Create Quota", {:action => "new", :id => @parent, :parent_type > => @parent_type}, :class=>"actionlink"%> > <% else %> > <table> > <thead> > <tr> > <th scope="col">Resource</th> > <th scope="col">Max Capacity</th> > - <th scope="col">Used Capacity</th> > - <th scope="col">Free Capacity</th> > - <th scope="col">% Used</th> > + <th scope="col">Used</th> > + <th scope="col">Available</th> > </tr> > </thead> > <tbody> > + <% quota_resources = @quota.quota_resources > + quota_resources.each_value do |quota_resource| %> > <tr> > - <td>Running Instances</td> > - <td><%= sprintf("%.1f", @quota.maximum_running_instances) %></td> > - <td><%= sprintf("%.1f", @quota.running_instances) %></td> > - <td><%= sprintf("%.1f", @quota.maximum_running_instances - > @quota.running_instances) %></td> > - <td><%= percentage = (100.to_f / > @quota.maximum_running_instances) * @quota.running_instances > - sprintf("%.2f", percentage) %></td> > - </tr> > - <tr> > - <td>Running Memory / MB</td> > - <td><%= sprintf("%.1f", @quota.maximum_running_memory.to_f) %></td> > - <td><%= sprintf("%.1f", @quota.running_memory.to_f) %></td> > - <td><%= sprintf("%.1f", @quota.maximum_running_memory.to_f - > @quota.running_memory.to_f) %></td> > - <td><%= percentage = (100.to_f / > @quota.maximum_running_memory.to_f) * @quota.running_memory.to_f > - sprintf("%.2f", percentage) %></td> > - <td></td> > - </tr> > - <tr> > - <td>Running CPUs</td> > - <td><%= sprintf("%.1f", @quota.maximum_running_cpus) %></td> > - <td><%= sprintf("%.1f", @quota.running_cpus) %></td> > - <td><%= sprintf("%.1f",@quota.maximum_running_cpus.to_f - > @quota.running_cpus.to_f) %></td> > - <td><%= sprintf("%.2f", (100.to_f / > @quota.maximum_running_cpus.to_f) * @quota.running_cpus.to_f) %></td> > - </tr> > - <tr> > - <td>Total Instances</td> > - <td><%= sprintf("%.1f", @quota.maximum_total_instances) %></td> > - <td><%= sprintf("%.1f", @quota.total_instances) %></td> > - <td><%= sprintf("%.1f", @quota.maximum_total_instances - > @quota.total_instances) %></td> > - <td><%= sprintf("%.2f", (100.to_f / > @quota.maximum_total_instances) * @quota.total_instances) %></td> > - </tr> > - <tr> > - <td>Total Storage / GB</td> > - <td><%= sprintf("%.1f", @quota.maximum_total_storage.to_f) %></td> > - <td><%= sprintf("%.1f", @quota.total_storage.to_f) %></td> > - <td><%= sprintf("%.1f", @quota.maximum_total_storage.to_f - > @quota.total_storage.to_f) %></td> > - <td><%= sprintf("%.2f", (100.to_f / > @quota.maximum_total_storage.to_f) * @quota.total_storage.to_f) %></td> > - </tr> > + <td><%= quota_resource.name + " " + quota_resource.unit%></td> > + <td><%= quota_resource.max %></td> > + <td><%= quota_resource.used %></td> > + <td><%= quota_resource.available %></td> > + </tr> > + <% end %> > </tbody> > </table> > <%= link_to "Edit", {:action => "edit", :id => @parent, :parent_type => > @parent_type}, :class=>"actionlink"%> > - <%= link_to "Delete", {:action => "delete", :id => @parent, :parent_type > => @parent_type}, :class=>"actionlink"%> > + <%= link_to "Reset", {:action => "reset", :id => @parent, :parent_type => > @parent_type}, :class=>"actionlink"%> > <% end %> > \ No newline at end of file > ACK,
This all works as expected. Scott _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
