Sha256: c524c1c1e00f27512b32db1a4f7f6ef81c8b137dafb408e29ba8666ae0a4cfc1

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

module CloudProviders
  class Authorize < Ec2Helper
    default_options({
                :protocol   => "tcp",
                :from_port  => "22",
                :to_port    => "22",
                :network    => "0.0.0.0/0",
                :group_name => nil,
                :owner_id   => nil})
    
    def run
      options = 
      if group_name
        puts "Authorizing #{name} for group named: #{group_name} of owner id: #{owner_id}"
        {:authorize_security_group_ingress => group_name, :source_security_group_owner_id => owner_id}
      else
        puts "Authorizing: #{name} for #{protocol} to #{from_port}:#{to_port} #{network}"
        to_hash
      end
      ec2.authorize_security_group_ingress(options) rescue nil
    end
    
    def to_hash
      if group_name
        {:group_name => group_name}
      else
        {
          :group_name   => name,
          :ip_protocol  => protocol,
          :from_port    => from_port,
          :to_port      => to_port,
          :cidr_ip      => network
        }
      end
    end
    
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
poolparty-1.6.8 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.7 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.6 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.5 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.4 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.3 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.2 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.1 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.6.0 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.5.0 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.4.8 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.4.7 lib/cloud_providers/ec2/helpers/authorize.rb
poolparty-1.4.6 lib/cloud_providers/ec2/helpers/authorize.rb