bin/tl in testlab-0.5.4 vs bin/tl in testlab-0.6.0

- old
+ new

@@ -147,10 +147,86 @@ end end end end + # NODE UP + ########## + c.desc 'Up a node' + c.long_desc <<-EOF +Up a node. The node is started and brought online. +EOF + c.command :up do |up| + up.action do |global_options, options, args| + if options[:id].nil? + help_now!('id is required') if options[:id].nil? + else + node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first + node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!" + + node.up + end + end + end + + # NODE DOWN + ############ + c.desc 'Down a node' + c.long_desc <<-EOF +Down a node. The node is stopped taking it offline. +EOF + c.command :down do |down| + down.action do |global_options, options, args| + if options[:id].nil? + help_now!('id is required') if options[:id].nil? + else + node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first + node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!" + + node.down + end + end + end + + # NODE SETUP + ############# + c.desc 'Setup a node' + c.long_desc <<-EOF +Setup a node. The node is created, started and provisioned. +EOF + c.command :setup do |setup| + setup.action do |global_options, options, args| + if options[:id].nil? + help_now!('id is required') if options[:id].nil? + else + node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first + node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!" + + node.setup + end + end + end + + # NODE TEARDOWN + ################ + c.desc 'Teardown a node' + c.long_desc <<-EOF +Teardown a node. The node is offlined and destroyed. +EOF + c.command :teardown do |teardown| + teardown.action do |global_options, options, args| + if options[:id].nil? + help_now!('id is required') if options[:id].nil? + else + node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first + node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!" + + node.teardown + end + end + end + end # NETWORKS ########### desc 'Manage networks' @@ -375,11 +451,13 @@ # No ID supplied; show everything containers = @testlab.containers.delete_if{ |c| c.node.dead? } if containers.count == 0 @testlab.ui.stderr.puts("You either have no containers defined or dead nodes!".yellow) else - ZTK::Report.new(:ui => @testlab.ui).spreadsheet(containers, TestLab::Container::STATUS_KEYS.reject{|k| k == :fqdn}) do |container| - OpenStruct.new(container.status.reject{|k,v| k == :fqdn}) + # ZTK::Report.new(:ui => @testlab.ui).spreadsheet(containers, TestLab::Container::STATUS_KEYS.reject{|k| k == :fqdn}) do |container| + ZTK::Report.new(:ui => @testlab.ui).list(containers, TestLab::Container::STATUS_KEYS) do |container| + # OpenStruct.new(container.status.reject{|k,v| k == :fqdn}) + OpenStruct.new(container.status) end end else # ID supplied; show just that item container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first