Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[updated]: 1) Update Authorize and Revoke security group permissions and 2) Minor issue - compatibility with ruby 1.8.6 and 3) Minor typo in aws.gemspec (missing lib/awsbase/support.rb) #89

Closed
wants to merge 3 commits into from

Conversation

marios
Copy link
Contributor

@marios marios commented May 10, 2011

Fix to maintain compatibility with Ruby 1.8.6 (use "string".to_a.each rather that "string".each_char)

Don't know if compatibility with ruby 1.8.6 is something you want to maintain - ran into this issue so thought I'd let you know.

The second commit reworks the Authorize and Revoke security groups ingress code. I believe the earlier implementations were based on http://docs.amazonwebservices.com/AWSEC2/2009-07-15/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html . In the latest version of API, you can specify a number of IP addresses, or groups, or mix of both, for which the specified rule will apply. Also, in the earlier API you couldn't specify 'from_port' 'to_port' 'protocol' for groups whereas now you can.

I implemented authorize and revoke as one method 'manage_security_group_ingress' (with an action parameter to specify which), since the only difference between them is the 'action' - if you prefer you should seperate them into seperate methods.

Finally the last commit is a very minor fix to gemspec - it looks like a file was removed along the way (lib/awsbase/support.rb) but the gemspec is still looking for this so there's an error if you want to build the gem by hand,

Thanks for considering these commits,

all the best, marios

…to latest API version - allows passing more than one IP address or source group (or mix of both) for the rule being specified
@marios
Copy link
Contributor Author

marios commented May 25, 2011

Hi Travis,

I can only apologise - you are right of course: "string".to_a doesn't work on ruby 1.9. I've found a way that's compatible with ruby 1.8 and 1.9 - I tested with ruby 1.9.2, 1.8.7, 1.8.6. Basically:
"string".each_byte do |b|
b.chr #gives you the char
end

I also noticed that the .gemspec no longer lists "lib/awsbase/support.rb".

I will close the current pull request and open a new one with the changes: as above for lib/awsbase/utils.rb, remove the change to the gemspec, and as before for lib/ec2/ec2.rb).

I am particularly interested in your thoughts about the security groups code - at the moment I am blocking on pushing that to our deltacloud repo as I need to make sure my code is compatible with aws gem.

thanks again, marios
(below output of irb in ruby 1.9.2, 1.8.7, 1.8.6 for your reference)

RUBY 1.9.2:
[marios@marios Scripts]$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]
[marios@marios Scripts]$ irb
ruby-1.9.2-p136 :001 > TO_REMEMBER = 'AZaz09 -.!~*'()' ; ASCII = {}
=> {}
ruby-1.9.2-p136 :002 > TO_REMEMBER.each_byte do |b|
ruby-1.9.2-p136 :003 > ASCII[b.chr] = b.chr.unpack("c")[0]
ruby-1.9.2-p136 :004?> end
=> "AZaz09 -
.!'()"
ruby-1.9.2-p136 :005 > ASCII
=> {"A"=>65, "Z"=>90, "a"=>97, "z"=>122, "0"=>48, "9"=>57, " "=>32, "-"=>45, "
"=>95, "."=>46, "!"=>33, "
"=>126, "_"=>42, "'"=>39, "("=>40, ")"=>41}

RUBY 1.8.7:
[marios@marios Scripts]$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
[marios@marios Scripts]$ irb
ruby-1.8.7-p302 :001 > TO_REMEMBER = 'AZaz09 -.!~*'()' ; ASCII = {}
=> {}
ruby-1.8.7-p302 :002 > TO_REMEMBER.each_byte do |b|
ruby-1.8.7-p302 :003 > ASCII[b.chr] = b.chr.unpack("c")[0]
ruby-1.8.7-p302 :004?> end
=> "AZaz09 -
.!_'()"
ruby-1.8.7-p302 :005 > ASCII
=> {" "=>32, "!"=>33, "a"=>97, "A"=>65, "-"=>45, "."=>46, "9"=>57, "z"=>122, "Z"=>90, "0"=>48, "'"=>39, "("=>40, "
"=>126, ")"=>41, ""=>95, ""=>42}

RUBY 1.8.6:
[marios@marios Scripts]$ ruby -v
ruby 1.8.6 (2010-09-02 patchlevel 420) [i386-linux]
[marios@marios Scripts]$ irb
irb(main):001:0> TO_REMEMBER = 'AZaz09 -.!~'()' ; ASCII = {}
=> {}
irb(main):002:0> TO_REMEMBER.each_byte do |b|
irb(main):003:1_ ASCII[b.chr] = b.chr.unpack("c")[0]
irb(main):004:1> end
=> "AZaz09 -.!~'()"
irb(main):005:0> ASCII
=> {" "=>32, "!"=>33, "a"=>97, "A"=>65, "-"=>45, "."=>46, "9"=>57, "z"=>122, "Z"=>90, "0"=>48, "'"=>39, "("=>40, "~"=>126, ")"=>41, ""=>95, ""=>42}

@marios marios closed this May 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant