Class: Yun::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/yun/model/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Node

Returns a new instance of Node.



4
5
6
# File 'lib/yun/model/node.rb', line 4

def initialize server
  @server = server
end

Instance Method Details

#all_infoObject



56
57
58
# File 'lib/yun/model/node.rb', line 56

def all_info
  @server
end

#created_atObject



44
45
46
# File 'lib/yun/model/node.rb', line 44

def created_at
  @server.created_at
end

#destroy(&block) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/yun/model/node.rb', line 48

def destroy &block
  @server.destroy
  @server.wait_for do
    instance_eval(&block) if block_given?
    not reload or state == 'terminated'
  end
end

#idObject



8
9
10
# File 'lib/yun/model/node.rb', line 8

def id
  @server.id
end

#imageObject



12
13
14
# File 'lib/yun/model/node.rb', line 12

def image
  @server.image_id
end

#instance_typeObject



16
17
18
# File 'lib/yun/model/node.rb', line 16

def instance_type
  @server.flavor_id
end

#ipObject



40
41
42
# File 'lib/yun/model/node.rb', line 40

def ip
  @server.public_ip_address
end

#is_destroyed?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/yun/model/node.rb', line 60

def is_destroyed?
  @server.state == 'terminated'
end

#key_nameObject



20
21
22
# File 'lib/yun/model/node.rb', line 20

def key_name
  @server.key_name
end

#nameObject



24
25
26
# File 'lib/yun/model/node.rb', line 24

def name
  @server.tags["name"]
end

#osObject



28
29
30
# File 'lib/yun/model/node.rb', line 28

def os
  @server.tags["os"]
end

#stateObject



36
37
38
# File 'lib/yun/model/node.rb', line 36

def state
  @server.state
end

#userObject



32
33
34
# File 'lib/yun/model/node.rb', line 32

def user
  @server.tags["user"]
end

#wait_for_ssh_ready(&block) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/yun/model/node.rb', line 64

def wait_for_ssh_ready &block
  ssh_config = SshConfig.new user, key_name
  ssh = Ssh.new ip, ssh_config
  @server.wait_for do
    instance_eval(&block) if block_given?
    ssh.is_ssh_ready?
  end
end