Class: BigBang::Provider
- Inherits:
-
Object
- Object
- BigBang::Provider
- Defined in:
- lib/bigbang/provider.rb
Instance Method Summary collapse
- #configured_zone ⇒ Object
- #create_dns(domain, addr) ⇒ Object
- #dns ⇒ Object
- #ec2 ⇒ Object
- #eips ⇒ Object
- #free_eips ⇒ Object
-
#initialize(config) ⇒ Provider
constructor
A new instance of Provider.
Constructor Details
#initialize(config) ⇒ Provider
Returns a new instance of Provider.
3 4 5 |
# File 'lib/bigbang/provider.rb', line 3 def initialize(config) @config = config end |
Instance Method Details
#configured_zone ⇒ Object
19 20 21 |
# File 'lib/bigbang/provider.rb', line 19 def configured_zone dns.zones.find { |z| z.domain == @config.domain } end |
#create_dns(domain, addr) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/bigbang/provider.rb', line 23 def create_dns(domain, addr) configured_zone.records.create( :value => addr, :name => domain, :type => "A") end |
#dns ⇒ Object
14 15 16 17 |
# File 'lib/bigbang/provider.rb', line 14 def dns return @dns unless @dns.nil? @dns = Fog::DNS.new(@config.dns_opts) end |
#ec2 ⇒ Object
7 8 9 10 11 12 |
# File 'lib/bigbang/provider.rb', line 7 def ec2 return @ec2 unless @ec2.nil? @ec2 = AWS::EC2::Base.new( :access_key_id => @config.access_key_id, :secret_access_key => @config.secret_key) end |
#eips ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/bigbang/provider.rb', line 30 def eips aset = ec2.describe_addresses.addressesSet if aset.nil? return [] else return aset.item end end |
#free_eips ⇒ Object
39 40 41 |
# File 'lib/bigbang/provider.rb', line 39 def free_eips eips.find_all { |eip| eip.instanceId.nil? } end |