Class: BigBang::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/bigbang/provider.rb

Instance Method Summary collapse

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_zoneObject



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

#dnsObject



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

#ec2Object



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

#eipsObject



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_eipsObject



39
40
41
# File 'lib/bigbang/provider.rb', line 39

def free_eips
	eips.find_all { |eip| eip.instanceId.nil? }
end