1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Changes to the security group handling:

* CreateSecurityGroup now includes the group id in the reply, this
  patch makes the code store this
* The patch also changes the delete call to use the group id if
  present (since you must use the id when deleting VPC groups)
This commit is contained in:
MaF 2012-03-20 08:49:49 +01:00
parent 4846a16053
commit de807f03b1
3 changed files with 34 additions and 4 deletions

View file

@ -1,5 +1,8 @@
require 'fog/core/model' require 'fog/core/model'
# XXX
require 'pp'
module Fog module Fog
module Compute module Compute
class AWS class AWS
@ -101,7 +104,11 @@ module Fog
def destroy def destroy
requires :name requires :name
if group_id.nil?
connection.delete_security_group(name) connection.delete_security_group(name)
else
connection.delete_security_group(nil, group_id)
end
true true
end end
@ -195,6 +202,8 @@ module Fog
def save def save
requires :description, :name requires :description, :name
data = connection.create_security_group(name, description, vpc_id).body data = connection.create_security_group(name, description, vpc_id).body
new_attributes = data.reject {|key,value| key == 'requestId'}
merge_attributes(new_attributes)
true true
end end

View file

@ -0,0 +1,20 @@
module Fog
module Parsers
module Compute
module AWS
class CreateSecurityGroup < Fog::Parsers::Base
def end_element(name)
case name
when 'requestId', 'return', 'groupId'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -3,7 +3,7 @@ module Fog
class AWS class AWS
class Real class Real
require 'fog/aws/parsers/compute/basic' require 'fog/aws/parsers/compute/create_security_group'
# Create a new security group # Create a new security group
# #
@ -17,6 +17,7 @@ module Fog
# * body<~Hash>: # * body<~Hash>:
# * 'requestId'<~String> - Id of request # * 'requestId'<~String> - Id of request
# * 'return'<~Boolean> - success? # * 'return'<~Boolean> - success?
# * 'groupId'<~String> - Id of created group
# #
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html] # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html]
def create_security_group(name, description, vpc_id=nil) def create_security_group(name, description, vpc_id=nil)
@ -24,8 +25,8 @@ module Fog
'Action' => 'CreateSecurityGroup', 'Action' => 'CreateSecurityGroup',
'GroupName' => name, 'GroupName' => name,
'GroupDescription' => description, 'GroupDescription' => description,
:parser => Fog::Parsers::Compute::AWS::Basic.new, 'VpcId' => vpc_id,
'VpcId' => vpc_id :parser => Fog::Parsers::Compute::AWS::CreateSecurityGroup.new
) )
end end