This is part of an overall redesign of the codebase. The most significant change is that a pool is now made up of one or more "back end" (or provider) accounts. Initially a user will have to pick a back end account (via the selection of a realm), but ultimately provider account selection will be optional, and the scheduler will automatically choose a back end account for each instance. In addition resources such as images or hardware profiles will be mapped from front end to back end clouds so that pool-specific images and hardware profiles chosen by the user will be mapped to the appropriate resources for whichever back-end cloud account ultimately receives the 'new instance' request.
1) the full hardware profile model is not included -- this is roughly the old flavor model renamed to 'hardware profile' 2) images and hardware profiles do not reflect the ability to map back-end images and profiles of multiple architectures to a single front end image or profile.
Signed-off-by: Scott Seago sseago@redhat.com --- src/app/models/cloud_account.rb | 8 +-- src/app/models/flavor.rb | 39 ---------- src/app/models/hardware_profile.rb | 51 +++++++++++++ src/app/models/image.rb | 5 +- src/app/models/instance.rb | 10 +++- src/app/models/permission.rb | 2 +- src/app/models/{user.rb => pool_account.rb} | 11 ++- src/app/models/portal_pool.rb | 75 ++++++++++--------- src/app/models/provider.rb | 21 +++--- src/app/models/{user.rb => quota.rb} | 5 +- src/app/models/user.rb | 3 + ...al_pools.rb => 20090802000000_create_quotas.rb} | 17 +++-- .../migrate/20090803141507_create_portal_pools.rb | 6 ++- ... => 20090804135630_create_hardware_profiles.rb} | 13 +++- src/db/migrate/20090804140143_create_images.rb | 3 +- src/db/migrate/20090804142049_create_instances.rb | 5 +- ...s.rb => 20091215182906_create_pool_accounts.rb} | 9 ++- src/test/fixtures/cloud_accounts.yml | 4 + src/test/fixtures/hardware_profiles.yml | 77 ++++++++++++++++++++ src/test/fixtures/images.yml | 10 +++ src/test/fixtures/instances.yml | 13 ++++ src/test/fixtures/permissions.yml | 8 ++ src/test/fixtures/pool_accounts.yml | 10 +++ src/test/fixtures/portal_pools.yml | 4 + src/test/fixtures/providers.yml | 4 + src/test/fixtures/{flavors.yml => quotas.yml} | 2 + src/test/fixtures/realms.yml | 8 ++ src/test/fixtures/users.yml | 8 ++ .../{flavor_test.rb => hardware_profile_test.rb} | 0 .../unit/{flavor_test.rb => pool_account_test.rb} | 2 +- src/test/unit/{flavor_test.rb => quota_test.rb} | 2 +- 31 files changed, 316 insertions(+), 119 deletions(-) delete mode 100644 src/app/models/flavor.rb create mode 100644 src/app/models/hardware_profile.rb copy src/app/models/{user.rb => pool_account.rb} (80%) copy src/app/models/{user.rb => quota.rb} (92%) copy src/db/migrate/{20090803141507_create_portal_pools.rb => 20090802000000_create_quotas.rb} (72%) rename src/db/migrate/{20090804135630_create_flavors.rb => 20090804135630_create_hardware_profiles.rb} (78%) copy src/db/migrate/{20090803141507_create_portal_pools.rb => 20091215182906_create_pool_accounts.rb} (84%) create mode 100644 src/test/fixtures/hardware_profiles.yml create mode 100644 src/test/fixtures/pool_accounts.yml rename src/test/fixtures/{flavors.yml => quotas.yml} (75%) copy src/test/unit/{flavor_test.rb => hardware_profile_test.rb} (100%) copy src/test/unit/{flavor_test.rb => pool_account_test.rb} (69%) rename src/test/unit/{flavor_test.rb => quota_test.rb} (71%)
diff --git a/src/app/models/cloud_account.rb b/src/app/models/cloud_account.rb index afb4623..a753e6e 100644 --- a/src/app/models/cloud_account.rb +++ b/src/app/models/cloud_account.rb @@ -21,14 +21,12 @@
class CloudAccount < ActiveRecord::Base belongs_to :provider - has_many :portal_pools, :dependent => :destroy + has_many :pool_accounts, :dependent => :destroy + has_many :portal_pools, :through => :pool_accounts + has_many :instances
# what form does the account quota take?
- # we aren't yet defining the local user object - # has_many :portal_users - - validates_presence_of :provider_id
validates_presence_of :username diff --git a/src/app/models/flavor.rb b/src/app/models/flavor.rb deleted file mode 100644 index e518fd3..0000000 --- a/src/app/models/flavor.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class Flavor < ActiveRecord::Base - has_many :instances - belongs_to :provider - - validates_presence_of :provider_id - - validates_presence_of :external_key - validates_uniqueness_of :external_key, :scope => :provider_id - - validates_presence_of :name - - validates_presence_of :storage - validates_numericality_of :storage - validates_presence_of :memory - validates_numericality_of :memory - - validates_presence_of :architecture -end diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb new file mode 100644 index 0000000..65fa12f --- /dev/null +++ b/src/app/models/hardware_profile.rb @@ -0,0 +1,51 @@ +# +# Copyright (C) 2009 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. A copy of the GNU General Public License is +# also available at http://www.gnu.org/copyleft/gpl.html. + +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +class HardwareProfile < ActiveRecord::Base + has_many :instances + has_many :provider_instances, :class_name => "Instance", + :foreign_key => "provider_hardware_profile_id" + belongs_to :provider + + has_and_belongs_to_many :master_hardware_profiles, + :class_name => "HardwareProfile", + :join_table => "hardware_profile_map", + :foreign_key => "provider_hardware_profile_id", + :association_foreign_key => "master_hardware_profile_id" + + has_and_belongs_to_many :provider_hardware_profiles, + :class_name => "HardwareProfile", + :join_table => "hardware_profile_map", + :foreign_key => "master_hardware_profile_id", + :association_foreign_key => "provider_hardware_profile_id" + + validates_presence_of :external_key + validates_uniqueness_of :external_key, :scope => :provider_id + + validates_presence_of :name + + validates_presence_of :storage + validates_numericality_of :storage + validates_presence_of :memory + validates_numericality_of :memory + + validates_presence_of :architecture +end diff --git a/src/app/models/image.rb b/src/app/models/image.rb index a69aaf2..098d09b 100644 --- a/src/app/models/image.rb +++ b/src/app/models/image.rb @@ -23,7 +23,10 @@ class Image < ActiveRecord::Base has_many :instances belongs_to :provider
- validates_presence_of :provider_id + belongs_to :master_image, :class_name => "Image", + :foreign_key => "master_image_id" + has_many :provider_images, :class_name => "Image", + :foreign_key => "master_image_id"
validates_presence_of :external_key validates_uniqueness_of :external_key, :scope => :provider_id diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb index a2cb01a..6e4241c 100644 --- a/src/app/models/instance.rb +++ b/src/app/models/instance.rb @@ -21,8 +21,16 @@
class Instance < ActiveRecord::Base belongs_to :portal_pool - belongs_to :flavor + belongs_to :cloud_account + + belongs_to :hardware_profile + belongs_to :provider_hardware_profile, :class_name => "HardwareProfile", + :foreign_key => "provider_hardware_profile_id" + belongs_to :image + belongs_to :provider_image, :class_name => "Image", + :foreign_key => "provider_image_id" + belongs_to :realm
validates_presence_of :portal_pool_id diff --git a/src/app/models/permission.rb b/src/app/models/permission.rb index 7c2bd9c..733cb0a 100644 --- a/src/app/models/permission.rb +++ b/src/app/models/permission.rb @@ -19,8 +19,8 @@
class Permission < ActiveRecord::Base belongs_to :pool - belongs_to :role + belongs_to :user
validates_presence_of :pool_id validates_presence_of :role_id diff --git a/src/app/models/user.rb b/src/app/models/pool_account.rb similarity index 80% copy from src/app/models/user.rb copy to src/app/models/pool_account.rb index cd49d32..2ba8de7 100644 --- a/src/app/models/user.rb +++ b/src/app/models/pool_account.rb @@ -1,5 +1,5 @@ # -# Copyright (C) 2009 Red Hat, Inc. +# Copyright (C) 2010 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +18,12 @@
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. +class PoolAccount < ActiveRecord::Base + belongs_to :cloud_account + belongs_to :portal_pool + belongs_to :quota + + validates_presence_of :cloud_account_id + validates_presence_of :portal_pool_id
-class User < ActiveRecord::Base - acts_as_authentic end diff --git a/src/app/models/portal_pool.rb b/src/app/models/portal_pool.rb index 6f4084b..0f0c42b 100644 --- a/src/app/models/portal_pool.rb +++ b/src/app/models/portal_pool.rb @@ -20,55 +20,60 @@ # Likewise, all the methods added will be available for all controllers.
class PortalPool < ActiveRecord::Base - belongs_to :cloud_account + has_many :pool_accounts, :dependent => :destroy + has_many :cloud_accounts, :through => :pool_accounts has_many :instances, :dependent => :destroy + belongs_to :owner, :class_name => "User", :foreign_key => "owner_id"
- # what form does the pool quota take?
validates_presence_of :cloud_account_id
+ validates_presence_of :owner_id validates_presence_of :name - validates_uniqueness_of :name, :scope => :cloud_account_id + validates_uniqueness_of :name, :scope => :owner_id + validates_uniqueness_of :exported_as
has_many :permissions, :as => :permission_object, :dependent => :destroy, :include => [:role], :order => "permissions.id ASC"
def populate_realms_and_images - client = cloud_account.connect - realms = client.realms - if client.driver_name == "ec2" - images = client.images(:owner_id=>:self) - else - images = client.images - end - # FIXME: this should probably be in the same transaction as portal_pool.save - self.transaction do - realms.each do |realm| - #ignore if it exists - #FIXME: we need to handle keeping in sync forupdates as well as - # account permissions - unless Realm.find_by_external_key_and_provider_id(realm.id, - cloud_account.provider.id) - ar_realm = Realm.new(:external_key => realm.id, - :name => realm.name ? realm.name : realm.id, - :provider_id => cloud_account.provider.id) - ar_realm.save! - end + cloud_accounts.each do |cloud_account| + client = cloud_account.connect + realms = client.realms + if client.driver_name == "ec2" + images = client.images(:owner_id=>:self) + else + images = client.images end - images.each do |image| - #ignore if it exists - #FIXME: we need to handle keeping in sync forupdates as well as - # account permissions - unless Image.find_by_external_key_and_provider_id(image.id, + # FIXME: this should probably be in the same transaction as portal_pool.save + self.transaction do + realms.each do |realm| + #ignore if it exists + #FIXME: we need to handle keeping in sync forupdates as well as + # account permissions + unless Realm.find_by_external_key_and_provider_id(realm.id, + cloud_account.provider.id) + ar_realm = Realm.new(:external_key => realm.id, + :name => realm.name ? realm.name : realm.id, + :provider_id => cloud_account.provider.id) + ar_realm.save! + end + end + images.each do |image| + #ignore if it exists + #FIXME: we need to handle keeping in sync forupdates as well as + # account permissions + unless Image.find_by_external_key_and_provider_id(image.id, cloud_account.provider.id) - ar_image = Image.new(:external_key => image.id, - :name => image.name ? image.name : - (image.description ? image.description : - image.id), - :architecture => image.architecture, - :provider_id => cloud_account.provider.id) - ar_image.save! + ar_image = Image.new(:external_key => image.id, + :name => image.name ? image.name : + (image.description ? image.description : + image.id), + :architecture => image.architecture, + :provider_id => cloud_account.provider.id) + ar_image.save! + end end end end diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb index dab9fee..14ffd80 100644 --- a/src/app/models/provider.rb +++ b/src/app/models/provider.rb @@ -23,10 +23,9 @@ class Provider < ActiveRecord::Base require 'util/deltacloud'
has_many :cloud_accounts, :dependent => :destroy - has_many :flavors, :dependent => :destroy + has_many :hardware_profiles, :dependent => :destroy has_many :images, :dependent => :destroy has_many :realms, :dependent => :destroy - has_many :portal_pools, :through=>:cloud_accounts
validates_presence_of :name validates_uniqueness_of :name @@ -48,18 +47,18 @@ class Provider < ActiveRecord::Base end end
- def populate_flavors - flavors = connect.flavors + def populate_hardware_profiles + hardware_profiles = connect.hardware_profiles # FIXME: this should probably be in the same transaction as provider.save self.transaction do - flavors.each do |flavor| - ar_flavor = Flavor.new(:external_key => flavor.id, - :name => flavor.name ? flavor.name : flavor.id, - :memory => flavor.memory, - :storage => flavor.storage, - :architecture => flavor.architecture, + hardware_profiles.each do |hardware_profile| + ar_hardware_profile = HardwareProfile.new(:external_key => hardware_profile.id, + :name => hardware_profile.name ? hardware_profile.name : hardware_profile.id, + :memory => hardware_profile.memory, + :storage => hardware_profile.storage, + :architecture => hardware_profile.architecture, :provider_id => id) - ar_flavor.save! + ar_hardware_profile.save! end end end diff --git a/src/app/models/user.rb b/src/app/models/quota.rb similarity index 92% copy from src/app/models/user.rb copy to src/app/models/quota.rb index cd49d32..28d1943 100644 --- a/src/app/models/user.rb +++ b/src/app/models/quota.rb @@ -19,6 +19,7 @@ # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers.
-class User < ActiveRecord::Base - acts_as_authentic +class Quota < ActiveRecord::Base + has_one :portal_pool + has_one :pool_account end diff --git a/src/app/models/user.rb b/src/app/models/user.rb index cd49d32..3e20689 100644 --- a/src/app/models/user.rb +++ b/src/app/models/user.rb @@ -21,4 +21,7 @@
class User < ActiveRecord::Base acts_as_authentic + + has_many :permissions + has_many :owned_pools, :class_name => "PortalPool", :foreign_key => "owner_id" end diff --git a/src/db/migrate/20090803141507_create_portal_pools.rb b/src/db/migrate/20090802000000_create_quotas.rb similarity index 72% copy from src/db/migrate/20090803141507_create_portal_pools.rb copy to src/db/migrate/20090802000000_create_quotas.rb index 9fea790..c61fb16 100644 --- a/src/db/migrate/20090803141507_create_portal_pools.rb +++ b/src/db/migrate/20090802000000_create_quotas.rb @@ -1,5 +1,6 @@ # # Copyright (C) 2009 Red Hat, Inc. +# Written by Scott Seago sseago@redhat.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,20 +17,20 @@ # MA 02110-1301, USA. A copy of the GNU General Public License is # also available at http://www.gnu.org/copyleft/gpl.html.
-# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class CreatePortalPools < ActiveRecord::Migration +class CreateQuotas < ActiveRecord::Migration def self.up - create_table :portal_pools do |t| - t.string :name, :null => false - t.integer :cloud_account_id, :null => false + create_table :quotas do |t| + t.integer :running_cpus + t.integer :running_memory + t.integer :running_instances + t.integer :total_storage + t.integer :total_instances t.integer :lock_version, :default => 0 t.timestamps end end
def self.down - drop_table :portal_pools + drop_table :quotas end end diff --git a/src/db/migrate/20090803141507_create_portal_pools.rb b/src/db/migrate/20090803141507_create_portal_pools.rb index 9fea790..d60b050 100644 --- a/src/db/migrate/20090803141507_create_portal_pools.rb +++ b/src/db/migrate/20090803141507_create_portal_pools.rb @@ -23,13 +23,17 @@ class CreatePortalPools < ActiveRecord::Migration def self.up create_table :portal_pools do |t| t.string :name, :null => false - t.integer :cloud_account_id, :null => false + t.string :exported_as + t.integer :owner_id, :null => false + t.integer :quota_id t.integer :lock_version, :default => 0 t.timestamps end + end
def self.down + drop_table :cloud_accounts_portal_pools drop_table :portal_pools end end diff --git a/src/db/migrate/20090804135630_create_flavors.rb b/src/db/migrate/20090804135630_create_hardware_profiles.rb similarity index 78% rename from src/db/migrate/20090804135630_create_flavors.rb rename to src/db/migrate/20090804135630_create_hardware_profiles.rb index 3378b8e..97eea9a 100644 --- a/src/db/migrate/20090804135630_create_flavors.rb +++ b/src/db/migrate/20090804135630_create_hardware_profiles.rb @@ -19,21 +19,26 @@ # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers.
-class CreateFlavors < ActiveRecord::Migration +class CreateHardwareProfiles < ActiveRecord::Migration def self.up - create_table :flavors do |t| + create_table :hardware_profiles do |t| t.string :external_key, :null => false t.string :name, :null => false, :limit => 1024 t.float :memory, :null => false t.float :storage, :null => false t.string :architecture, :null => false - t.integer :provider_id, :null => false + t.integer :provider_id t.integer :lock_version, :default => 0 t.timestamps end + + create_table "hardware_profile_map", :force => true, :id => false do |t| + t.column "master_hardware_profile_id", :integer + t.column "provider_hardware_profile_id", :integer +end end
def self.down - drop_table :flavors + drop_table :hardware_profiles end end diff --git a/src/db/migrate/20090804140143_create_images.rb b/src/db/migrate/20090804140143_create_images.rb index 5717caf..986c997 100644 --- a/src/db/migrate/20090804140143_create_images.rb +++ b/src/db/migrate/20090804140143_create_images.rb @@ -25,7 +25,8 @@ class CreateImages < ActiveRecord::Migration t.string :external_key, :null => false t.string :name, :null => false, :limit => 1024 t.string :architecture, :null => false - t.integer :provider_id, :null => false + t.integer :provider_id + t.integer :master_image_id t.integer :lock_version, :default => 0 t.timestamps end diff --git a/src/db/migrate/20090804142049_create_instances.rb b/src/db/migrate/20090804142049_create_instances.rb index 17abbfe..2880e85 100644 --- a/src/db/migrate/20090804142049_create_instances.rb +++ b/src/db/migrate/20090804142049_create_instances.rb @@ -24,10 +24,13 @@ class CreateInstances < ActiveRecord::Migration create_table :instances do |t| t.string :external_key t.string :name, :null => false, :limit => 1024 - t.integer :flavor_id, :null => false + t.integer :hardware_profile_id, :null => false + t.integer :provider_hardware_profile_id t.integer :image_id, :null => false + t.integer :provider_image_id t.integer :realm_id t.integer :portal_pool_id, :null => false + t.integer :cloud_account_id t.string :public_address t.string :private_address t.string :state diff --git a/src/db/migrate/20090803141507_create_portal_pools.rb b/src/db/migrate/20091215182906_create_pool_accounts.rb similarity index 84% copy from src/db/migrate/20090803141507_create_portal_pools.rb copy to src/db/migrate/20091215182906_create_pool_accounts.rb index 9fea790..e3b4fe6 100644 --- a/src/db/migrate/20090803141507_create_portal_pools.rb +++ b/src/db/migrate/20091215182906_create_pool_accounts.rb @@ -19,17 +19,18 @@ # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers.
-class CreatePortalPools < ActiveRecord::Migration +class CreatePoolAccounts < ActiveRecord::Migration def self.up - create_table :portal_pools do |t| - t.string :name, :null => false + create_table :pool_accounts do |t| t.integer :cloud_account_id, :null => false + t.integer :portal_pool_id, :null => false + t.integer :quota_id t.integer :lock_version, :default => 0 t.timestamps end end
def self.down - drop_table :portal_pools + drop_table :pool_accounts end end diff --git a/src/test/fixtures/cloud_accounts.yml b/src/test/fixtures/cloud_accounts.yml index 5bf0293..f9d41da 100644 --- a/src/test/fixtures/cloud_accounts.yml +++ b/src/test/fixtures/cloud_accounts.yml @@ -5,3 +5,7 @@ # # two: # column: value +mock_account: + username: mockuser + password: mockpassword + provider: mock_provider diff --git a/src/test/fixtures/hardware_profiles.yml b/src/test/fixtures/hardware_profiles.yml new file mode 100644 index 0000000..cc70c3e --- /dev/null +++ b/src/test/fixtures/hardware_profiles.yml @@ -0,0 +1,77 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +# one: +# column: value +# +# two: +# column: value +m1_small_backend: + external_key: m1-small + name: m1-small + memory: 1.7 + storage: 160 + architecture: i386 + provider: mock_provider +m1_large_backend: + external_key: m1-large + name: m1-large + memory: 7.5 + storage: 850 + architecture: x86_64 + provider: mock_provider +m1_xlarge_backend: + external_key: m1-xlarge + name: m1-xlarge + memory: 15 + storage: 1690 + architecture: x86_64 + provider: mock_provider +c1_medium_backend: + external_key: c1-medium + name: c1-medium + memory: 1.7 + storage: 350 + architecture: x86_64 + provider: mock_provider +c1_xlarge_backend: + external_key: c1-xlarge + name: c1-xlarge + memory: 7 + storage: 1690 + architecture: x86_64 + provider: mock_provider +m1_small_frontend: + external_key: m1-small + name: m1-small + memory: 1.7 + storage: 160 + architecture: i386 + provider_hardware_profiles: m1_small_frontend +m1_large_frontend: + external_key: m1-large + name: m1-large + memory: 7.5 + storage: 850 + architecture: x86_64 + provider_hardware_profiles: m1_large_frontend +m1_xlarge_frontend: + external_key: m1-xlarge + name: m1-xlarge + memory: 15 + storage: 1690 + architecture: x86_64 + provider_hardware_profiles: m1_xlarge_frontend +c1_medium_frontend: + external_key: c1-medium + name: c1-medium + memory: 1.7 + storage: 350 + architecture: x86_64 + provider_hardware_profiles: c1_medium_frontend +c1_xlarge_frontend: + external_key: c1-xlarge + name: c1-xlarge + memory: 7 + storage: 1690 + architecture: x86_64 + provider_hardware_profiles: c1_xlarge_frontend diff --git a/src/test/fixtures/images.yml b/src/test/fixtures/images.yml index 5bf0293..f9f2677 100644 --- a/src/test/fixtures/images.yml +++ b/src/test/fixtures/images.yml @@ -5,3 +5,13 @@ # # two: # column: value +fedora_13_image_backend: + external_key: fedora_13 + name: fedora_13 + architecture: x86_64 + provider: mock_provider +fedora_13_image_frontend: + external_key: fedora_13 + name: fedora_13 + architecture: x86_64 + provider_images: fedora_13_image_frontend diff --git a/src/test/fixtures/instances.yml b/src/test/fixtures/instances.yml index 5bf0293..1b7c84b 100644 --- a/src/test/fixtures/instances.yml +++ b/src/test/fixtures/instances.yml @@ -5,3 +5,16 @@ # # two: # column: value +test_instance: + external_key: test_instance + name: test_instance + hardware_profile: c1_xlarge_frontend + provider_hardware_profile: c1_xlarge_backend + image: fedora_13_image_frontend + provider_image: fedora_13_image_backend + realm: us_realm + portal_pool: test_pool + cloud_account: mock_account + public_address: + private_address: + state: stopped diff --git a/src/test/fixtures/permissions.yml b/src/test/fixtures/permissions.yml index 5bf0293..892007e 100644 --- a/src/test/fixtures/permissions.yml +++ b/src/test/fixtures/permissions.yml @@ -5,3 +5,11 @@ # # two: # column: value +admin_permission: + role: site_administrator + user: test_admin + permission_object: base_portal_object (BasePortalObject) +user_permission: + role: instance_creator_and_user + user: test_user + permission_object: test_pool (PortalPool) diff --git a/src/test/fixtures/pool_accounts.yml b/src/test/fixtures/pool_accounts.yml new file mode 100644 index 0000000..6ba868f --- /dev/null +++ b/src/test/fixtures/pool_accounts.yml @@ -0,0 +1,10 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +# one: +# column: value +# +# two: +# column: value +test_pool_mock_account: + cloud_account: mock_account + portal_pool: test_pool diff --git a/src/test/fixtures/portal_pools.yml b/src/test/fixtures/portal_pools.yml index 5bf0293..53b94ab 100644 --- a/src/test/fixtures/portal_pools.yml +++ b/src/test/fixtures/portal_pools.yml @@ -5,3 +5,7 @@ # # two: # column: value +test_pool + name: test_pool + owner: test_user + cloud_accounts: mock_account diff --git a/src/test/fixtures/providers.yml b/src/test/fixtures/providers.yml index 5bf0293..506c7d2 100644 --- a/src/test/fixtures/providers.yml +++ b/src/test/fixtures/providers.yml @@ -5,3 +5,7 @@ # # two: # column: value +mock_provider: + name: mock + cloud_type: Mock + url: http://localhost:3001/api diff --git a/src/test/fixtures/flavors.yml b/src/test/fixtures/quotas.yml similarity index 75% rename from src/test/fixtures/flavors.yml rename to src/test/fixtures/quotas.yml index 5bf0293..ddae3be 100644 --- a/src/test/fixtures/flavors.yml +++ b/src/test/fixtures/quotas.yml @@ -5,3 +5,5 @@ # # two: # column: value +test_pool_quota: + running_instances: 10 diff --git a/src/test/fixtures/realms.yml b/src/test/fixtures/realms.yml index 5bf0293..14cc32e 100644 --- a/src/test/fixtures/realms.yml +++ b/src/test/fixtures/realms.yml @@ -5,3 +5,11 @@ # # two: # column: value +us_realm: + external_key: us + name: United States + provider: mock_provider +eu_realm: + external_key: eu + name: Europe + provider: mock_provider diff --git a/src/test/fixtures/users.yml b/src/test/fixtures/users.yml index 3a3acb5..83d4f93 100644 --- a/src/test/fixtures/users.yml +++ b/src/test/fixtures/users.yml @@ -13,3 +13,11 @@ test_user: persistence_token: 5136b29cb04a5b8840fe74451b8bdf83531f57c072826eaf63a5c05e71828ed58fc5359a2f22b02e54298d64e043a870bc03d898249dd7f577f6c5418d5ba5a6 single_access_token: YxaPK0smnUj2t9Pq0xuK perishable_token: XZO-3xU2OIqHAUJOkDMX +test_admin: + login: tadmin + email: tadmin@example.com + password_salt: <%= salt = Authlogic::Random.hex_token %> + crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("testpass" + salt) %> + persistence_token: 5136b29cb04a5b8840fe74451b8bdf83531f57c072826eaf63a5c05e71828ed58fc5359a2f22b02e54298d64e043a870bc03d898249dd7f577f6c5418d5ba5a6 + single_access_token: YxaPK0smnUj2t9Pq0xuK + perishable_token: XZO-3xU2OIqHAUJOkDMX diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/hardware_profile_test.rb similarity index 100% copy from src/test/unit/flavor_test.rb copy to src/test/unit/hardware_profile_test.rb diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/pool_account_test.rb similarity index 69% copy from src/test/unit/flavor_test.rb copy to src/test/unit/pool_account_test.rb index 539b662..be6686d 100644 --- a/src/test/unit/flavor_test.rb +++ b/src/test/unit/pool_account_test.rb @@ -1,6 +1,6 @@ require 'test_helper'
-class FlavorTest < ActiveSupport::TestCase +class PoolAccountTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/quota_test.rb similarity index 71% rename from src/test/unit/flavor_test.rb rename to src/test/unit/quota_test.rb index 539b662..f629b97 100644 --- a/src/test/unit/flavor_test.rb +++ b/src/test/unit/quota_test.rb @@ -1,6 +1,6 @@ require 'test_helper'
-class FlavorTest < ActiveSupport::TestCase +class QuotaTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true
Couple minor things I noticed in here, inline
On Mon, Feb 8, 2010 at 5:24 PM, Scott Seago sseago@redhat.com wrote:
This is part of an overall redesign of the codebase. The most significant change is that a pool is now made up of one or more "back end" (or provider) accounts. Initially a user will have to pick a back end account (via the selection of a realm), but ultimately provider account selection will be optional, and the scheduler will automatically choose a back end account for each instance. In addition resources such as images or hardware profiles will be mapped from front end to back end clouds so that pool-specific images and hardware profiles chosen by the user will be mapped to the appropriate resources for whichever back-end cloud account ultimately receives the 'new instance' request.
- the full hardware profile model is not included -- this is roughly the old flavor model renamed to 'hardware profile'
- images and hardware profiles do not reflect the ability to map back-end images and profiles of multiple architectures to a single front end image or profile.
Signed-off-by: Scott Seago sseago@redhat.com
src/app/models/cloud_account.rb | 8 +-- src/app/models/flavor.rb | 39 ---------- src/app/models/hardware_profile.rb | 51 +++++++++++++ src/app/models/image.rb | 5 +- src/app/models/instance.rb | 10 +++- src/app/models/permission.rb | 2 +- src/app/models/{user.rb => pool_account.rb} | 11 ++- src/app/models/portal_pool.rb | 75 ++++++++++--------- src/app/models/provider.rb | 21 +++--- src/app/models/{user.rb => quota.rb} | 5 +- src/app/models/user.rb | 3 + ...al_pools.rb => 20090802000000_create_quotas.rb} | 17 +++-- .../migrate/20090803141507_create_portal_pools.rb | 6 ++- ... => 20090804135630_create_hardware_profiles.rb} | 13 +++- src/db/migrate/20090804140143_create_images.rb | 3 +- src/db/migrate/20090804142049_create_instances.rb | 5 +- ...s.rb => 20091215182906_create_pool_accounts.rb} | 9 ++- src/test/fixtures/cloud_accounts.yml | 4 + src/test/fixtures/hardware_profiles.yml | 77 ++++++++++++++++++++ src/test/fixtures/images.yml | 10 +++ src/test/fixtures/instances.yml | 13 ++++ src/test/fixtures/permissions.yml | 8 ++ src/test/fixtures/pool_accounts.yml | 10 +++ src/test/fixtures/portal_pools.yml | 4 + src/test/fixtures/providers.yml | 4 + src/test/fixtures/{flavors.yml => quotas.yml} | 2 + src/test/fixtures/realms.yml | 8 ++ src/test/fixtures/users.yml | 8 ++ .../{flavor_test.rb => hardware_profile_test.rb} | 0 .../unit/{flavor_test.rb => pool_account_test.rb} | 2 +- src/test/unit/{flavor_test.rb => quota_test.rb} | 2 +- 31 files changed, 316 insertions(+), 119 deletions(-) delete mode 100644 src/app/models/flavor.rb create mode 100644 src/app/models/hardware_profile.rb copy src/app/models/{user.rb => pool_account.rb} (80%) copy src/app/models/{user.rb => quota.rb} (92%) copy src/db/migrate/{20090803141507_create_portal_pools.rb => 20090802000000_create_quotas.rb} (72%) rename src/db/migrate/{20090804135630_create_flavors.rb => 20090804135630_create_hardware_profiles.rb} (78%) copy src/db/migrate/{20090803141507_create_portal_pools.rb => 20091215182906_create_pool_accounts.rb} (84%) create mode 100644 src/test/fixtures/hardware_profiles.yml create mode 100644 src/test/fixtures/pool_accounts.yml rename src/test/fixtures/{flavors.yml => quotas.yml} (75%) copy src/test/unit/{flavor_test.rb => hardware_profile_test.rb} (100%) copy src/test/unit/{flavor_test.rb => pool_account_test.rb} (69%) rename src/test/unit/{flavor_test.rb => quota_test.rb} (71%)
<snip>
diff --git a/src/db/migrate/20090804135630_create_flavors.rb b/src/db/migrate/20090804135630_create_hardware_profiles.rb similarity index 78% rename from src/db/migrate/20090804135630_create_flavors.rb rename to src/db/migrate/20090804135630_create_hardware_profiles.rb index 3378b8e..97eea9a 100644 --- a/src/db/migrate/20090804135630_create_flavors.rb +++ b/src/db/migrate/20090804135630_create_hardware_profiles.rb @@ -19,21 +19,26 @@ # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers.
-class CreateFlavors < ActiveRecord::Migration +class CreateHardwareProfiles < ActiveRecord::Migration def self.up
- create_table :flavors do |t|
- create_table :hardware_profiles do |t|
t.string :external_key, :null => false t.string :name, :null => false, :limit => 1024 t.float :memory, :null => false t.float :storage, :null => false t.string :architecture, :null => false
- t.integer :provider_id, :null => false
- t.integer :provider_id
t.integer :lock_version, :default => 0 t.timestamps end
- create_table "hardware_profile_map", :force => true, :id => false do |t|
- t.column "master_hardware_profile_id", :integer
- t.column "provider_hardware_profile_id", :integer
+end end
def self.down
- drop_table :flavors
- drop_table :hardware_profiles
should drop hardware_profile_map table as well
end end
<snip>
diff --git a/src/test/fixtures/cloud_accounts.yml b/src/test/fixtures/cloud_accounts.yml index 5bf0293..f9d41da 100644 --- a/src/test/fixtures/cloud_accounts.yml +++ b/src/test/fixtures/cloud_accounts.yml @@ -5,3 +5,7 @@ # # two: # column: value
Minor nit. This stuff can just go away ^^
+mock_account:
- username: mockuser
- password: mockpassword
- provider: mock_provider
diff --git a/src/test/fixtures/hardware_profiles.yml b/src/test/fixtures/hardware_profiles.yml new file mode 100644 index 0000000..cc70c3e --- /dev/null +++ b/src/test/fixtures/hardware_profiles.yml @@ -0,0 +1,77 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# one: +# column: value +# +# two: +# column: value
same as above ^^
+m1_small_backend:
- external_key: m1-small
- name: m1-small
- memory: 1.7
- storage: 160
- architecture: i386
- provider: mock_provider
+m1_large_backend:
- external_key: m1-large
- name: m1-large
- memory: 7.5
- storage: 850
- architecture: x86_64
- provider: mock_provider
+m1_xlarge_backend:
- external_key: m1-xlarge
- name: m1-xlarge
- memory: 15
- storage: 1690
- architecture: x86_64
- provider: mock_provider
+c1_medium_backend:
- external_key: c1-medium
- name: c1-medium
- memory: 1.7
- storage: 350
- architecture: x86_64
- provider: mock_provider
+c1_xlarge_backend:
- external_key: c1-xlarge
- name: c1-xlarge
- memory: 7
- storage: 1690
- architecture: x86_64
- provider: mock_provider
+m1_small_frontend:
- external_key: m1-small
- name: m1-small
- memory: 1.7
- storage: 160
- architecture: i386
- provider_hardware_profiles: m1_small_frontend
+m1_large_frontend:
- external_key: m1-large
- name: m1-large
- memory: 7.5
- storage: 850
- architecture: x86_64
- provider_hardware_profiles: m1_large_frontend
+m1_xlarge_frontend:
- external_key: m1-xlarge
- name: m1-xlarge
- memory: 15
- storage: 1690
- architecture: x86_64
- provider_hardware_profiles: m1_xlarge_frontend
+c1_medium_frontend:
- external_key: c1-medium
- name: c1-medium
- memory: 1.7
- storage: 350
- architecture: x86_64
- provider_hardware_profiles: c1_medium_frontend
+c1_xlarge_frontend:
- external_key: c1-xlarge
- name: c1-xlarge
- memory: 7
- storage: 1690
- architecture: x86_64
- provider_hardware_profiles: c1_xlarge_frontend
diff --git a/src/test/fixtures/images.yml b/src/test/fixtures/images.yml index 5bf0293..f9f2677 100644 --- a/src/test/fixtures/images.yml +++ b/src/test/fixtures/images.yml @@ -5,3 +5,13 @@ # # two: # column: value
delete ^^
+fedora_13_image_backend:
- external_key: fedora_13
- name: fedora_13
- architecture: x86_64
- provider: mock_provider
+fedora_13_image_frontend:
- external_key: fedora_13
- name: fedora_13
- architecture: x86_64
- provider_images: fedora_13_image_frontend
diff --git a/src/test/fixtures/instances.yml b/src/test/fixtures/instances.yml index 5bf0293..1b7c84b 100644 --- a/src/test/fixtures/instances.yml +++ b/src/test/fixtures/instances.yml @@ -5,3 +5,16 @@ # # two: # column: value
delete ^^
+test_instance:
- external_key: test_instance
- name: test_instance
- hardware_profile: c1_xlarge_frontend
- provider_hardware_profile: c1_xlarge_backend
- image: fedora_13_image_frontend
- provider_image: fedora_13_image_backend
- realm: us_realm
- portal_pool: test_pool
- cloud_account: mock_account
- public_address:
- private_address:
- state: stopped
diff --git a/src/test/fixtures/permissions.yml b/src/test/fixtures/permissions.yml index 5bf0293..892007e 100644 --- a/src/test/fixtures/permissions.yml +++ b/src/test/fixtures/permissions.yml @@ -5,3 +5,11 @@ # # two: # column: value
delete ^^
+admin_permission:
- role: site_administrator
- user: test_admin
- permission_object: base_portal_object (BasePortalObject)
+user_permission:
- role: instance_creator_and_user
- user: test_user
- permission_object: test_pool (PortalPool)
diff --git a/src/test/fixtures/pool_accounts.yml b/src/test/fixtures/pool_accounts.yml new file mode 100644 index 0000000..6ba868f --- /dev/null +++ b/src/test/fixtures/pool_accounts.yml @@ -0,0 +1,10 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# one: +# column: value +# +# two: +# column: value
delete ^^
+test_pool_mock_account:
- cloud_account: mock_account
- portal_pool: test_pool
diff --git a/src/test/fixtures/portal_pools.yml b/src/test/fixtures/portal_pools.yml index 5bf0293..53b94ab 100644 --- a/src/test/fixtures/portal_pools.yml +++ b/src/test/fixtures/portal_pools.yml @@ -5,3 +5,7 @@ # # two: # column: value
delete ^^
+test_pool
- name: test_pool
- owner: test_user
- cloud_accounts: mock_account
diff --git a/src/test/fixtures/providers.yml b/src/test/fixtures/providers.yml index 5bf0293..506c7d2 100644 --- a/src/test/fixtures/providers.yml +++ b/src/test/fixtures/providers.yml @@ -5,3 +5,7 @@ # # two: # column: value
delete ^^
+mock_provider:
- name: mock
- cloud_type: Mock
- url: http://localhost:3001/api
diff --git a/src/test/fixtures/flavors.yml b/src/test/fixtures/quotas.yml similarity index 75% rename from src/test/fixtures/flavors.yml rename to src/test/fixtures/quotas.yml index 5bf0293..ddae3be 100644 --- a/src/test/fixtures/flavors.yml +++ b/src/test/fixtures/quotas.yml @@ -5,3 +5,5 @@ # # two: # column: value
delete ^^
+test_pool_quota:
- running_instances: 10
diff --git a/src/test/fixtures/realms.yml b/src/test/fixtures/realms.yml index 5bf0293..14cc32e 100644 --- a/src/test/fixtures/realms.yml +++ b/src/test/fixtures/realms.yml @@ -5,3 +5,11 @@ # # two: # column: value
delete ^^
+us_realm:
- external_key: us
- name: United States
- provider: mock_provider
+eu_realm:
- external_key: eu
- name: Europe
- provider: mock_provider
diff --git a/src/test/fixtures/users.yml b/src/test/fixtures/users.yml index 3a3acb5..83d4f93 100644 --- a/src/test/fixtures/users.yml +++ b/src/test/fixtures/users.yml @@ -13,3 +13,11 @@ test_user: persistence_token: 5136b29cb04a5b8840fe74451b8bdf83531f57c072826eaf63a5c05e71828ed58fc5359a2f22b02e54298d64e043a870bc03d898249dd7f577f6c5418d5ba5a6 single_access_token: YxaPK0smnUj2t9Pq0xuK perishable_token: XZO-3xU2OIqHAUJOkDMX +test_admin:
- login: tadmin
- email: tadmin@example.com
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("testpass" + salt) %>
- persistence_token: 5136b29cb04a5b8840fe74451b8bdf83531f57c072826eaf63a5c05e71828ed58fc5359a2f22b02e54298d64e043a870bc03d898249dd7f577f6c5418d5ba5a6
- single_access_token: YxaPK0smnUj2t9Pq0xuK
- perishable_token: XZO-3xU2OIqHAUJOkDMX
diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/hardware_profile_test.rb similarity index 100% copy from src/test/unit/flavor_test.rb copy to src/test/unit/hardware_profile_test.rb diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/pool_account_test.rb similarity index 69% copy from src/test/unit/flavor_test.rb copy to src/test/unit/pool_account_test.rb index 539b662..be6686d 100644 --- a/src/test/unit/flavor_test.rb +++ b/src/test/unit/pool_account_test.rb @@ -1,6 +1,6 @@ require 'test_helper'
-class FlavorTest < ActiveSupport::TestCase +class PoolAccountTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true diff --git a/src/test/unit/flavor_test.rb b/src/test/unit/quota_test.rb similarity index 71% rename from src/test/unit/flavor_test.rb rename to src/test/unit/quota_test.rb index 539b662..f629b97 100644 --- a/src/test/unit/flavor_test.rb +++ b/src/test/unit/quota_test.rb @@ -1,6 +1,6 @@ require 'test_helper'
-class FlavorTest < ActiveSupport::TestCase +class QuotaTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true -- 1.6.2.5
deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel
deltacloud-devel@lists.fedorahosted.org