Class: CloudProviders::Authorize

Inherits:
Ec2Helper show all
Defined in:
lib/cloud_providers/ec2/helpers/authorize.rb

Instance Attribute Summary

Attributes inherited from CloudProvider

#init_opts, #name

Instance Method Summary collapse

Methods inherited from Ec2Helper

#as, #ec2, #elb, #initialize, #pool, property, #rds

Methods inherited from CloudProvider

#after_initialized, #bootstrap_nodes!, #default_keypair_path, default_keypair_path, #initialize, #method_missing

Constructor Details

This class inherits a constructor from CloudProviders::Ec2Helper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CloudProviders::CloudProvider

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cloud_providers/ec2/helpers/authorize.rb', line 11

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

#to_hashObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cloud_providers/ec2/helpers/authorize.rb', line 23

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