You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Michal Fojtik <mf...@redhat.com> on 2010/10/21 16:49:38 UTC
Re: [PATCH] small fix to ec2 driver to ensure imageset is not null
before attempting to use
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
>
--
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
Re: [PATCH] small fix to ec2 driver to ensure imageset is not null
before attempting to use
Posted by Michal Fojtik <mf...@redhat.com>.
On 21/10/10 10:53 -0400, Mohammed Morsi wrote:
> 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.
Sure thing :)
>
> -Mo
--
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
Re: [PATCH] small fix to ec2 driver to ensure imageset is not null
before attempting to use
Posted by Mohammed Morsi <mm...@redhat.com>.
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