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

54 lines
1.3 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 :name, 'groupName'
attribute :description, 'groupDescription'
attribute :ip_permissions, 'ipPermissions'
attribute :owner_id, 'ownerId'
2009-09-18 11:56:42 -04:00
def authorize_group_and_owner(group, owner)
requires :name
connection.authorize_security_group_ingress(
'GroupName' => @name,
'SourceSecurityGroupName' => group,
'SourceSecurityGroupOwnerId' => owner
)
end
def authorize_port_range(range, options = {})
requires :name
connection.authorize_security_group_ingress(
'CidrIp' => options[:cidr_ip] || '0.0.0.0/0',
'FromPort' => range.min,
'GroupName' => @name,
'ToPort' => range.max,
'IpProtocol' => options[:ip_protocol] || 'tcp'
)
end
2009-09-20 12:21:03 -04:00
def destroy
requires :name
connection.delete_security_group(@name)
2009-09-18 11:56:42 -04:00
true
end
def save
requires :description, :name
data = connection.create_security_group(@name, @description).body
2009-09-18 11:56:42 -04:00
true
end
end
end
end
end