diff --git a/src/client/ruby/onehost b/src/client/ruby/onehost index 402a785b17..89ca90b3af 100755 --- a/src/client/ruby/onehost +++ b/src/client/ruby/onehost @@ -25,9 +25,9 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end + $: << RUBY_LIB_LOCATION -$: << './lib' require 'OpenNebula' require 'client_utilities' @@ -63,7 +63,9 @@ ShowTableHost={ :name => "FCPU", :desc => "Free cpu percentage", :size => 6, - :proc => lambda {|d,e| d["HOST_SHARE/MAX_CPU"].to_i-d["HOST_SHARE/USED_CPU"].to_i } + :proc => lambda {|d,e| + d["HOST_SHARE/MAX_CPU"].to_i-d["HOST_SHARE/USED_CPU"].to_i + } }, :acpu => { :name => "ACPU", @@ -106,9 +108,6 @@ class HostShow @table=ShowTable.new(ShowTableHost) end - def close - end - def header_host_small scr_bold scr_underline diff --git a/src/client/ruby/oneuser b/src/client/ruby/oneuser index 662f4a8a54..26be8f6dbe 100755 --- a/src/client/ruby/oneuser +++ b/src/client/ruby/oneuser @@ -27,13 +27,12 @@ end $: << RUBY_LIB_LOCATION -$: << "./lib" -#require 'one' require 'OpenNebula' require 'client_utilities' require 'command_parse' + ShowTableUP={ :uid => { :name => "UID", @@ -71,9 +70,6 @@ class UPShow @table=ShowTable.new(ShowTableUP) end - def close - end - def header_up_small scr_bold scr_underline @@ -185,7 +181,6 @@ when "list" uplist=UPShow.new ops[:columns]=ops[:list] if ops[:list] result=uplist.list_short(ops) - uplist.close else userpool=OpenNebula::UserPool.new(get_one_client) userpool.info diff --git a/src/client/ruby/onevm b/src/client/ruby/onevm index 5597e26cd4..68cda75a5e 100755 --- a/src/client/ruby/onevm +++ b/src/client/ruby/onevm @@ -25,17 +25,13 @@ else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" end -$: << './lib' $: << RUBY_LIB_LOCATION -#require 'one' require 'OpenNebula' - require 'client_utilities' require 'command_parse' -require 'profiler' ShowTableVM={ :id => { @@ -169,9 +165,6 @@ class VmShow @table_history=ShowTable.new(ShowTableHistory) end - def close - end - def header_vm_small scr_bold scr_underline @@ -187,24 +180,6 @@ class VmShow scr_restore puts "" end - - def print_vm_long(data) - - str="%-10s: %-20s" - - puts str % ["ID", data["oid"]] - puts str % ["NAME", data["deploy_id"]] - puts str % ["STATE", ONE::VM_STATE[data["state"].to_i]] - puts str % ["LCM_STATE", ONE::LCM_STATE[data["lcm_state"].to_i]] - puts str % ["MEMORY", data["memory"]] - puts str % ["CPU", data["cpu"]] - puts - - str=" %-20s: %-20s" - data.each {|key,value| - puts str % [key, value] if !%w{oid deploy_id state lcm_state memory cpu template_id}.include? key - } - end def list_short(options=nil) res=@vmpool.info() @@ -595,7 +570,6 @@ when "list" ops[:columns]=ops[:list] if ops[:list] result=vmlist.list_short(ops) - vmlist.close else vmpool=OpenNebula::VirtualMachinePool.new(get_one_client, filter_flag.to_i) @@ -607,24 +581,9 @@ when "top" vmlist=VmShow.new(get_one_client) ops[:columns]=ops[:list] if ops[:list] result=vmlist.top(ops) - vmlist.close -when "show_db" - # TODO: delete? - check_parameters("show", 1) - vmlist=VmShow.new(vm) - - if ARGV[0] - vm_id=get_vm_id(vm, ARGV[0]) - result=vmlist.list_long(vm_id) - - vmlist.close - else - result=[false, "You must provide a VM id."] - end when "history" - # TODO: change this to new API vmlist=VmShow.new(get_one_client) ops[:columns]=ops[:list] if ops[:list] if ARGV[0] @@ -634,7 +593,6 @@ when "history" else result=vmlist.list_vm_history_all(ops) end - vmlist.close when "delete" check_parameters("delete", 1) @@ -649,7 +607,6 @@ when "delete" end when "show" - # TODO: change this to the new API check_parameters("get_info", 1) vm_id=get_vm_id(ARGV[0]) @@ -695,43 +652,6 @@ when "show" puts vm.to_xml end - -=begin - result = res = vm.get_info(vm_id) - if res[0] - res[1].gsub!(/^\n/, '') - (normal, template)=res[1].split("Template") - - str="%-15s: %-20s" - normal.each{|line| - (key, value)=line.split(":").collect{|v| v.strip } - case key - when "STATE" - value = ONE::VM_STATE[value.to_i] - when "LCM STATE" - value = ONE::LCM_STATE[value.to_i] - when "START TIME","STOP TIME" - value=Time.at(value.to_i).strftime("%m/%d %H:%M:%S") - end - puts str % [key, value] - } - - puts - puts "....: Template :...." - - str=" %-16s: %-20s" - - template.gsub!(/\@\^\_\^\@/,',') - - template.scan(/^\t*(.*?)=(.*)$/).each{|line| - (key, value)=line - puts str % [key, value] - } - - command_exit 0 - end -=end - else onevm_opts.print_help exit -1 @@ -745,6 +665,3 @@ if OpenNebula.is_error?(result) end - -#command_exit 0 - diff --git a/src/client/ruby/onevnet b/src/client/ruby/onevnet index 3145c40585..7072eb9b4a 100755 --- a/src/client/ruby/onevnet +++ b/src/client/ruby/onevnet @@ -27,13 +27,12 @@ end $: << RUBY_LIB_LOCATION -$: << "./lib" -#require 'one' require 'OpenNebula' require 'client_utilities' require 'command_parse' + ShowTableVN={ :nid => { :name => "NID", @@ -93,13 +92,11 @@ ShowTableVN={ class VNShow def initialize(filter_flag="-2") - @vnpool=OpenNebula::VirtualNetworkPool.new(get_one_client,filter_flag.to_i) + @vnpool=OpenNebula::VirtualNetworkPool.new(get_one_client, + filter_flag.to_i) @table=ShowTable.new(ShowTableVN) end - def close - end - def header_vn_small scr_bold scr_underline @@ -258,18 +255,18 @@ when "delete" when "list" if ARGV[0] case ARGV[0] - when "a", "all" + when "a", "all" + filter_flag="-2" + when "m", "mine" + filter_flag="-1" + else + if !ARGV[0].match(/^[0123456789]+$/) filter_flag="-2" - when "m", "mine" - filter_flag="-1" + ops[:filter_flag]=ARGV[0] else - if !ARGV[0].match(/^[0123456789]+$/) - filter_flag="-2" - ops[:filter_flag]=ARGV[0] - else - filter_flag=ARGV[0] - end + filter_flag=ARGV[0] end + end else filter_flag="-2" end @@ -278,7 +275,6 @@ when "list" vnlist=VNShow.new(filter_flag) ops[:columns]=ops[:list] if ops[:list] result=vnlist.list_short(ops) - vnlist.close else vnpool=OpenNebula::VirtualNetworkPool.new(get_one_client, filter_flag.to_i)