aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-01-15 19:24:02 +0100
committerAndreas Schneider <asn@cryptomilk.org>2011-01-15 19:24:02 +0100
commitb2cf8360ccc208d492dd93506e9ff96da47eb161 (patch)
treec3206066826ad1dfa43c0bcbd438b69881de0332
parent64cceae169565f186128b62293f51484b0f84552 (diff)
downloadvmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.tar.gz
vmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.tar.xz
vmexec-b2cf8360ccc208d492dd93506e9ff96da47eb161.zip
vmexec: Added more options.
-rwxr-xr-xvmexec51
1 files changed, 33 insertions, 18 deletions
diff --git a/vmexec b/vmexec
index 7d9967d..aa850e0 100755
--- a/vmexec
+++ b/vmexec
@@ -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.