Class: Arnold::Controller::Cli
- Inherits:
-
Object
- Object
- Arnold::Controller::Cli
- Defined in:
- lib/arnold/controller/cli.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #listnodes ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/arnold/controller/cli.rb', line 8 def initialize(args) @manager = Arnold::NodeManager.new case args[0] when "help" usage when "list" listnodes exit 0 when "new" args.shift @data = {} args.each do |arg| name, value = arg.split("=") @data[name] = value end begin node = Arnold::Node.new(nil, @data['name'], @data['macaddr'], Arnold::Node.munge(@data, :params), @data['classes'].split(',')) @manager.write(node) $CONFIG[:provisioner].provision(node) rescue RuntimeError => e puts "Whoops: #{e}" end else puts "WAT" usage end end |
Instance Method Details
#listnodes ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/arnold/controller/cli.rb', line 43 def listnodes nodes = @manager.loadall puts puts "________GUID______________________Name____________________MAC Address___" nodes.each do |node| printf "%18s │ %30s │ %18s\n", node.guid, node.name, node.macaddr end puts end |
#usage ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/arnold/controller/cli.rb', line 53 def usage puts puts "Usage:" puts " * arnold help" puts " * arnold list" puts " * arnold new [name=<name>] [macaddr=<macaddr>] [template=<template>] [group=<group>] [classes=<class1,class2,...>] [param1=value1]..." puts exit 1 end |