From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/models/hardware_profile.rb | 27 --------------------
src/app/models/provider.rb | 18 -------------
...110302124928_remove_hardware_profile_mapping.rb | 12 +++++++++
.../step_definitions/hardware_profile_steps.rb | 3 --
src/features/support/custom.rb | 10 -------
src/spec/models/hardware_profile_spec.rb | 24 -----------------
6 files changed, 12 insertions(+), 82 deletions(-)
create mode 100644 src/db/migrate/20110302124928_remove_hardware_profile_mapping.rb
diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb
index daa66e7..75a501b 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -71,18 +71,6 @@ class HardwareProfile < ActiveRecord::Base
accepts_nested_attributes_for :memory, :cpu, :storage, :architecture
- has_and_belongs_to_many :conductor_hardware_profiles,
- :class_name => "HardwareProfile",
- :join_table => "hardware_profile_map",
- :foreign_key => "provider_hardware_profile_id",
- :association_foreign_key =>
"conductor_hardware_profile_id"
-
- has_and_belongs_to_many :provider_hardware_profiles,
- :class_name => "HardwareProfile",
- :join_table => "hardware_profile_map",
- :foreign_key => "conductor_hardware_profile_id",
- :association_foreign_key =>
"provider_hardware_profile_id"
-
validates_presence_of :external_key, :if => Proc.new { |hwp| !hwp.provider.nil? }
validates_uniqueness_of :external_key, :scope => [:provider_id], :if => Proc.new
{ |hwp| !hwp.provider.nil? }
@@ -99,21 +87,6 @@ class HardwareProfile < ActiveRecord::Base
!provider.nil?
end
- # FIXME: what about custom instance profiles?
- def validate
- if provider.nil?
- if !conductor_hardware_profiles.empty?
- errors.add(:conductor_hardware_profiles,
- "Conductor profiles only allowed for provider profiles")
- end
- else
- if !provider_hardware_profiles.empty?
- errors.add(:provider_hardware_profiles,
- "Provider profiles only allowed for conductor profiles")
- end
- end
- end
-
def add_properties(api_profile)
self.memory = new_property(api_profile.memory)
self.storage = new_property(api_profile.storage)
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index dfb94c3..1e6b27c 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -116,24 +116,6 @@ class Provider < ActiveRecord::Base
:provider_id => id)
ar_hardware_profile.add_properties(hardware_profile)
ar_hardware_profile.save!
-
- front_hwp = HardwareProfile.new(:external_key
=>ar_hardware_profile.external_key,
- :name => ar_hardware_profile.name)
-
- # Omit creation of new front-end hardware profile if
- # hardware profile with same external_key exists
-
- avail_hwp = HardwareProfile.frontend.find(:all, :conditions => { :external_key
=> front_hwp.external_key })
-
- if avail_hwp.empty?
- front_hwp.add_properties(hardware_profile)
- front_hwp.provider_hardware_profiles << ar_hardware_profile
- front_hwp.save!
- else
- avail_hwp.each do |hwp|
- hwp.provider_hardware_profiles << ar_hardware_profile
- end
- end
end
end
end
diff --git a/src/db/migrate/20110302124928_remove_hardware_profile_mapping.rb
b/src/db/migrate/20110302124928_remove_hardware_profile_mapping.rb
new file mode 100644
index 0000000..61b8724
--- /dev/null
+++ b/src/db/migrate/20110302124928_remove_hardware_profile_mapping.rb
@@ -0,0 +1,12 @@
+class RemoveHardwareProfileMapping < ActiveRecord::Migration
+ def self.up
+ drop_table :hardware_profile_map
+ end
+
+ def self.down
+ create_table "hardware_profile_map", :force => true, :id => false do
|t|
+ t.column "conductor_hardware_profile_id", :integer
+ t.column "provider_hardware_profile_id", :integer
+ end
+ end
+end
diff --git a/src/features/step_definitions/hardware_profile_steps.rb
b/src/features/step_definitions/hardware_profile_steps.rb
index c014cf9..5b9d97a 100644
--- a/src/features/step_definitions/hardware_profile_steps.rb
+++ b/src/features/step_definitions/hardware_profile_steps.rb
@@ -8,9 +8,6 @@ Given /^the Hardare Profile "([^"]*)" has the following
Provider Hardware Profil
provider = Factory :mock_provider
front_end_hwp = HardwareProfile.find_by_name(name)
back_end_hwps = table.hashes.collect { |hash| create_hwp(hash, provider) }
-
- front_end_hwp.provider_hardware_profiles = back_end_hwps
- front_end_hwp.save!
end
Given /^there is a "([^"]*)" hardware profile$/ do |arg1|
diff --git a/src/features/support/custom.rb b/src/features/support/custom.rb
index 1bc2c33..a11a133 100644
--- a/src/features/support/custom.rb
+++ b/src/features/support/custom.rb
@@ -7,16 +7,6 @@ Provider.class_eval do
def valid_framework?
true
end
-
- def populate_hardware_profiles
- [[:mock_hwp1, :agg_hwp1], [:mock_hwp2, :agg_hwp2]].each do |mp_name, ap_name|
- mock = Factory(mp_name, :provider_id => self.id)
- agg_mock = Factory(ap_name, :external_key => self.name +
Realm::CONDUCTOR_REALM_ACCOUNT_DELIMITER + mock.name)
- agg_mock.provider_hardware_profiles << mock
- end
- return true
- end
-
end
ProviderAccount.class_eval do
diff --git a/src/spec/models/hardware_profile_spec.rb
b/src/spec/models/hardware_profile_spec.rb
index 6ca8ca6..6a92b9c 100644
--- a/src/spec/models/hardware_profile_spec.rb
+++ b/src/spec/models/hardware_profile_spec.rb
@@ -56,30 +56,6 @@ describe HardwareProfile do
end
end
- it "should allow Conductor profiles only for provider profiles" do
- @hp.provider = nil
-
- @hp.conductor_hardware_profiles << @hp
- @hp.should have(1).error_on(:conductor_hardware_profiles)
- @hp.errors.on(:conductor_hardware_profiles).should eql(
- "Conductor profiles only allowed for provider profiles")
-
- @hp.conductor_hardware_profiles.clear
- @hp.should be_valid
- end
-
- it "should allow Provider profiles only for conductor profiles" do
- @hp.provider = Provider.new
-
- @hp.conductor_hardware_profiles << @hp
- @hp.should have(1).error_on(:provider_hardware_profiles)
- @hp.errors.on(:provider_hardware_profiles).should eql(
- "Provider profiles only allowed for conductor profiles")
-
- @hp.provider_hardware_profiles.clear
- @hp.should be_valid
- end
-
it "should have 'kind' attribute of hardware profile property set to
string (not symbol)" do
api_prop = mock('DeltaCloud::HWP::FloatProperty', :unit => 'MB',
:name => 'memory', :kind => :fixed, :value => 12288.0)
@hp.memory =(a)hp.new_property(api_prop)
--
1.7.4