incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohammed Morsi <mmo...@redhat.com>
Subject Re: [PATCH] small fix to ec2 driver to ensure imageset is not null before attempting to use
Date Thu, 21 Oct 2010 14:53:44 GMT
  On 10/21/2010 10:49 AM, Michal Fojtik wrote:
> On 18/10/10 13:16 -0400, Mohammed Morsi wrote:
>>  Note the only way I could test this through the standard core 
>> deployment was
>>  to change the default 'owner_id' used in the images query in the ec2 
>> driver
>>  to an account which had no images (eg my ec2 account after I deleted 
>> all my
>>  images). AFAIK the core REST interface doesn't allow 'user_id' to be 
>> passed
>>  in via the client and setting 'id' to something invalid yields 
>> another error:
>>
>>    'Deltacloud::BackendError - Invalid id: "ami-foo"'
>> ---
>> server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    7 +++++--
>> 1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb 
>> b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> index ac6ffce..0e71ea0 100644
>> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> @@ -130,8 +130,11 @@ class EC2Driver < Deltacloud::BaseDriver
>>       config.merge!({ :owner_id => opts[:owner_id] }) if opts and 
>> opts[:owner_id]
>>     end
>>     safely do
>> -      ec2.describe_images(config).imagesSet.item.each do |image|
>> -        img_arr << convert_image(image)
>> +      image_set = ec2.describe_images(config).imagesSet
>> +      unless image_set.nil?
>> +        image_set.item.each do |image|
>> +          img_arr << convert_image(image)
>> +        end
>>       end
>>     end
>>     img_arr = filter_on( img_arr, :architecture, opts )
>
> ACK.
>
> Btw. this could be also written in this way:
>
> img_arr = image.set.item.collect { |image| convert_image(image) } 
> unless image_set.nil?
>
>   -- Michal
>
>> -- 
>> 1.7.2.3
>>
>
Ah true, simplicity through Ruby FTW!

Thanks for the ack, do you think you can push this as well since I don't 
have core push rights.

   -Mo

Mime
View raw message