bin/instalatron-play in instalatron-0.1.3 vs bin/instalatron-play in instalatron-0.1.4

- old
+ new

@@ -1,10 +1,11 @@ #!/usr/bin/env ruby require 'fileutils' require 'instalatron' require 'yaml' require 'mixlib/cli' +require 'logger' def play_session(vm_name, script, custom_seq = nil, key_press_delay = 0) ctrlc_gap = 0 basedir = File.dirname(script) script = YAML.load_file(script) @@ -88,11 +89,25 @@ option :key_press_delay, :long => "--key-press-delay SECS", :description => "Delay between key presses", :default => 0 + + option :nic_config, + :long => "--nic-config CFG", + :description => "VM NIC config (nic:device:mode)" + option :vm_memory, + :long => "--vm-memory MEM", + :description => "VM Memory", + :default => 512 + + option :vm_disk_size, + :long => "--vm-disk-size SIZE", + :description => "VM Disk Size in MB", + :default => 10024 + option :help, :short => "-h", :long => "--help", :description => "Show this message", :on => :tail, @@ -100,10 +115,12 @@ :show_options => true, :exit => 0 end +Log = Logger.new($stdout) + cli = MyCLI.new cli.parse_options vm_name = cli.config[:vm_name] @@ -123,13 +140,22 @@ $stderr.puts "Invalid ISO file.\n\n" usage(cli) end # Create VBox VM first -Instalatron.create_vm :vm_name => vm_name, :iso_file => iso_file, :headless => cli.config[:headless] + +Log.debug "Creating VM #{vm_name}" +Instalatron.create_vm :vm_disk_size => cli.config[:vm_disk_size], :vm_memory => cli.config[:vm_memory], :vm_name => vm_name, :iso_file => iso_file, :headless => cli.config[:headless] +nic_config = cli.config[:nic_config] +if nic_config + nic, device, mode = nic_config.split ':' + Log.debug "Setting nic mode #{nic} #{device} #{mode}" + Instalatron.set_nic_mode(vm_name, nic, device, mode) +end puts "Playing script using VM #{vm_name}\n\n" play_session vm_name, script, cli.config[:custom_sequence], cli.config[:key_press_delay] + if cli.config[:destroy_vm] puts "Unregistering and deleting VM #{vm_name}" Instalatron.destroy_vm(vm_name) end