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:
parent
4846a16053
commit
de807f03b1
3 changed files with 34 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
# XXX
|
||||
require 'pp'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
@ -101,7 +104,11 @@ module Fog
|
|||
def destroy
|
||||
requires :name
|
||||
|
||||
connection.delete_security_group(name)
|
||||
if group_id.nil?
|
||||
connection.delete_security_group(name)
|
||||
else
|
||||
connection.delete_security_group(nil, group_id)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -195,6 +202,8 @@ module Fog
|
|||
def save
|
||||
requires :description, :name
|
||||
data = connection.create_security_group(name, description, vpc_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
20
lib/fog/aws/parsers/compute/create_security_group.rb
Normal file
20
lib/fog/aws/parsers/compute/create_security_group.rb
Normal 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
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/basic'
|
||||
require 'fog/aws/parsers/compute/create_security_group'
|
||||
|
||||
# Create a new security group
|
||||
#
|
||||
|
@ -17,6 +17,7 @@ module Fog
|
|||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'return'<~Boolean> - success?
|
||||
# * 'groupId'<~String> - Id of created group
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html]
|
||||
def create_security_group(name, description, vpc_id=nil)
|
||||
|
@ -24,8 +25,8 @@ module Fog
|
|||
'Action' => 'CreateSecurityGroup',
|
||||
'GroupName' => name,
|
||||
'GroupDescription' => description,
|
||||
:parser => Fog::Parsers::Compute::AWS::Basic.new,
|
||||
'VpcId' => vpc_id
|
||||
'VpcId' => vpc_id,
|
||||
:parser => Fog::Parsers::Compute::AWS::CreateSecurityGroup.new
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue