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
# 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."
  connection.create attributes do
    print "."
  end
  puts "\ndone"
end

#destroy(node_name) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/yun/commands/node_command.rb', line 39

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



48
49
50
51
52
# File 'lib/yun/commands/node_command.rb', line 48

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