Class: Fog::Compute::Linode::Server
- Inherits:
-
Server
- Object
- Server
- Fog::Compute::Linode::Server
- Defined in:
- lib/fog/linode/models/compute/server.rb
Instance Attribute Summary collapse
-
#stack_script ⇒ Object
readonly
Returns the value of attribute stack_script.
Instance Method Summary collapse
- #boot ⇒ Object
- #destroy ⇒ Object
- #disks ⇒ Object
- #disks? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Server
constructor
A new instance of Server.
- #ips ⇒ Object
- #public_ip_address ⇒ Object
- #ready? ⇒ Boolean
- #reboot ⇒ Object
- #save ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
12 13 14 15 |
# File 'lib/fog/linode/models/compute/server.rb', line 12 def initialize(attributes={}) super self.username = 'root' end |
Instance Attribute Details
#stack_script ⇒ Object (readonly)
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 |
Instance Method Details
#boot ⇒ Object
41 42 43 |
# File 'lib/fog/linode/models/compute/server.rb', line 41 def boot service.linode_boot id, config end |
#destroy ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/fog/linode/models/compute/server.rb', line 61 def destroy requires :identity service.linode_shutdown id disks.each { |disk| disk.destroy } wait_for { not disks? } service.linode_delete id end |
#disks ⇒ Object
25 26 27 |
# File 'lib/fog/linode/models/compute/server.rb', line 25 def disks Fog::Compute::Linode::Disks.new :server => self, :service => service end |
#disks? ⇒ Boolean
29 30 31 |
# File 'lib/fog/linode/models/compute/server.rb', line 29 def disks? not disks.empty? end |
#ips ⇒ Object
17 18 19 |
# File 'lib/fog/linode/models/compute/server.rb', line 17 def ips Fog::Compute::Linode::Ips.new :server => self, :service => service end |
#public_ip_address ⇒ Object
21 22 23 |
# File 'lib/fog/linode/models/compute/server.rb', line 21 def public_ip_address ips.find{|ip| ip.ip !~ /^192\.168\./}.ip end |
#ready? ⇒ Boolean
69 70 71 |
# File 'lib/fog/linode/models/compute/server.rb', line 69 def ready? status == 1 end |
#reboot ⇒ Object
33 34 35 |
# File 'lib/fog/linode/models/compute/server.rb', line 33 def reboot service.linode_reboot id end |
#save ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fog/linode/models/compute/server.rb', line 45 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? @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
37 38 39 |
# File 'lib/fog/linode/models/compute/server.rb', line 37 def shutdown service.linode_shutdown id end |