2010-03-16 18:46:21 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-08 17:40:02 -04:00
|
|
|
class Compute
|
2010-03-16 18:46:21 -04:00
|
|
|
class Real
|
2009-09-16 23:02:32 -04:00
|
|
|
|
|
|
|
# Remove permissions from a security group
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * options<~Hash>:
|
|
|
|
# * 'GroupName'<~String> - Name of group
|
|
|
|
# * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
|
|
|
|
# * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
|
|
|
|
# or
|
|
|
|
# * 'CidrIp' - CIDR range
|
|
|
|
# * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
|
|
|
|
# * 'GroupName' - Name of group to modify
|
|
|
|
# * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
|
|
|
|
# * 'ToPort' - End of port range (or -1 for ICMP wildcard)
|
|
|
|
#
|
|
|
|
# === Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-09-16 23:02:32 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'return'<~Boolean> - success?
|
|
|
|
def revoke_security_group_ingress(options = {})
|
|
|
|
request({
|
2010-05-24 17:22:35 -04:00
|
|
|
'Action' => 'RevokeSecurityGroupIngress',
|
|
|
|
:idempotent => true,
|
2010-09-08 17:40:02 -04:00
|
|
|
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
2010-03-16 01:15:33 -04:00
|
|
|
}.merge!(options))
|
2009-09-16 23:02:32 -04:00
|
|
|
end
|
|
|
|
|
2009-07-14 18:02:56 -04:00
|
|
|
end
|
2009-09-16 23:02:32 -04:00
|
|
|
|
2010-03-16 18:46:21 -04:00
|
|
|
class Mock
|
2009-07-14 18:02:56 -04:00
|
|
|
|
2009-09-16 23:02:32 -04:00
|
|
|
def revoke_security_group_ingress(options = {})
|
2010-05-24 20:41:01 -04:00
|
|
|
response = Excon::Response.new
|
|
|
|
group = @data[:security_groups][options['GroupName']]
|
|
|
|
if group
|
|
|
|
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
|
|
|
group['ipPermissions'].delete_if {|permission|
|
|
|
|
permission['groups'].first['groupName'] == options['GroupName']
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ingress = group['ipPermissions'].select {|permission|
|
|
|
|
permission['fromPort'] == options['FromPort'] &&
|
|
|
|
permission['ipProtocol'] == options['IpProtocol'] &&
|
|
|
|
permission['toPort'] == options['ToPort'] &&
|
|
|
|
(
|
|
|
|
permission['ipRanges'].empty? ||
|
|
|
|
(
|
|
|
|
permission['ipRanges'].first &&
|
|
|
|
permission['ipRanges'].first['cidrIp'] == options['CidrIp']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}.first
|
|
|
|
group['ipPermissions'].delete(ingress)
|
|
|
|
end
|
2010-02-02 01:53:18 -05:00
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'return' => true
|
|
|
|
}
|
2010-05-26 01:26:20 -04:00
|
|
|
response
|
2010-05-24 20:41:01 -04:00
|
|
|
else
|
2010-09-09 20:50:38 -04:00
|
|
|
raise Fog::AWS::Compute::NotFound.new("The security group '#{options['GroupName']}' does not exist")
|
2010-02-02 01:53:18 -05:00
|
|
|
end
|
2009-09-16 23:02:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-14 18:02:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|