[PATCH conductor 3/3] BZ 768089: Add model and UI for provider account priority
Scott Seago
sseago at redhat.com
Tue Dec 20 18:13:17 UTC 2011
Added intger property to provider accounts for 'priority'. Priority is added as the default order for the provider_accounts association on Pool Families (environments). This way, when returning a list of provider accounts that match an instance, the highest priority account is returned first.
---
src/app/controllers/pool_families_controller.rb | 1 +
src/app/helpers/provider_accounts_helper.rb | 1 +
src/app/models/pool_family.rb | 2 +-
.../pool_families/_provider_accounts.html.haml | 1 +
src/app/views/provider_accounts/_list.html.haml | 1 +
.../views/provider_accounts/_properties.html.haml | 5 ++++
.../provider_accounts/_provider_form.html.haml | 3 ++
src/config/locales/en.yml | 1 +
...20111215180000_add_provider_account_priority.rb | 25 ++++++++++++++++++++
9 files changed, 39 insertions(+), 1 deletions(-)
create mode 100644 src/db/migrate/20111215180000_add_provider_account_priority.rb
diff --git a/src/app/controllers/pool_families_controller.rb b/src/app/controllers/pool_families_controller.rb
index 93dce2e..cde17c7 100644
--- a/src/app/controllers/pool_families_controller.rb
+++ b/src/app/controllers/pool_families_controller.rb
@@ -197,6 +197,7 @@ class PoolFamiliesController < ApplicationController
{ :name => t("provider_accounts.index.username"), :sortable => false},
{ :name => t("provider_accounts.index.provider_name"), :sortable => false },
{ :name => t("provider_accounts.index.provider_type"), :sortable => false },
+ { :name => t("provider_accounts.index.priority"), :sortable => false, :class => 'center' },
{ :name => t("quota_used"), :sortable => false, :class => 'center' },
{ :name => t("provider_accounts.index.quota_limit"), :sortable => false, :class => 'center' }
]
diff --git a/src/app/helpers/provider_accounts_helper.rb b/src/app/helpers/provider_accounts_helper.rb
index 8660496..dc00f96 100644
--- a/src/app/helpers/provider_accounts_helper.rb
+++ b/src/app/helpers/provider_accounts_helper.rb
@@ -22,6 +22,7 @@ module ProviderAccountsHelper
{ :name => t("provider_accounts.index.username"), :sortable => false},
{ :name => t("provider_accounts.index.provider_name"), :sortable => false },
{ :name => t("provider_accounts.index.provider_type"), :sortable => false },
+ { :name => t("provider_accounts.index.priority"), :sortable => false, :class => 'center' },
{ :name => t("quota_used"), :sortable => false, :class => 'center' },
{ :name => t("provider_accounts.index.quota_limit"), :sortable => false, :class => 'center' }
]
diff --git a/src/app/models/pool_family.rb b/src/app/models/pool_family.rb
index 0d645d3..1598640 100644
--- a/src/app/models/pool_family.rb
+++ b/src/app/models/pool_family.rb
@@ -38,7 +38,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, :uniq => true
+ has_and_belongs_to_many :provider_accounts, :uniq => true, :order => "provider_accounts.priority asc"
has_many :permissions, :as => :permission_object, :dependent => :destroy
validates_length_of :name, :maximum => 255
diff --git a/src/app/views/pool_families/_provider_accounts.html.haml b/src/app/views/pool_families/_provider_accounts.html.haml
index 58695cb..effa330 100644
--- a/src/app/views/pool_families/_provider_accounts.html.haml
+++ b/src/app/views/pool_families/_provider_accounts.html.haml
@@ -13,5 +13,6 @@
%td= account.credentials_hash['username']
%td= account.provider.name
%td= account.provider.provider_type.name
+ %td= account.priority
%td{:class => 'center'}= number_to_percentage account.quota.percentage_used, :precision => 0
%td{:class => 'center'}= account.quota.maximum_running_instances or 'unlimited'
diff --git a/src/app/views/provider_accounts/_list.html.haml b/src/app/views/provider_accounts/_list.html.haml
index 182ed06..2430a04 100644
--- a/src/app/views/provider_accounts/_list.html.haml
+++ b/src/app/views/provider_accounts/_list.html.haml
@@ -32,5 +32,6 @@
%td= account.credentials_hash['username']
%td= account.provider.name
%td= account.provider.provider_type.name
+ %td= account.priority
%td{:class => 'center'}= number_to_percentage account.quota.percentage_used, :precision => 0
%td{:class => 'center'}= account.quota.maximum_running_instances or 'unlimited'
diff --git a/src/app/views/provider_accounts/_properties.html.haml b/src/app/views/provider_accounts/_properties.html.haml
index f54f69d..e8ed168 100644
--- a/src/app/views/provider_accounts/_properties.html.haml
+++ b/src/app/views/provider_accounts/_properties.html.haml
@@ -11,6 +11,11 @@
%label=t'provider_accounts.properties.running_instances_quota'
%td
= @provider_account.quota.maximum_running_instances or t('unlimited')
+ %tr
+ %td
+ %label=t'provider_accounts.index.priority'
+ %td
+ = @provider_account.priority
- if @account_id
%tr
%td
diff --git a/src/app/views/provider_accounts/_provider_form.html.haml b/src/app/views/provider_accounts/_provider_form.html.haml
index b5c0545..1553c5f 100644
--- a/src/app/views/provider_accounts/_provider_form.html.haml
+++ b/src/app/views/provider_accounts/_provider_form.html.haml
@@ -17,6 +17,9 @@
%fieldset
%p
+ = label :provider_account, t('provider_accounts.index.priority')
+ = text_field :provider_account, :priority, :class => 'em'
+ %p
= label_tag t("quotas.quota")
= text_field :quota, :maximum_running_instances, :title => t('provider_accounts.form.quota_instances'), :value => @quota.maximum_running_instances || t('provider_accounts.properties.unlimited'), :id => "quota_instances"
(
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index c1526a0..e50c21f 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -943,6 +943,7 @@ en:
provider_name: Provider Name
provider_type: Provider Type
quota_limit: Quota Limit
+ priority: Priority
config_server_saved: "Config Server data was successfully saved"
config_server_not_saved: "An error occurred while saving the Config Server data."
preset_filters:
diff --git a/src/db/migrate/20111215180000_add_provider_account_priority.rb b/src/db/migrate/20111215180000_add_provider_account_priority.rb
new file mode 100644
index 0000000..c544636
--- /dev/null
+++ b/src/db/migrate/20111215180000_add_provider_account_priority.rb
@@ -0,0 +1,25 @@
+#
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class AddProviderAccountPriority < ActiveRecord::Migration
+ def self.up
+ add_column :provider_accounts, :priority, :integer
+ end
+
+ def self.down
+ remove_column :provider_accounts, :priority
+ end
+end
--
1.7.6.4
More information about the aeolus-devel
mailing list