From: Jan Provaznik jprovazn@redhat.com
Added check for matching HW profile --- src/app/models/instance.rb | 4 ++++ src/spec/models/instance_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb index aba031b..c34d647 100644 --- a/src/app/models/instance.rb +++ b/src/app/models/instance.rb @@ -325,6 +325,10 @@ class Instance < ActiveRecord::Base # hardware_profile that can satisfy the input hardware_profile hwp = HardwareProfile.match_provider_hardware_profile(account.provider, hardware_profile) + unless hwp + errors << "#{account.name}: hardware profile match not found" + next + end account_images = provider_images.select {|pi| pi.provider == account.provider} if account_images.empty? errors << "#{account.name}: image is not pushed to this provider account" diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb index de2154c..5856951 100644 --- a/src/spec/models/instance_spec.rb +++ b/src/spec/models/instance_spec.rb @@ -153,6 +153,13 @@ describe Instance do @instance.matches.last.should include('testaccount: image is not pushed to this provider account') end
+ it "shouldn't match provider accounts where matching hardware profile not found" do + account = Factory(:mock_provider_account, :label => 'testaccount') + account.provider.hardware_profiles.destroy_all + @pool.pool_family.provider_accounts << account + @instance.matches.last.should include('testaccount: hardware profile match not found') + end + it "should return a match if all requirements are satisfied" do build = @instance.image_build || @instance.image.latest_build provider = Factory(:mock_provider, :name => build.provider_images.first.provider_name)
On 06/30/2011 02:44 PM, jprovazn@redhat.com wrote:
From: Jan Provaznikjprovazn@redhat.com
Added check for matching HW profile
src/app/models/instance.rb | 4 ++++ src/spec/models/instance_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb index aba031b..c34d647 100644 --- a/src/app/models/instance.rb +++ b/src/app/models/instance.rb @@ -325,6 +325,10 @@ class Instance< ActiveRecord::Base # hardware_profile that can satisfy the input hardware_profile hwp = HardwareProfile.match_provider_hardware_profile(account.provider, hardware_profile)
unless hwp
errors<< "#{account.name}: hardware profile match not found"
next
end account_images = provider_images.select {|pi| pi.provider == account.provider} if account_images.empty? errors<< "#{account.name}: image is not pushed to this provider account"
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb index de2154c..5856951 100644 --- a/src/spec/models/instance_spec.rb +++ b/src/spec/models/instance_spec.rb @@ -153,6 +153,13 @@ describe Instance do @instance.matches.last.should include('testaccount: image is not pushed to this provider account') end
- it "shouldn't match provider accounts where matching hardware profile not found" do
- account = Factory(:mock_provider_account, :label => 'testaccount')
- account.provider.hardware_profiles.destroy_all
- @pool.pool_family.provider_accounts<< account
- @instance.matches.last.should include('testaccount: hardware profile match not found')
- end
- it "should return a match if all requirements are satisfied" do build = @instance.image_build || @instance.image.latest_build provider = Factory(:mock_provider, :name => build.provider_images.first.provider_name)
ACK
aeolus-devel@lists.fedorahosted.org