2011-07-13 17:18:58 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class ACS
|
|
|
|
|
|
|
|
class SecurityGroup < Fog::Model
|
|
|
|
|
|
|
|
identity :id, :aliases => 'CacheSecurityGroupName'
|
2011-09-02 11:59:50 -04:00
|
|
|
attribute :description, :aliases => 'Description'
|
2011-07-14 10:45:52 -04:00
|
|
|
attribute :ec2_groups, :aliases => 'EC2SecurityGroups', :type => :array
|
2011-07-13 17:18:58 -04:00
|
|
|
attribute :owner_id, :aliases => 'OwnerId'
|
|
|
|
|
|
|
|
def ready?
|
2011-07-14 10:45:52 -04:00
|
|
|
ec2_groups.all?{|ingress| ingress['Status'] == 'authorized'}
|
2011-07-13 17:18:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.delete_cache_security_group(id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :id
|
|
|
|
requires :description
|
|
|
|
connection.create_cache_security_group(id, description)
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_ec2_group(group_name, group_owner_id=owner_id)
|
2011-07-14 10:45:52 -04:00
|
|
|
requires :id
|
|
|
|
requires :owner_id if group_owner_id.nil?
|
|
|
|
data = connection.authorize_cache_security_group_ingress(id, group_name, group_owner_id).body['CacheSecurityGroup']
|
|
|
|
merge_attributes(data)
|
2011-07-13 17:18:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def revoke_ec2_group(group_name, group_owner_id=owner_id)
|
2011-07-14 10:45:52 -04:00
|
|
|
requires :id
|
|
|
|
requires :owner_id if group_owner_id.nil?
|
|
|
|
data = connection.revoke_cache_security_group_ingress(id, group_name, group_owner_id).body['CacheSecurityGroup']
|
|
|
|
merge_attributes(data)
|
2011-07-13 17:18:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|