On 07/06/10 17:15 -0400, Jason Guiditta wrote:
>On Mon, 2010-06-07 at 17:12 -0400, Jason Guiditta wrote:
>> This happened if you were not a site admin because we do
>> not have perms hooked directly to instances, but pools.
>> ---
>>  src/app/models/instance.rb |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
>> index 591bc62..ee35ba5 100644
>> --- a/src/app/models/instance.rb
>> +++ b/src/app/models/instance.rb
>> @@ -171,7 +171,10 @@ class Instance < ActiveRecord::Base
>>        :stopped_instances => 0,
>>      }
>>
>> -    instances = Instance.with_hardware_profile.list_for_user(user, 
>> Privilege::INSTANCE_VIEW)
>> +    instances = []
>> +    pools = Pool.list_for_user(user, Privilege::INSTANCE_VIEW)
>> +    pools.each{|pool| pool.instances.each {|i| instances << i}}

This could be just:

         instances = pools.collect { |p| p.instances }.flatten

But it's just cosmetic one ;-)


>> +    #instances = Instance.with_hardware_profile.list_for_user(user, 
>> Privilege::INSTANCE_VIEW)
>
>Note that this ^ is removed in final patch.
>
>>      instances.each do |i|
>>        if i.state == Instance::STATE_RUNNING
>>          stats[:running_instances] += 1

ACK.


  -- Michal


-- 
--------------------------------------------------------
Michal Fojtik, [email protected], +420 532 294 4307
Ruby / Ruby On Rails Developer
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to