Class: Yun::NodeCommand

Inherits:
Thor
  • Object
show all
Includes:
CommandBase
Defined in:
lib/yun/commands/node_command.rb

Instance Method Summary collapse

Methods included from CommandBase

#connection, #init_data

Instance Method Details

#create(node_name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/yun/commands/node_command.rb', line 28

def create(node_name)
  $stdout.sync = true

  attributes = create_attributes node_name, options

  print "creating node."

  node = connection.create attributes do
    print "."
  end

  print "node #{node_name} created."
  print "\nwaiting sshd ready."

  node.wait_for_ssh_ready { print "." }

  print "node #{node_name} is ssh ready."

  puts "\ndone"
end

#destroy(node_name) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/yun/commands/node_command.rb', line 50

def destroy node_name
  $stdout.sync = true
  node = connection.find node_name
  print "destroy node."
  node.destroy { print "." }
  puts "\ndone"
end

#info(node_name) ⇒ Object



59
60
61
62
63
# File 'lib/yun/commands/node_command.rb', line 59

def info node_name
  $stdout.sync = true
  node = connection.find node_name
  pp node.all_info
end

#listObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yun/commands/node_command.rb', line 10

def list
  node_attributes = connection.list.map do |node|
    {
      :id => node.id,
      :name => node.name,
      :type => node.instance_type,
      :os => node.os,
      :ip => node.ip,
      :created_at => node.created_at.strftime("%Y-%m-%d %H:%M:%S"),
      :state => node.state
    }
  end
  puts Hirb::Helpers::AutoTable.render node_attributes
end