1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

CLI on success does not print anything unless -v is specified (#51)

git-svn-id: http://svn.opennebula.org/one/trunk@249 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Javier Fontán Muiños 2008-11-19 10:21:11 +00:00
parent 129934befc
commit d662ac78a7
4 changed files with 27 additions and 24 deletions

View File

@ -59,13 +59,19 @@ EOT
"Sets the delay in seconds for top", "command") do |o|
@options[:delay]=o
end
opts.on("-v", "--verbose",
"Tells more information if the command",
"is successful") do |o|
@options[:verbose]=true
end
opts.on_tail("-h", "--help", "Shows this help message") do |o|
print_help
exit
end
opts.on_tail("-v", "--version",
opts.on_tail("--version",
"Shows version and copyright information") do |o|
puts text_version
exit

View File

@ -225,6 +225,7 @@ end
onehost_opts=OnehostParse.new
onehost_opts.parse(ARGV)
ops=onehost_opts.options
result=[false, "Unknown error"]
@ -251,20 +252,18 @@ when "delete"
host_id=get_host_id(host, ARGV[0])
result=host.delete(host_id)
if result[0]
puts "Host deleted"
puts "Host deleted" if ops[:verbose]
command_exit 0
end
when "list"
hostlist=HostShow.new(host)
ops=onehost_opts.options
ops[:columns]=ops[:list] if ops[:list]
result=hostlist.list_short(ops)
hostlist.close
when "top"
hostlist=HostShow.new(host)
ops=onehost_opts.options
ops[:columns]=ops[:list] if ops[:list]
result=hostlist.top(ops)
hostlist.close
@ -274,7 +273,7 @@ when "enable"
host_id=get_host_id(host, ARGV[0])
result=host.enable(host_id)
if result[0]
puts "Host enabled"
puts "Host enabled" if ops[:verbose]
command_exit 0
end
@ -283,7 +282,7 @@ when "disable"
host_id=get_host_id(host, ARGV[0])
result=host.disable(host_id)
if result[0]
puts "Host disabled"
puts "Host disabled" if ops[:verbose]
command_exit 0
end

View File

@ -173,6 +173,7 @@ vn=ONE::VN.new(server)
onevn_opts=OneVNParse.new
onevn_opts.parse(ARGV)
ops=onevn_opts.options
result=[false, "Unknown error"]
@ -183,7 +184,7 @@ when "create"
check_parameters("create", 1)
result=vn.allocate(*ARGV)
if result[0]
puts "NID: " + result[1].to_s
puts "NID: " + result[1].to_s if ops[:verbose]
exit 0
end
@ -203,13 +204,12 @@ when "delete"
vn_id=get_vn_id(vn, ARGV[0])
result=vn.delete(vn_id)
if result[0]
puts "Virtual Network deleted"
puts "Virtual Network deleted" if ops[:verbose]
exit 0
end
when "list"
vnlist=VNShow.new(vn)
ops=onevn_opts.options
ops[:columns]=ops[:list] if ops[:list]
result=vnlist.list_short(ops)
vnlist.close

View File

@ -373,6 +373,7 @@ end
onevm_opts=OnevmParse.new
onevm_opts.parse(ARGV)
ops=onevm_opts.options
result=[false, "Unknown error"]
@ -383,7 +384,7 @@ when "submit"
check_parameters("submit", 1)
result=vm.allocate(*ARGV)
if result[0]
puts "ID: " + result[1].to_s
puts "ID: " + result[1].to_s if ops[:verbose]
command_exit 0
end
@ -393,7 +394,7 @@ when "deploy"
host_id=get_host_id(host, ARGV[1])
result=vm.deploy(vm_id, host_id)
if result[0]
puts "Deploying VM"
puts "Deploying VM" if ops[:verbose]
command_exit 0
end
@ -402,7 +403,7 @@ when "shutdown"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.shutdown(vm_id)
if result[0]
puts "Shutting down VM"
puts "Shutting down VM" if ops[:verbose]
command_exit 0
end
@ -412,7 +413,7 @@ when "livemigrate"
host_id=get_host_id(host, ARGV[1])
result=vm.livemigrate(vm_id, host_id)
if result[0]
puts "Migrating VM"
puts "Migrating VM" if ops[:verbose]
command_exit 0
end
@ -422,7 +423,7 @@ when "migrate"
host_id=get_host_id(host, ARGV[1])
result=vm.migrate(vm_id, host_id)
if result[0]
puts "Migrating VM"
puts "Migrating VM" if ops[:verbose]
command_exit 0
end
@ -431,7 +432,7 @@ when "hold"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.hold(vm_id)
if result[0]
puts "Setting VM to hold state"
puts "Setting VM to hold state" if ops[:verbose]
command_exit 0
end
@ -440,7 +441,7 @@ when "release"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.release(vm_id)
if result[0]
puts "Releasing VM"
puts "Releasing VM" if ops[:verbose]
command_exit 0
end
@ -449,7 +450,7 @@ when "stop"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.stop(vm_id)
if result[0]
puts "Stopping VM"
puts "Stopping VM" if ops[:verbose]
command_exit 0
end
@ -457,7 +458,7 @@ when "cancel"
check_parameters("cancel", 1)
result=vm.cancel(*ARGV)
if result[0]
puts "Cancelling VM"
puts "Cancelling VM" if ops[:verbose]
command_exit 0
end
@ -466,7 +467,7 @@ when "suspend"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.suspend(vm_id)
if result[0]
puts "Suspending VM"
puts "Suspending VM" if ops[:verbose]
command_exit 0
end
@ -475,20 +476,18 @@ when "resume"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.resume(vm_id)
if result[0]
puts "Resuming VM"
puts "Resuming VM" if ops[:verbose]
command_exit 0
end
when "list"
vmlist=VmShow.new(vm)
ops=onevm_opts.options
ops[:columns]=ops[:list] if ops[:list]
result=vmlist.list_short(ops)
vmlist.close
when "top"
vmlist=VmShow.new(vm)
ops=onevm_opts.options
ops[:columns]=ops[:list] if ops[:list]
result=vmlist.top(ops)
vmlist.close
@ -508,7 +507,6 @@ when "show_db"
when "history"
vmlist=VmShow.new(vm)
ops=onevm_opts.options
ops[:columns]=ops[:list] if ops[:list]
if ARGV[0]
ids=ARGV.collect {|arg| get_vm_id(vm, arg)}
@ -524,7 +522,7 @@ when "delete"
vm_id=get_vm_id(vm, ARGV[0])
result=vm.delete(vm_id)
if result[0]
puts "VM correctly deleted"
puts "VM correctly deleted" if ops[:verbose]
command_exit 0
end