diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-01-15 19:24:02 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-01-15 19:24:02 +0100 |
commit | b2cf8360ccc208d492dd93506e9ff96da47eb161 (patch) | |
tree | c3206066826ad1dfa43c0bcbd438b69881de0332 | |
parent | 64cceae169565f186128b62293f51484b0f84552 (diff) | |
download | vmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.tar.gz vmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.tar.xz vmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.zip |
vmexec: Added more options.
-rwxr-xr-x | vmexec | 51 |
1 files changed, 33 insertions, 18 deletions
@@ -20,6 +20,7 @@ require 'net/telnet' +require 'etc' require 'optparse' require 'ostruct' @@ -35,11 +36,13 @@ class VMExecOpts @options = OpenStruct.new @options.cmds = [] - @options.disk = nil + @options.disk = String.new - @options.user = [] - @options.mem = 512 @options.port = 2222 + @options.user = Etc.getlogin + @options.pwd = String.new + @options.mem = 512 + @options.smp = 1 @options.verbose = false opts = OptionParser.new do |opts| @@ -68,27 +71,39 @@ class VMExecOpts # Optional argument; multi-line description. opts.on("-p", "--port <PORT>", Integer, - "Forward this port on the host side to the ssh port (port", - "22) on the guest side. Must be different for each runvm", - "instance running in parallel to avoid conflicts. The", - "default is $opt_port.", - "To copy files in/out of the guest use a command prefixed", - "with '=' calling scp(1) with the -P option using the port", - "specified here, like this:", - " vmexec img.qcow2 \"=scp -P 2222 file.txt localhost:\"") do |port| + "Forward this port on the host side to the ssh port (port", + "22) on the guest side. Must be different for each runvm", + "instance running in parallel to avoid conflicts.", + "Default is #{@options.port}.", + "To copy files in/out of the guest use a command prefixed", + "with '=' calling scp(1) with the -P option using the port", + "specified here, like this:", + " vmexec img.qcow2 \"= scp -P 2222 file.txt localhost:\"") do |port| @options.port = port end - opts.on("-u", "--user <USER>", - "Name of the account to ssh into in the guest. Defaults to", - "the name of the user invoking runvm on the host.") do |user| + opts.on("-u", "--user <USER>", String, + "Name of the account to ssh into in the guest. Defaults is", + "the name of the user (#{@options.user}) invoking vmexec on the host.") do |user| @options.user = user end - opts.on("-m", "--memory N", - "Amount of memory (in megabytes) to allocate to the guest.", - "Defaults to options..") do |memory| - @options.memory = memory + opts.on("-u", "--password <PASSWORD>", String, + "The password of the account to log into in the guest. This is only", + "for Windows!.") do |passwd| + @options.pwd = passwd + end + + opts.on("-m", "--memory N", Integer, + "Amount of memory (in megabytes) to allocate to the guest.", + "Default is #{@options.mem}") do |mem| + @options.mem = mem + end + + opts.on("--smp N", Integer, + "Number of CPU cores to allocate to the guest.", + "Default is #{@options.smp}") do |smp| + @options.mem = smp end # Boolean switch. |