This patchset associates quota with pool family. To be fully functional, condor plugin has to be updated to check pool family when starting instance.
From: Jan Provaznik jprovazn@redhat.com
--- src/app/models/pool_family.rb | 1 + src/app/models/quota.rb | 1 + .../20110417180833_add_pool_family_quota.rb | 15 +++++++++++++++ src/db/seeds.rb | 2 +- src/spec/factories/pool_family.rb | 1 + 5 files changed, 19 insertions(+), 1 deletions(-) create mode 100644 src/db/migrate/20110417180833_add_pool_family_quota.rb
diff --git a/src/app/models/pool_family.rb b/src/app/models/pool_family.rb index 2eee939..d7241a3 100644 --- a/src/app/models/pool_family.rb +++ b/src/app/models/pool_family.rb @@ -42,6 +42,7 @@ class PoolFamily < ActiveRecord::Base end
has_many :pools, :dependent => :destroy + belongs_to :quota, :dependent => :destroy has_and_belongs_to_many :provider_accounts
validates_length_of :name, :maximum => 255 diff --git a/src/app/models/quota.rb b/src/app/models/quota.rb index 7d67088..b33560c 100644 --- a/src/app/models/quota.rb +++ b/src/app/models/quota.rb @@ -37,6 +37,7 @@ class Quota < ActiveRecord::Base
has_one :pool + has_one :pool_family has_one :provider_account has_one :user
diff --git a/src/db/migrate/20110417180833_add_pool_family_quota.rb b/src/db/migrate/20110417180833_add_pool_family_quota.rb new file mode 100644 index 0000000..e95b4a5 --- /dev/null +++ b/src/db/migrate/20110417180833_add_pool_family_quota.rb @@ -0,0 +1,15 @@ +class AddPoolFamilyQuota < ActiveRecord::Migration + def self.up + add_column :pool_families, :quota_id, :integer + PoolFamily.all.each do |pf| + unless pf.quota + pf.quota = Quota.new + pf.save! + end + end + end + + def self.down + remove_column :pool_families, :quota_id + end +end diff --git a/src/db/seeds.rb b/src/db/seeds.rb index 69be3f4..7ef7c37 100644 --- a/src/db/seeds.rb +++ b/src/db/seeds.rb @@ -1,5 +1,5 @@ # Default Pool Family -PoolFamily.create!(:name => "default", :description => "default pool family") +PoolFamily.create!(:name => "default", :description => "default pool family", :quota => Quota.create)
# Default Pool Pool.create!(:name => "default_pool", :quota => Quota.create, :pool_family => PoolFamily.find_by_name('default')) diff --git a/src/spec/factories/pool_family.rb b/src/spec/factories/pool_family.rb index d0ca8e7..1d9f0a0 100644 --- a/src/spec/factories/pool_family.rb +++ b/src/spec/factories/pool_family.rb @@ -1,4 +1,5 @@ Factory.define :pool_family do |z| z.sequence(:name) { |n| "pool_family#{n}" } z.description 'pool family' + z.association :quota end
From: Jan Provaznik jprovazn@redhat.com
Updated new/edit forms to enable setting of quota --- .../controllers/admin/pool_families_controller.rb | 3 ++- src/app/models/pool_family.rb | 1 + src/app/views/admin/pool_families/_form.haml | 6 ++++++ src/app/views/admin/pool_families/_list.haml | 2 +- src/features/pool_family.feature | 1 + 5 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/admin/pool_families_controller.rb b/src/app/controllers/admin/pool_families_controller.rb index af53aac..9f53113 100644 --- a/src/app/controllers/admin/pool_families_controller.rb +++ b/src/app/controllers/admin/pool_families_controller.rb @@ -17,7 +17,7 @@ class Admin::PoolFamiliesController < ApplicationController end
def new - @pool_family = PoolFamily.new + @pool_family = PoolFamily.new(:quota => Quota.new) end
def create @@ -34,6 +34,7 @@ class Admin::PoolFamiliesController < ApplicationController
def edit @pool_family = PoolFamily.find(params[:id]) + @pool_family.quota ||= Quota.new end
def update diff --git a/src/app/models/pool_family.rb b/src/app/models/pool_family.rb index d7241a3..36f68a7 100644 --- a/src/app/models/pool_family.rb +++ b/src/app/models/pool_family.rb @@ -43,6 +43,7 @@ class PoolFamily < ActiveRecord::Base
has_many :pools, :dependent => :destroy belongs_to :quota, :dependent => :destroy + accepts_nested_attributes_for :quota has_and_belongs_to_many :provider_accounts
validates_length_of :name, :maximum => 255 diff --git a/src/app/views/admin/pool_families/_form.haml b/src/app/views/admin/pool_families/_form.haml index 093e41d..e493931 100644 --- a/src/app/views/admin/pool_families/_form.haml +++ b/src/app/views/admin/pool_families/_form.haml @@ -1,6 +1,12 @@ += error_messages_for :pool_family = form.error_message_on :name, 'Name ' %fieldset.clear = form.label :name,'Pool Family Name :' = form.text_field :name, :title => 'pool_family_name', :value => @pool_family.name, :class => "clear grid_4 alpha" %fieldset.clear + - form.fields_for :quota do |quota_form| + %fieldset.clear + = quota_form.label :maximum_running_instances, t(:maximum_running_instances), :class => "alpha grid_3" + = quota_form.text_field :maximum_running_instances +%fieldset.clear = form.submit "Save", :class => "submit formbutton" diff --git a/src/app/views/admin/pool_families/_list.haml b/src/app/views/admin/pool_families/_list.haml index a824676..aef3e33 100644 --- a/src/app/views/admin/pool_families/_list.haml +++ b/src/app/views/admin/pool_families/_list.haml @@ -19,4 +19,4 @@ = link_to pool_family.name, admin_pool_family_path(pool_family) %td %td - xx % + = "#{pool_family.quota.percentage_used} %" diff --git a/src/features/pool_family.feature b/src/features/pool_family.feature index 6795d42..9dc97ea 100644 --- a/src/features/pool_family.feature +++ b/src/features/pool_family.feature @@ -32,6 +32,7 @@ Feature: Pool Families When I follow "Create" Then I should be on the new admin pool family page When I fill in "pool_family[name]" with "testpoolfamily" + When I fill in "pool_family[quota_attributes][maximum_running_instances]" with "2" And I press "Save" Then I should be on the admin pool families page And I should see "Pool family was added."
Dne 18.4.2011 17:37, jprovazn@redhat.com napsal(a):
From: Jan Provaznikjprovazn@redhat.com
Updated new/edit forms to enable setting of quota
.../controllers/admin/pool_families_controller.rb | 3 ++- src/app/models/pool_family.rb | 1 + src/app/views/admin/pool_families/_form.haml | 6 ++++++ src/app/views/admin/pool_families/_list.haml | 2 +- src/features/pool_family.feature | 1 + 5 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/admin/pool_families_controller.rb b/src/app/controllers/admin/pool_families_controller.rb index af53aac..9f53113 100644 --- a/src/app/controllers/admin/pool_families_controller.rb +++ b/src/app/controllers/admin/pool_families_controller.rb @@ -17,7 +17,7 @@ class Admin::PoolFamiliesController< ApplicationController end
def new
- @pool_family = PoolFamily.new
@pool_family = PoolFamily.new(:quota => Quota.new) end
def create
@@ -34,6 +34,7 @@ class Admin::PoolFamiliesController< ApplicationController
def edit @pool_family = PoolFamily.find(params[:id])
@pool_family.quota ||= Quota.new end
def update
diff --git a/src/app/models/pool_family.rb b/src/app/models/pool_family.rb index d7241a3..36f68a7 100644 --- a/src/app/models/pool_family.rb +++ b/src/app/models/pool_family.rb @@ -43,6 +43,7 @@ class PoolFamily< ActiveRecord::Base
has_many :pools, :dependent => :destroy belongs_to :quota, :dependent => :destroy
accepts_nested_attributes_for :quota has_and_belongs_to_many :provider_accounts
validates_length_of :name, :maximum => 255
diff --git a/src/app/views/admin/pool_families/_form.haml b/src/app/views/admin/pool_families/_form.haml index 093e41d..e493931 100644 --- a/src/app/views/admin/pool_families/_form.haml +++ b/src/app/views/admin/pool_families/_form.haml @@ -1,6 +1,12 @@ += error_messages_for :pool_family = form.error_message_on :name, 'Name ' %fieldset.clear = form.label :name,'Pool Family Name :' = form.text_field :name, :title => 'pool_family_name', :value => @pool_family.name, :class => "clear grid_4 alpha" %fieldset.clear
- form.fields_for :quota do |quota_form|
- %fieldset.clear
= quota_form.label :maximum_running_instances, t(:maximum_running_instances), :class => "alpha grid_3"
= quota_form.text_field :maximum_running_instances
+%fieldset.clear = form.submit "Save", :class => "submit formbutton" diff --git a/src/app/views/admin/pool_families/_list.haml b/src/app/views/admin/pool_families/_list.haml index a824676..aef3e33 100644 --- a/src/app/views/admin/pool_families/_list.haml +++ b/src/app/views/admin/pool_families/_list.haml @@ -19,4 +19,4 @@ = link_to pool_family.name, admin_pool_family_path(pool_family) %td
= pool_family.quota.maximum_running_instances or 'unlimited'
%td
xx %
= "#{pool_family.quota.percentage_used} %"
diff --git a/src/features/pool_family.feature b/src/features/pool_family.feature index 6795d42..9dc97ea 100644 --- a/src/features/pool_family.feature +++ b/src/features/pool_family.feature @@ -32,6 +32,7 @@ Feature: Pool Families When I follow "Create" Then I should be on the new admin pool family page When I fill in "pool_family[name]" with "testpoolfamily"
- When I fill in "pool_family[quota_attributes][maximum_running_instances]" with "2" And I press "Save" Then I should be on the admin pool families page And I should see "Pool family was added."
Pool Families list should display maximum_running_instances value in column QUOTA LIMIT. Othervise all tests passed. ACK.
aeolus-devel@lists.fedorahosted.org