Class: Fog::Compute::Linode::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/linode/models/compute/server.rb
Instance Attribute Summary collapse
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Server
#scp, #ssh
Methods inherited from Model
#inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
13
14
15
16
|
# File 'lib/fog/linode/models/compute/server.rb', line 13
def initialize(attributes={})
super
self.username = 'root'
end
|
Instance Attribute Details
#private_key ⇒ Object
Returns the value of attribute private_key.
8
9
10
|
# File 'lib/fog/linode/models/compute/server.rb', line 8
def private_key
@private_key
end
|
#stack_script ⇒ Object
Returns the value of attribute stack_script.
7
8
9
|
# File 'lib/fog/linode/models/compute/server.rb', line 7
def stack_script
@stack_script
end
|
#username ⇒ Object
Returns the value of attribute username.
8
9
10
|
# File 'lib/fog/linode/models/compute/server.rb', line 8
def username
@username
end
|
Instance Method Details
#boot ⇒ Object
42
43
44
|
# File 'lib/fog/linode/models/compute/server.rb', line 42
def boot
connection.linode_boot id, config
end
|
#destroy ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/fog/linode/models/compute/server.rb', line 62
def destroy
requires :identity
connection.linode_shutdown id
disks.each { |disk| disk.destroy }
wait_for { not disks? }
connection.linode_delete id
end
|
#disks ⇒ Object
26
27
28
|
# File 'lib/fog/linode/models/compute/server.rb', line 26
def disks
Fog::Compute::Linode::Disks.new :server => self, :connection => connection
end
|
#disks? ⇒ Boolean
30
31
32
|
# File 'lib/fog/linode/models/compute/server.rb', line 30
def disks?
not disks.empty?
end
|
#ips ⇒ Object
18
19
20
|
# File 'lib/fog/linode/models/compute/server.rb', line 18
def ips
Fog::Compute::Linode::Ips.new :server => self, :connection => connection
end
|
#public_ip_address ⇒ Object
22
23
24
|
# File 'lib/fog/linode/models/compute/server.rb', line 22
def public_ip_address
ips.find{|ip| ip.ip !~ /^192/}.ip
end
|
#reboot ⇒ Object
34
35
36
|
# File 'lib/fog/linode/models/compute/server.rb', line 34
def reboot
connection.linode_reboot id
end
|
#save ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/fog/linode/models/compute/server.rb', line 46
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
@data_center, @flavor, @image, @kernel, @type, @payment_terms, @stack_script, @name, @password, @callback =
attributes.values_at :data_center, :flavor, :image, :kernel, :type, :payment_terms, :stack_script, :name, :password, :callback
create_linode
@callback.call self if @callback
create_disks
create_config
boot_linode
self
rescue Exception => ex
destroy if id
raise ex
end
|
#shutdown ⇒ Object
38
39
40
|
# File 'lib/fog/linode/models/compute/server.rb', line 38
def shutdown
connection.linode_shutdown id
end
|