class Topo::Provision::CLI
Attributes
topology[RW]
Public Class Methods
new(argv=[])
click to toggle source
Calls superclass method
# File lib/topo/provision/cli.rb, line 48 def initialize(argv=[]) super() parse_and_validate_args end
Public Instance Methods
parse_and_validate_args()
click to toggle source
# File lib/topo/provision/cli.rb, line 53 def parse_and_validate_args begin parse_options @input_file = cli_arguments()[0] rescue OptionParser::InvalidOption => e STDERR.puts e.message puts opt_parser exit(-1) end if !@input_file STDERR.puts opt_parser exit(-1) end end
redirect_stdout(file)
click to toggle source
# File lib/topo/provision/cli.rb, line 69 def redirect_stdout(file) begin $stdout.reopen(file, "w") rescue => e STDERR.puts "ERROR: Cannot open provisioning output file #{file} - #{e.message}" end end
run()
click to toggle source
# File lib/topo/provision/cli.rb, line 77 def run @topology = Topo::Loader.from_file(@input_file, @config[:format] || "default") # output topo file @topology.to_file(@config[:output_topo]) if(@config[:output_topo]) # redirect generated recipe to file redirect_stdout(@config[:output]) if(@config[:output]) # run generator @generator = Topo::Provision::Generator.new(@topology) action = @config[:action].to_sym @generator.generate_provisioning_recipe(action) end