Class: Cloud
- Inherits:
-
Object
- Object
- Cloud
- Defined in:
- lib/dew/cloud.rb
Overview
require ‘opensrs’
Instance Attribute Summary collapse
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#profile_name ⇒ Object
readonly
Returns the value of attribute profile_name.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Class Method Summary collapse
Instance Method Summary collapse
- #account ⇒ Object
- #compute ⇒ Object
- #dns ⇒ Object
- #elb ⇒ Object
- #has_dns? ⇒ Boolean
- #keyfile_path(key_name) ⇒ Object
- #keypair_exists?(keypair) ⇒ Boolean
- #profile ⇒ Object
- #rds ⇒ Object
- #rds_authorized_ec2_owner_ids ⇒ Object
- #security_groups ⇒ Object
- #valid_servers ⇒ Object
Instance Attribute Details
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
5 6 7 |
# File 'lib/dew/cloud.rb', line 5 def account_name @account_name end |
#profile_name ⇒ Object (readonly)
Returns the value of attribute profile_name.
5 6 7 |
# File 'lib/dew/cloud.rb', line 5 def profile_name @profile_name end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
5 6 7 |
# File 'lib/dew/cloud.rb', line 5 def region @region end |
Class Method Details
.connect(region, account_name, profile_name = nil) ⇒ Object
9 10 11 12 |
# File 'lib/dew/cloud.rb', line 9 def connect region, account_name, profile_name = nil @connection = new(region, account_name, profile_name) Inform.info("Connected to AWS in %{region} using account %{account_name}", :region => region, :account_name => account_name) end |
.method_missing(method, *args) ⇒ Object
14 15 16 |
# File 'lib/dew/cloud.rb', line 14 def method_missing method, *args @connection.send(method, *args) end |
Instance Method Details
#account ⇒ Object
20 21 22 |
# File 'lib/dew/cloud.rb', line 20 def account @account ||= Account.read(account_name) end |
#compute ⇒ Object
24 25 26 |
# File 'lib/dew/cloud.rb', line 24 def compute @compute ||= Fog::Compute.new(fog_credentials.merge({:provider => 'AWS'})) end |
#dns ⇒ Object
74 75 76 |
# File 'lib/dew/cloud.rb', line 74 def dns # @dns ||= OpenSRS::Server.new(account.opensrs_credentials) end |
#elb ⇒ Object
40 41 42 |
# File 'lib/dew/cloud.rb', line 40 def elb @elb ||= Fog::AWS::ELB.new(fog_credentials) end |
#has_dns? ⇒ Boolean
70 71 72 |
# File 'lib/dew/cloud.rb', line 70 def has_dns? account.has_dns? end |
#keyfile_path(key_name) ⇒ Object
65 66 67 68 |
# File 'lib/dew/cloud.rb', line 65 def keyfile_path(key_name) account_dir = File.join(ENV['HOME'], '.dew','accounts') File.join(account_dir, 'keys', account_name, region, "#{key_name}.pem") end |
#keypair_exists?(keypair) ⇒ Boolean
36 37 38 |
# File 'lib/dew/cloud.rb', line 36 def keypair_exists? keypair !!compute.key_pairs.get(keypair) end |
#profile ⇒ Object
59 60 61 62 63 |
# File 'lib/dew/cloud.rb', line 59 def profile if profile_name @profile ||= Profile.read(profile_name) end end |
#rds ⇒ Object
44 45 46 |
# File 'lib/dew/cloud.rb', line 44 def rds @rds ||= Fog::AWS::RDS.new(fog_credentials) end |
#rds_authorized_ec2_owner_ids ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dew/cloud.rb', line 48 def # XXX - Does this belong in Fog::AWS::RDS ? @rds_authorized_ec2_owner_ids ||= rds.security_groups.detect { |security_group| security_group.id == 'default' }.ec2_security_groups.select { |ec2_security_group| ec2_security_group["EC2SecurityGroupName"] == "default" && ec2_security_group["Status"] == "authorized" }.collect { |h| h["EC2SecurityGroupOwnerId"] } end |
#security_groups ⇒ Object
28 29 30 |
# File 'lib/dew/cloud.rb', line 28 def security_groups @security_groups ||= compute.security_groups.inject({}) { |h, g| h[g.name] = g; h } end |