Class: Hazetug::Haze::Linode
Constant Summary
RE_BITS
NetSSH::Mixin::NET_SSH_OPTIONS
Instance Attribute Summary
#compute_name, #config
Instance Method Summary
collapse
#bits_from_string, #image_from_string, #lookup, #memory_in_megabytes, #provision_server, #server_args, #wait_for_ssh
[], defaults, #provision, #ready?, requires, #update_access_settings
Methods included from UI::Mixin
included
Constructor Details
#initialize(config = {}) ⇒ Linode
12
13
14
15
16
17
|
# File 'lib/hazetug/haze/linode.rb', line 12
def initialize(config={})
super
@config[:bits] = bits_from_string(@config[:image])
@config[:image_slug] = image_from_string(@config[:image])
@config[:ssh_password] ||= SecureRandom.hex
end
|
Instance Method Details
#compare_flavor?(o) ⇒ Boolean
40
41
42
43
44
45
|
# File 'lib/hazetug/haze/linode.rb', line 40
def compare_flavor?(o)
a = o.attributes
value = config[:flavor]
a[:ram] == memory_in_megabytes(value) ||
a[:name].match(/^#{value}/i)
end
|
#compare_image?(o) ⇒ Boolean
47
48
49
50
51
52
|
# File 'lib/hazetug/haze/linode.rb', line 47
def compare_image?(o)
a = o.attributes
img_id = image_from_string(a[:name])
bits = a[:bits]
img_id.match(/^#{config[:image_slug]}/) && bits == config[:bits]
end
|
#compare_location?(o) ⇒ Boolean
33
34
35
36
37
38
|
# File 'lib/hazetug/haze/linode.rb', line 33
def compare_location?(o)
a = o.attributes
value = config[:location]
a[:location].match(/^#{value}/i) != nil ||
a[:abbr] == config[:location] || a[:abbr].match(/^#{value}/) != nil
end
|
#create_server_args ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/hazetug/haze/linode.rb', line 19
def create_server_args
latest = /^Latest #{config[:bits]} bit/
{
:name => config[:name].gsub(/\./,'-'),
:data_center => lookup(:location),
:flavor => lookup(:flavor),
:image => lookup(:image),
:kernel => compute.kernels.find {|k| k.name.match(latest)},
:password => config[:ssh_password],
:payment_terms => config[:payment_terms]
}
end
|
#private_ip_address ⇒ Object
58
59
60
61
62
63
|
# File 'lib/hazetug/haze/linode.rb', line 58
def private_ip_address
server and begin
found = server.ips.find {|ip| not ip.public}
found and found.ip
end
end
|
#public_ip_address ⇒ Object
54
55
56
|
# File 'lib/hazetug/haze/linode.rb', line 54
def public_ip_address
server and server.public_ip_address
end
|