NACK, see 2 comments inline. On 09/10/2010 04:58 PM, Michal Fojtik wrote: > --- > src/app/models/hardware_profile.rb | 4 ++++ > src/app/models/provider.rb | 28 ++++++++++++++++++---------- > 2 files changed, 22 insertions(+), 10 deletions(-) > > diff --git a/src/app/models/hardware_profile.rb > b/src/app/models/hardware_profile.rb > index 2ce6d81..328f90c 100644 > --- a/src/app/models/hardware_profile.rb > +++ b/src/app/models/hardware_profile.rb > @@ -21,8 +21,12 @@ > > class HardwareProfile< ActiveRecord::Base > has_many :instances > +
here ^^^ is a trailing whitespace > + named_scope :frontend, :conditions => { :provider_id => nil } > + > has_many :provider_instances, :class_name => "Instance", > :foreign_key => "provider_hardware_profile_id" > + > belongs_to :provider > > belongs_to :memory, :class_name => "HardwareProfileProperty", > diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb > index ed8fc70..25a7f5f 100644 > --- a/src/app/models/provider.rb > +++ b/src/app/models/provider.rb > @@ -81,16 +81,24 @@ class Provider< ActiveRecord::Base > :provider_id => id) > ar_hardware_profile.add_properties(hardware_profile) > ar_hardware_profile.save! > - front_hwp = HardwareProfile.new(:external_key => > - name + > - > Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER + > - ar_hardware_profile.external_key, > - :name => name + > - > Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER + > - ar_hardware_profile.name) > - front_hwp.add_properties(hardware_profile) > - front_hwp.provider_hardware_profiles<< ar_hardware_profile > - front_hwp.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, :external_key => > front_hwp.external_key) When I add a provider, I'm getting an error on the line above: ArgumentError (Unknown key(s): external_key) The line should read: 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 _______________________________________________ deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel