[PATCH conductor 12/22] Migration and model related changes for ProviderSelectionStrategy

ifarkas at redhat.com ifarkas at redhat.com
Thu Aug 2 12:25:03 UTC 2012


From: Imre Farkas <ifarkas at redhat.com>

---
 src/app/models/pool.rb                             |  1 +
 src/app/models/provider_selection_strategy.rb      | 25 ++++++++++++++++
 ...6084533_create_provider_selection_strategies.rb | 33 ++++++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 src/app/models/provider_selection_strategy.rb
 create mode 100644 src/db/migrate/20120726084533_create_provider_selection_strategies.rb

diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 23d31c6..18ba564 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -66,6 +66,7 @@ class Pool < ActiveRecord::Base
 
   has_many :deployments, :dependent => :destroy
 
+  has_many :provider_selection_strategies, :dependent => :destroy
   has_many :provider_priority_groups, :dependent => :destroy
 
   before_destroy :destroyable?
diff --git a/src/app/models/provider_selection_strategy.rb b/src/app/models/provider_selection_strategy.rb
new file mode 100644
index 0000000..8a35631
--- /dev/null
+++ b/src/app/models/provider_selection_strategy.rb
@@ -0,0 +1,25 @@
+#
+#   Copyright 2012 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 ProviderSelectionStrategy < ActiveRecord::Base
+
+  serialize :config
+
+  belongs_to :pool
+
+  scope :enabled, :conditions => { :enabled => true }
+
+end
\ No newline at end of file
diff --git a/src/db/migrate/20120726084533_create_provider_selection_strategies.rb b/src/db/migrate/20120726084533_create_provider_selection_strategies.rb
new file mode 100644
index 0000000..92f4c13
--- /dev/null
+++ b/src/db/migrate/20120726084533_create_provider_selection_strategies.rb
@@ -0,0 +1,33 @@
+#
+#   Copyright 2012 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 CreateProviderSelectionStrategies < ActiveRecord::Migration
+  def self.up
+    create_table :provider_selection_strategies do |t|
+      t.string :name, :null => false
+      t.boolean :enabled, :null => false
+      t.text :config
+
+      t.references :pool
+
+      t.timestamps
+    end
+  end
+
+  def self.down
+    drop_table :provider_selection_strategies
+  end
+end
-- 
1.7.11.2




More information about the aeolus-devel mailing list