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



27
28
29
30
# File 'lib/yun/commands/node_command.rb', line 27

def create(node_name)
  attributes = create_attributes node_name, options
  connection.create attributes
end

#destroy(node_name) ⇒ Object



33
34
35
36
# File 'lib/yun/commands/node_command.rb', line 33

def destroy node_name
  node = connection.find node_name
  node.destroy
end

#listObject



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

def list
  node_attributes = connection.list.map do |node|
    {
      :id => node.id,
      :name => node.name,
      :type => node.instance_type,
      :image => node.image,
      :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