Class: Fog::Compute::Tenderloin::Server

Inherits:
Server
  • Object
show all
Defined in:
lib/fog/tenderloin/models/compute/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



37
38
39
# File 'lib/fog/tenderloin/models/compute/server.rb', line 37

def initialize(attributes={})
  super
end

Instance Method Details

#destroyObject



45
46
47
48
49
# File 'lib/fog/tenderloin/models/compute/server.rb', line 45

def destroy
  requires :id
  connection.destroy_vm(id)
  true
end

#public_ip_addressObject



33
34
35
# File 'lib/fog/tenderloin/models/compute/server.rb', line 33

def public_ip_address
  ip
end

#ready?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fog/tenderloin/models/compute/server.rb', line 25

def ready?
  running && ip
end

#running?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fog/tenderloin/models/compute/server.rb', line 29

def running?
  running
end

#saveObject



41
42
43
# File 'lib/fog/tenderloin/models/compute/server.rb', line 41

def save
  raise "Save not implemented"
end

#ssh(commands, options = {}, &blk) ⇒ Object



19
20
21
22
23
# File 'lib/fog/tenderloin/models/compute/server.rb', line 19

def ssh(commands, options={}, &blk)
  require 'net/ssh'
  options[:password] = password
  super(commands, options)
end

#sshable?Boolean

Returns:

  • (Boolean)


63
64
65
66
67
# File 'lib/fog/tenderloin/models/compute/server.rb', line 63

def sshable?
  ready? && !public_ip_address.nil? && !!Timeout::timeout(30) { ssh 'pwd' }
rescue SystemCallError, Net::SSH::AuthenticationFailed, Timeout::Error
  false
end

#startObject



51
52
53
54
55
# File 'lib/fog/tenderloin/models/compute/server.rb', line 51

def start
  requires :id
  connection.start_vm(id)
  true
end

#stopObject



57
58
59
60
61
# File 'lib/fog/tenderloin/models/compute/server.rb', line 57

def stop
  requires :id
  connection.stop_vm(id)
  true
end