[email protected] wrote:
> This Series of patches adds the ability to Create/Edit/Delete quota on Pools
> and Cloud Accounts. It Audits quota by storing totals on the quota model.
> Then enforces the Quota on Instance Create/Start in TaskOMatic
>
> Changes from last submission:
>
> - Added Quota Factory
> - Updated Quota limits/totals to use strings instead of integer (copying the
> hwp model)
> - Refactory Model.find methods to use e.g. pool.quota
> - Updated task-o-matic to check quota for start and create on
> create_instance, using assumption that all providers start instance on create
> - Removed STATE_NEW from ACTIVE_STATES
> _______________________________________________
> deltacloud-devel mailing list
> [email protected]
> https://fedorahosted.org/mailman/listinfo/deltacloud-devel
>
Ran into the following error running 'rake spec':
1)
NoMethodError in 'Instance should be able to query and set up frontend
realm'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.quota
/home/sseago/devel/git/deltacloud/aggregator/src/app/models/instance_observer.rb:41:in
`update_quota'
/home/sseago/devel/git/deltacloud/aggregator/src/app/models/instance_observer.rb:40:in
`each'
/home/sseago/devel/git/deltacloud/aggregator/src/app/models/instance_observer.rb:40:in
`update_quota'
/home/sseago/devel/git/deltacloud/aggregator/src/app/models/instance_observer.rb:11:in
`before_save'
/home/sseago/.gem/ruby/1.8/gems/factory_girl-1.2.3/lib/factory_girl/proxy/create.rb:6:in
`result'
/home/sseago/.gem/ruby/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:316:in
`run'
/home/sseago/.gem/ruby/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:260:in
`create'
./spec/models/instance_spec.rb:98:
I think it's failing when trying to find the quota for the
cloud_account, since a newly-created instance may not yet have an
assigned cloud account.
Make the following change and all the tests pass for me:
diff --git a/src/app/models/instance_observer.rb
b/src/app/models/instance_observer.rb
index 52adccc..1521085 100644
--- a/src/app/models/instance_observer.rb
+++ b/src/app/models/instance_observer.rb
@@ -38,7 +38,7 @@ class InstanceObserver < ActiveRecord::Observer
cloud_account = an_instance.cloud_account
[cloud_account, pool].each do |parent|
- quota = parent.quota
+ quota = parent.quota if parent
if quota
if state_to == Instance::STATE_RUNNING
quota.running_instances += 1
ACK otherwise -- it seems to work fine, so make this one change above
and push the patches.
Scott
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel