1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/security_group.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

2009-09-18 11:56:42 -04:00
module Fog
module AWS
class EC2
class SecurityGroup < Fog::Model
identity :group_name, 'groupName'
2009-09-18 11:56:42 -04:00
attribute :group_description, 'groupDescription'
attribute :ip_permissions, 'ipPermissions'
attribute :owner_id, 'ownerId'
def authorize_group_and_owner(group, owner)
connection.authorize_security_group_ingress(
'GroupName' => @group_name,
'SourceSecurityGroupName' => group,
'SourceSecurityGroupOwnerId' => owner
)
end
def authorize_port_range(range, options = {})
connection.authorize_security_group_ingress(
'CidrIp' => options[:cidr_ip] || '0.0.0.0/0',
'FromPort' => range.min,
'GroupName' => @group_name,
'ToPort' => range.max,
'IpProtocol' => options[:ip_protocol] || 'tcp'
)
end
2009-09-20 12:21:03 -04:00
def destroy
2009-09-18 11:56:42 -04:00
connection.delete_security_group(@group_name)
true
end
def save
2009-09-28 23:00:49 -04:00
data = connection.create_security_group(@group_name, @group_description).body
2009-09-18 11:56:42 -04:00
true
end
end
end
end
end