lib/oscar/command/init_vms.rb in oscar-0.3.0 vs lib/oscar/command/init_vms.rb in oscar-0.3.1

- old
+ new

@@ -10,34 +10,30 @@ @cmd_name = 'oscar init-vms' @masters = [] @agents = [] - @pe_version = '3.0.0' # @todo remove thingy + require 'pe_build/release' + @pe_version = PEBuild::Release::LATEST_VERSION + split_argv end def execute argv = parse_options(parser) - config_dir = Pathname.new(File.join(Dir.getwd, 'config')) + write_configs - vm_config_file = config_dir + 'vms.yaml' - pe_config_file = config_dir + 'pe_build.yaml' - - config_dir.mkpath unless config_dir.exist? - - vm_config_file.open('w') do |fh| - yaml = YAML.dump vms - fh.write(yaml) - end - - pe_config_file.open('w') do |fh| - yaml = YAML.dump pe_build - fh.write(yaml) - end + @env.ui.info( + I18n.t( + 'oscar.command.init_vms.settings', + :masters => @masters.map { |m| " - #{m}" }.join("\n"), + :agents => @agents.map { |m| " - #{m}" }.join("\n"), + :pe_version => @pe_version, + ) + ) end private def parser @@ -56,27 +52,49 @@ end o.on('-p', '--pe-version=val', String, 'The PE version to install on the VMs') do |val| @pe_version = val end + + o.on('-h', '--help', 'Display this help message') do + puts o + exit 0 + end end end - def vms - vm_list = [] + def write_configs + config_dir = Pathname.new(File.join(Dir.getwd, 'config')) + vm_config_file = config_dir + 'vms.yaml' + pe_config_file = config_dir + 'pe_build.yaml' + config_dir.mkpath unless config_dir.exist? - vm_list += @masters.map do |(name, box)| - { + vm_config_file.open('w') do |fh| + yaml = YAML.dump vms + fh.write(yaml) + end + + pe_config_file.open('w') do |fh| + yaml = YAML.dump pe_build + fh.write(yaml) + end + end + + def vms + vm_list = [] + + @masters.each do |(name, box)| + vm_list << { 'name' => name, 'box' => box, 'roles' => ['pe-puppet-master'] } end - vm_list += @agents.map do |(name, box)| - { + @agents.each do |(name, box)| + vm_list << { 'name' => name, 'box' => box, 'roles' => ['pe-puppet-agent'] } end