diff --git a/share/linters/.rubocop.yml b/share/linters/.rubocop.yml index 873aadb7c2c..b9bb697d5b9 100644 --- a/share/linters/.rubocop.yml +++ b/share/linters/.rubocop.yml @@ -354,7 +354,6 @@ AllCops: - src/vnm_mad/remotes/lib/vlan.rb - src/vnm_mad/remotes/lib/address.rb - src/cli/command_parser.rb - - src/cli/cli_helper.rb - src/cli/one_helper.rb - src/cli/one_helper/onevmgroup_helper.rb - src/cli/one_helper/onemarket_helper.rb diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index d5c7062cb64..23365b938d5 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -15,356 +15,736 @@ #--------------------------------------------------------------------------- # require 'csv' +require 'highline' +# CLI Helper module CLIHelper + + # CLI general options LIST = { - :name => "list", - :short => "-l x,y,z", - :large => "--list x,y,z", + :name => 'list', + :short => '-l x,y,z', + :large => '--list x,y,z', :format => Array, - :description => "Selects columns to display with list command" + :description => 'Selects columns to display with list command' } LISTCONF = { - :name => "listconf", - :short => "-c conf", - :large => "--listconf conf", + :name => 'listconf', + :short => '-c conf', + :large => '--listconf conf', :format => String, - :description => "Selects a predefined column list" + :description => 'Selects a predefined column list' } CSV_OPT = { - :name => "csv", - :large => "--csv", - :description => "Write table in csv format" + :name => 'csv', + :large => '--csv', + :description => 'Write table in csv format' + } + + CSV_DEL = { + :name => 'csv_del', + :large => '--csv-del del', + :format => String, + :description => 'Set delimiter for csv output' } - #ORDER = { - # :name => "order", - # :short => "-o x,y,z", - # :large => "--order x,y,z", - # :format => Array, - # :description => "Order by these columns, column starting with - means decreasing order" - #} - # FILTER = { - :name => "filter", - :short => "-f x,y,z", - :large => "--filter x,y,z", + :name => 'filter', + :short => '-f x,y,z', + :large => '--filter x,y,z', :format => Array, - :description => "Filter data. An array is specified with\n"<< - " "*31<<"column=value pairs." + :description => "Filter data. An array is specified with\n" << + ' ' * 31 << 'column=value pairs.' } + OPERATOR = { - :name => "operator", - :large => "--operator operator", + :name => 'operator', + :large => '--operator operator', :format => String, - :description => "Logical operator used on filters: AND, OR."<< - " Default: AND." + :description => 'Logical operator used on filters: AND, OR. ' \ + 'Default: AND.' + } + + NO_HEADER = { + :name => 'no_header', + :large => '--no-header', + :description => 'Hides the header of the table' } - - # - #HEADER = { - # :name => "header", - # :short => "-H", - # :large => "--header", - # :description => "Shows the header of the table" - #} DELAY = { - :name => "delay", - :short => "-d x", - :large => "--delay x", + :name => 'delay', + :short => '-d x', + :large => '--delay x', :format => Integer, - :description => "Sets the delay in seconds for top command" + :description => 'Sets the delay in seconds for top command' } NO_PAGER = { - :name => "no_pager", - :large => "--no-pager", - :format => String, - :description => "Disable pagination", - :proc => lambda { |o, options| - ENV['ONE_PAGER'] = 'cat' if File.exists?('/bin/cat') + :name => 'no_pager', + :large => '--no-pager', + :description => 'Disable pagination', + :proc => lambda {|_o, _options| + ENV['ONE_PAGER'] = 'cat' if File.exist?('/bin/cat') } } - #OPTIONS = [LIST, ORDER, FILTER, HEADER, DELAY] - OPTIONS = [LIST, LISTCONF, DELAY, FILTER, OPERATOR, CSV_OPT, NO_PAGER] + ADJUST = { + :name => 'adjust', + :large => '--adjust x,y,z', + :format => Array, + :description => 'Adjust size to not truncate selected columns' + } + + SIZE = { + :name => 'size', + :short => '-s x=size,y=size', + :large => '--size x=size,y=size', + :format => Array, + :description => 'Change the size of selected columns. ' \ + 'For example: ' \ + '$ onevm list --size "name=20" ' \ + 'will make column name size 20.' + } + + EXPAND = { + :name => 'expand', + :large => '--expand [x=prop,y=prop]', + :format => Array, + :description => 'Expands the columns size to fill the terminal. ' \ + 'For example: ' \ + '$onevm list --expand name=0.4,group=0.6 ' \ + 'will expand name 40% and group 60%. ' \ + '$onevm list --expand name,group ' \ + 'will expand name and group based on its size.' \ + '$onevm list --expand will expand all columns.' + } + + NO_EXPAND = { + :name => 'no_expand', + :large => '--no-expand', + :description => 'Disable expand' + } + + OPTIONS = [LIST, + LISTCONF, + DELAY, + FILTER, + OPERATOR, + CSV_OPT, + CSV_DEL, + NO_PAGER, + NO_HEADER, + ADJUST, + SIZE, + EXPAND, + NO_EXPAND] # Sets bold font - def CLIHelper.scr_bold + def self.scr_bold print "\33[1m" end # Sets underline - def CLIHelper.scr_underline + def self.scr_underline print "\33[4m" end # Restore normal font - def CLIHelper.scr_restore + def self.scr_restore print "\33[0m" end # Clears screen - def CLIHelper.scr_cls + def self.scr_cls print "\33[2J\33[H" end # Moves the cursor - def CLIHelper.scr_move(x,y) - print "\33[#{x};#{y}H" - end - - def CLIHelper.scr_red - print "\33[31m" - end - - def CLIHelper.scr_green - print "\33[32m" + # + # @param cord_x [Integer] Coordinate x + # @param cord_y [Integer] Coordinate y + def self.scr_move(cord_x, cord_y) + print "\33[#{cord_x};#{cord_y}H" end - ANSI_RED="\33[31m" - ANSI_GREEN="\33[32m" - ANSI_RESET="\33[0m" - ANSI_YELLOW="\33[33m" + # CLI state colors + ANSI_RED = "\33[31m" + ANSI_GREEN = "\33[32m" + ANSI_RESET = "\33[0m" + ANSI_YELLOW = "\33[33m" - OK_STATES=%w{runn rdy on configured} - BAD_STATES=%w{fail err err error} - REGULAR_STATES=%w{pending} + # CLI states + OK_STATES = %w[runn rdy on configured] + BAD_STATES = %w[fail err err error] + REGULAR_STATES = %w[pending] - def CLIHelper.color_state(stat) + # Set state color + # + # @param stat [String] Current state + def self.color_state(state) if $stdout.tty? - case stat.strip + case state.strip when *OK_STATES - ANSI_GREEN+stat+ANSI_RESET + ANSI_GREEN + state + ANSI_RESET when *BAD_STATES - ANSI_RED+stat+ANSI_RESET + ANSI_RED + state + ANSI_RESET when *REGULAR_STATES - ANSI_YELLOW+stat+ANSI_RESET + ANSI_YELLOW + state + ANSI_RESET else - stat + state end else - stat + state end end # Print header - def CLIHelper.print_header(str, underline=true) + # + # @param str [String] String with header content + # @param underline [Boolean] True to underline the header + def self.print_header(str, underline = true) if $stdout.tty? print_tty_header(str, underline) else print str end + puts end - # Pretty print header - def CLIHelper.print_tty_header(str, underline=true) + # Print pretty header + # + # @param str [String] String with header content + # @param underline [Boolean] True to underline the header + def self.print_tty_header(str, underline = true) scr_bold scr_underline if underline print str scr_restore end + # Show error message and exit with error + # + # @param message [String] Error message to show + def self.fail(message) + STDERR.puts message + + exit(-1) + end + + # Hash with search module HashWithSearch + + # Search inside path + # + # @param path [String] Path to search on def dsearch(path) - stems=path.split('/') - hash=self + stems = path.split('/') + hash = self stems.delete_if {|s| s.nil? || s.empty? } stems.each do |stem| - if Hash===hash + if hash.is_a? Hash if hash[stem] - hash=hash[stem] + hash = hash[stem] else - hash=nil + hash = nil break end else - hash=nil + hash = nil break end end hash end + end + # Show table class ShowTable + require 'yaml' attr_reader :default_columns - def initialize(conf=nil, ext=nil, &block) - @columns = Hash.new - @default_columns = Array.new + # Class constructor + # + # @param conf [String] Configuration file + # @param ext [Helper] Cli helper information + def initialize(conf = nil, ext = nil, &block) + @columns = {} + @default_columns = [] - @ext = ext + @ext = ext @conf = conf instance_eval(&block) end + # Get the helper def helper @ext end + # Fill column attributes + # + # @param name [String] Column name + # @param desc [String] Column description + # @param conf [Array] Configutation attributes def column(name, desc, *conf, &block) - column = Hash.new + column = {} + column[:desc] = desc column[:size] = 5 - conf.each{|c| - if c.instance_of?(Symbol) - column[c]=true - elsif c.instance_of?(Hash) - c.each{|key,value| - column[key]=value - } + + conf.each do |c| + if c.is_a? Symbol + column[c] = true + elsif c.is_a? Hash + c.each do |key, value| + column[key] = value + end end - } + end + column[:proc] = block + @columns[name.to_sym] = column - @default_columns< e - puts e.message + rescue SystemExit, Interrupt, StandardError => e + CLIHelper.fail(e.message) end end + # Show column description def describe_columns - str="%-20s: %-20s" + str = '%-20s: %-20s' @columns.each do |column, d| - puts str % [column, d[:desc]] + puts format(str, column, d[:desc]) + end + end + + # Get maximum string lenght in column + # + # @param index [Integer] Column index to search + # + # @return [Integer] Maximum length + def max_size(index) + sizes = [] + + @res_data.each do |d| + sizes << d[index].size + end + + sizes.max + end + + # Get total size of all columns + # + # @param columns [Array] Array with columns name + # + # @return [Integer] Total size + def total_columns_size(columns) + size = 0 + + columns.each do |c| + size += @columns[c[:name]][:size] + end + + size + end + + # Get columns information + # + # @param columns [Array] Array with columns information + # + # @return [Array] Array with columns objects + def columns_info(columns) + ret = [] + + columns.each do |column| + data = column.to_s.split('=') + + ret << { :name => data[0].upcase.to_sym, :prop => data[1] } end + + ret end + # Print tty header def print_tty_header CLIHelper.print_tty_header(header_str) + puts end private + # Get header in string format + def header_str + @default_columns.collect do |c| + if @columns[c] + format_str(c, c.to_s) + else + CLIHelper.fail("Column #{c} not defined.") + end + end.compact.join(' ') + end + + # Print data in table format + # + # @param data [Array] Array with data to show + # @param options [Hash] Object with CLI user options def print_table(data, options) - if !options[:csv] && !options[:noheader] + @res_data = data_array(data, options) + + update_columns_size(options) + + if !options[:csv] && (!options.key? :no_header) CLIHelper.print_header(header_str) end - data ? print_data(data, options) : puts + if options[:csv] && (!options.key? :no_header) + print_csv_data([@default_columns], options[:csv_del]) + end + + @res_data ? print_data(@res_data, options) : puts end + # Print data + # + # @param data [Array] Array with data to show + # @param options [Hash] Object with CLI user options def print_data(data, options) - ncolumns=@default_columns.length - res_data=data_array(data, options) + if options[:csv] + print_csv_data(data, options[:csv_del]) + else + print_normal_data(data, options[:stat_column]) + end + rescue Errno::EPIPE => e + CLIHelper.fail(e.message) + end + + # Print data in CSV format + # + # @param data [Array] Array with data to show + # @param del [Char] CSV delimiter + def print_csv_data(data, del) + del ? del = del : del = ',' + + data.each do |l| + puts CSV.generate_line(l, :col_sep => del) + end + end + + # Print data in normal format + # + # @param data [Array] Array with data to show + # @param stat_column [String] Name of the state column + def print_normal_data(data, stat_column) + ncolumns = @default_columns.length - if options[:stat_column] - stat_column=@default_columns.index( - options[:stat_column].upcase.to_sym) + if stat_column + stat = stat_column.upcase.to_sym + stat_column = @default_columns.index(stat) else - stat_column=@default_columns.index(:STAT) + stat_column = @default_columns.index(:STAT) end - begin - if options[:csv] - puts CSV.generate_line(@default_columns) if !options[:noheader] - res_data.each {|l| puts CSV.generate_line(l) } - else - res_data.each{|l| - puts (0..ncolumns-1).collect{ |i| - dat=l[i] - col=@default_columns[i] + data.each do |l| + result = [] + + ncolumns.times do |i| + dat = l[i] + col = @default_columns[i] - str=format_str(col, dat) - str=CLIHelper.color_state(str) if i==stat_column + str = format_str(col, dat) - str - }.join(' ').rstrip - } + str = CLIHelper.color_state(str) if i == stat_column + + result << str end - rescue Errno::EPIPE + puts result.join(' ').rstrip end end + # Get data in array format + # + # @param data [Array] Array with data to show + # @param options [Hash] Object with CLI user options + # + # @return [Array] Array with selected columns information def data_array(data, options) - res_data=data.collect {|d| - @default_columns.collect {|c| + res_data = data.collect do |d| + @default_columns.collect do |c| @columns[c][:proc].call(d).to_s if @columns[c] - } - } + end + end if options filter_data!(res_data, options) if options[:filter] - sort_data!(res_data, options[:order]) if options[:order] end res_data end + # Format data as string + # + # @param field [Symbol] Name of the column to format + # @param data [String] Data to format def format_str(field, data) if @columns[field] - minus=( @columns[field][:left] ? "-" : "" ) - size=@columns[field][:size] - if @columns[field][:donottruncate] - return "%#{minus}#{size}s" % [ data.to_s ] + @columns[field][:left] ? minus = '-' : minus = '' + size = @columns[field][:size] + + if @columns[field][:adjust] + format("%#{minus}#{size}s", data.to_s) + else + format("%#{minus}#{size}.#{size}s", data.to_s) end - return "%#{minus}#{size}.#{size}s" % [ data.to_s ] else - exit -1, "Column #{field} not defined." + CLIHelper.fail("Column #{field} not defined.") end end + # Get expand information from configuration files + # + # @return [Array] Array with columns data + def config_expand_data + ret = [] + + @default_columns.each do |column| + expand_c = @columns[column][:expand] + + next unless expand_c + + column = column.to_s.downcase + + ret << "#{column}=#{expand_c}" if expand_c.is_a? Numeric + + ret << column.to_s.downcase unless expand_c.is_a? Numeric + end + + ret + end + + # Get adjust information from configuration files + # + # @return [Array] Array with columns data + def config_adjust_data + ret = [] + + @default_columns.each do |column| + next unless @columns[column][:adjust] + + ret << column.to_s.downcase + end + + ret + end + + # Change the size of expand columns + # + # @param expand_columns [Array] Array with expand columns names + # @param all [Boolean] True to expand all columns + def expand_columns(expand_columns, all = false) + return if expand_columns.empty? + + terminal_size = HighLine::SystemExtensions.terminal_size[0] + + return if terminal_size.nil? + + default_columns = columns_info(@default_columns) + expand_columns = columns_info(expand_columns) + + total_size = total_columns_size(default_columns) + columns_size = total_columns_size(expand_columns) + + terminal_size -= (@default_columns.size - 1) + left_size = terminal_size - total_size + remaining_size = left_size + + return if left_size <= 0 + + expand_columns.each do |c| + column = c[:name] + prop = c[:prop] + + if @columns[column].nil? + CLIHelper.fail("Unknown column #{column}") + end + + if all + prop = @columns[column][:size] / total_size.to_f + elsif !prop + prop = @columns[column][:size] / columns_size.to_f + end + + size = (left_size * prop.to_f).round + + @columns[column][:adjust] = false + @columns[column][:size] += size + + remaining_size -= size + end + + if remaining_size > 0 + # If there is some left space, add it to the last column + @columns[expand_columns[-1][:name]][:size] += remaining_size + end + + return if terminal_size == total_columns_size(default_columns) + + # If there is extra space, sub it from the last column + diff = total_columns_size(default_columns) - terminal_size + + @columns[expand_columns[-1][:name]][:size] -= diff + end + + # Change columns size + # + # @param options [Array] Array with size information for each column + def size_columns(options) + options[:size].each do |column| + data = column.split('=') + column = data[0].upcase.to_sym + size = data[1].to_i + + @columns[column][:adjust] = false + @columns[column][:size] = size + end + end + + # Update columns size information + # + # @param options [Hash] Object with CLI user options + def update_columns_size(options) + adjust = options[:adjust] + + if adjust + adjust += config_adjust_data + else + adjust = config_adjust_data + end + + expand_all = (options.key? :expand) && options[:expand].nil? + expand = !options[:expand].nil? + expand_data = [] + + if expand_all + expand_data = @default_columns + elsif expand + expand_data += options[:expand] + end + + expand_data += config_expand_data + + c_size = options[:size] + + # Update adjust attribute to not truncate the column + # If expand all columns adjust is ignored + unless expand_all + adjust.each do |column| + column = column.upcase.to_sym + size = max_size(@default_columns.index(column)) + + if size && size > @columns[column][:size] + @columns[column][:adjust] = true + @columns[column][:size] = size + end + end + end + + # Update size attribute if size + size_columns(options) if c_size + + # Update size attribute if expand + expand_columns(expand_data) unless (options.key? :no_expand) + end + + # Update columns information + # + # @param options [Hash] Object with CLI user options def update_columns(options) begin - config = YAML.load_file(@conf) + if @conf + config = YAML.load_file(@conf) + else + config = {} + end - default = config.delete(:default) + default = config.delete(:default) || {} default_conf = config.delete(:default_conf) || {} - listconf = options[:listconf] + listconf = options[:listconf] listconf = default_conf[listconf.to_sym] if listconf @@ -381,75 +761,69 @@ def update_columns(options) # Filter show options with available columns @default_columns &= @columns.keys - @columns.merge!(config) { |key, oldval, newval| + @columns.merge!(config) do |_key, oldval, newval| oldval.merge(newval) - } - rescue Exception => e + end + rescue StandardError => e + CLIHelper.fail(e.message) end - @default_columns = options[:list].collect{|o| o.to_sym} if options[:list] - end + return unless options[:list] - def header_str - @default_columns.collect {|c| - if @columns[c] - format_str(c, c.to_s) - else - puts "Column #{c} not defined." - exit -1 - end - }.compact.join(' ') + @default_columns = options[:list].collect {|o| o.to_sym } end + # Filter data + # + # @param data [Array] Array with data to filter + # @param options [Hash] Object with CLI user options def filter_data!(data, options) - # TBD: add more operators - # operators=/(==|=|!=|<|<=|>|>=)/ - operators=/(=|!=)/ - filter = options[:filter] + operators = /(=|!=|<|<=|>|>=)/ + filter = options[:filter] + if options.key?(:operator) - log_operator = options[:operator].upcase + log_operator = options[:operator].upcase else - log_operator = "AND" + log_operator = 'AND' end - stems=filter.map do |s| - m=s.match(/^(.*?)#{operators}(.*?)$/) + stems = filter.map do |s| + m = s.match(/^(.*?)#{operators}(.*?)$/) + if m - left, operator, right=m[1..3] - index=@default_columns.index(left.to_sym) + index = @default_columns.index(m[1].to_sym) if index { - :left => left, - :operator => operator, - :right => right, + :left => m[1], + :operator => m[2], + :right => m[3], :index => index } else - STDERR.puts "Column '#{left}' not found" - exit(-1) + CLIHelper.fail("Column '#{left}' not found") end else - STDERR.puts "Expression '#{s}' incorrect" - exit(-1) + CLIHelper.fail("Expression '#{s}' incorrect") end end data.select! do |d| - pass=true + pass = true stems.each do |s| + s[:operator] == '=' ? op = '==' : op = s[:operator] - if d[s[:index]].public_send(s[:operator] == "=" ? "==" : s[:operator], s[:right]) - if log_operator == "OR" + if d[s[:index]].public_send(op, s[:right]) + if log_operator == 'OR' pass = true + break end else pass = false - if log_operator == "AND" - break - end + + break if log_operator == 'AND' end end @@ -457,6 +831,8 @@ def filter_data!(data, options) end end - # TBD def sort_data! + # TODO: def sort_data!(data, options) + end + end diff --git a/src/cli/etc/oneacct.yaml b/src/cli/etc/oneacct.yaml index e3de19fbe44..24357ec2636 100644 --- a/src/cli/etc/oneacct.yaml +++ b/src/cli/etc/oneacct.yaml @@ -59,4 +59,4 @@ - :CPU - :NETRX - :NETTX -- :DISK \ No newline at end of file +- :DISK diff --git a/src/cli/etc/oneacl.yaml b/src/cli/etc/oneacl.yaml index 8582f4b516d..2722cc11ca6 100644 --- a/src/cli/etc/oneacl.yaml +++ b/src/cli/etc/oneacl.yaml @@ -1,8 +1,9 @@ --- :ID: :desc: To which resource owner the rule applies to - :size: 5 + :size: 4 :right: true + :adjust: true :USER: :desc: To which resource owner the rule applies to diff --git a/src/cli/etc/onecluster.yaml b/src/cli/etc/onecluster.yaml index 8244cff202f..93d873e393e 100644 --- a/src/cli/etc/onecluster.yaml +++ b/src/cli/etc/onecluster.yaml @@ -1,20 +1,22 @@ --- :ID: :desc: ONE identifier for the Cluster - :size: 5 + :size: 4 + :adjust: true :NAME: :desc: Name of the Cluster - :size: 25 + :size: 15 :left: true + :expand: true :HOSTS: :desc: Number of Hosts - :size: 5 + :size: 10 :VNETS: :desc: Number of Networks - :size: 5 + :size: 10 :DATASTORES: :desc: Number of Datastores diff --git a/src/cli/etc/onedatastore.yaml b/src/cli/etc/onedatastore.yaml index ac5cc35acc7..da251a1ee12 100644 --- a/src/cli/etc/onedatastore.yaml +++ b/src/cli/etc/onedatastore.yaml @@ -2,34 +2,36 @@ :ID: :desc: ONE identifier for the Datastore :size: 4 + :adjust: true :USER: :desc: Username of the Datastore owner - :size: 10 + :size: 8 :left: true :GROUP: :desc: Group of the Datastore - :size: 10 + :size: 8 :left: true :NAME: :desc: Name of the Datastore - :size: 13 + :size: 10 :left: true + :expand: true :SIZE: :desc: Total Datastore size - :size: 10 + :size: 6 :AVAIL: :desc: Free Datastore size (%) - :size: 5 + :size: 3 :left: true :CLUSTERS: :desc: Cluster IDs - :size: 12 + :size: 8 :left: true :IMAGES: @@ -43,12 +45,12 @@ :DS: :desc: Datastore driver - :size: 7 + :size: 2 :left: true :TM: :desc: Transfer driver - :size: 7 + :size: 3 :left: true :STAT: @@ -67,4 +69,3 @@ - :DS - :TM - :STAT - diff --git a/src/cli/etc/onegroup.yaml b/src/cli/etc/onegroup.yaml index 2fbf97b1d72..01832bac1a0 100644 --- a/src/cli/etc/onegroup.yaml +++ b/src/cli/etc/onegroup.yaml @@ -2,11 +2,13 @@ :ID: :desc: ONE identifier for the Group :size: 4 + :adjust: true :NAME: :desc: Name of the Group - :size: 29 + :size: 15 :left: true + :expand: true :USERS: :desc: Number of Users in this group diff --git a/src/cli/etc/onehost.yaml b/src/cli/etc/onehost.yaml index b88c52f8953..beaef48412b 100644 --- a/src/cli/etc/onehost.yaml +++ b/src/cli/etc/onehost.yaml @@ -2,15 +2,17 @@ :ID: :desc: ONE identifier for Host :size: 4 + :adjust: true :NAME: :desc: Name of the Host :size: 15 :left: true + :expand: true :CLUSTER: :desc: Name of the Cluster - :size: 9 + :size: 10 :left: true :TVM: @@ -67,7 +69,7 @@ :STAT: :desc: Host status - :size: 6 + :size: 4 :left: true :default: diff --git a/src/cli/etc/oneimage.yaml b/src/cli/etc/oneimage.yaml index 384dcdba495..99141127d60 100644 --- a/src/cli/etc/oneimage.yaml +++ b/src/cli/etc/oneimage.yaml @@ -2,21 +2,23 @@ :ID: :desc: ONE identifier for the Image :size: 4 + :adjust: true :USER: :desc: Username of the Image owner - :size: 10 + :size: 8 :left: true :GROUP: :desc: Group of the Image - :size: 10 + :size: 8 :left: true :NAME: :desc: Name of the Image :size: 15 :left: true + :expand: true :DATASTORE: :desc: Name of the Datastore diff --git a/src/cli/etc/onemarket.yaml b/src/cli/etc/onemarket.yaml index b7608ed26d0..10a7d5248eb 100644 --- a/src/cli/etc/onemarket.yaml +++ b/src/cli/etc/onemarket.yaml @@ -2,21 +2,23 @@ :ID: :desc: ONE identifier for the Marketplace :size: 4 + :adjust: true :USER: :desc: Username of the Marketplace owner - :size: 10 + :size: 8 :left: true :GROUP: :desc: Group of the Marketplace - :size: 10 + :size: 8 :left: true :NAME: :desc: Name of the Marketplace - :size: 30 + :size: 15 :left: true + :expand: true :SIZE: :desc: Marketplace total size @@ -43,4 +45,4 @@ - :AVAIL - :APPS - :MAD -- :ZONE \ No newline at end of file +- :ZONE diff --git a/src/cli/etc/onemarketapp.yaml b/src/cli/etc/onemarketapp.yaml index cd8dc560e86..2fae5e1b0e4 100644 --- a/src/cli/etc/onemarketapp.yaml +++ b/src/cli/etc/onemarketapp.yaml @@ -2,11 +2,13 @@ :ID: :desc: ONE identifier for the MarketPlaceApp :size: 4 + :adjust: true :NAME: :desc: Name of the MarketPlaceApp - :size: 25 + :size: 20 :left: true + :expand: true :VERSION: :desc: Version of the MarketPlaceApp @@ -30,7 +32,7 @@ :MARKET: :desc: Name of the MarketPlace - :size: 20 + :size: 10 :left: true :ZONE: @@ -46,4 +48,4 @@ - :TYPE - :REGTIME - :MARKET -- :ZONE \ No newline at end of file +- :ZONE diff --git a/src/cli/etc/oneprovision.yaml b/src/cli/etc/oneprovision.yaml index ec762989061..501b5680a38 100644 --- a/src/cli/etc/oneprovision.yaml +++ b/src/cli/etc/oneprovision.yaml @@ -5,7 +5,7 @@ :NAME: :desc: Name of the Provision - :size: 25 + :size: 15 :left: true :CLUSTERS: diff --git a/src/cli/etc/onesecgroup.yaml b/src/cli/etc/onesecgroup.yaml index ed2ba2f67b7..8c6e74c2082 100644 --- a/src/cli/etc/onesecgroup.yaml +++ b/src/cli/etc/onesecgroup.yaml @@ -2,20 +2,22 @@ :ID: :desc: ONE identifier for the Security Group :size: 4 + :adjust: true :NAME: :desc: Name of the Security Group - :size: 20 + :size: 15 :left: true + :expand: true :USER: :desc: Username of the Security Group owner - :size: 15 + :size: 8 :left: true :GROUP: :desc: Group of the Security Group - :size: 15 + :size: 8 :left: true :UPDATED: @@ -23,14 +25,13 @@ :size: 8 :left: false - :OUTDATED: :desc: Number of VMs with outdated rules :size: 8 :left: false :ERROR: - :desc: Number of VMs that failed to update rules + :desc: Number of VMs that failed to update rules :size: 8 :left: false diff --git a/src/cli/etc/oneshowback.yaml b/src/cli/etc/oneshowback.yaml index 6624b55288d..790c7d39bb6 100644 --- a/src/cli/etc/oneshowback.yaml +++ b/src/cli/etc/oneshowback.yaml @@ -2,10 +2,11 @@ :UID: :desc: User ID :size: 4 + :adjust: true :USER_NAME: :desc: User name - :size: 12 + :size: 8 :GID: :desc: Group ID @@ -13,7 +14,7 @@ :GROUP_NAME: :desc: Group name - :size: 12 + :size: 8 :VM_ID: :desc: Virtual Machine ID @@ -21,7 +22,7 @@ :VM_NAME: :desc: Virtual Machine name - :size: 12 + :size: 15 :MONTH: :desc: Month @@ -47,4 +48,4 @@ - :MONTH - :YEAR - :HOURS -- :COST \ No newline at end of file +- :COST diff --git a/src/cli/etc/onetemplate.yaml b/src/cli/etc/onetemplate.yaml index 5a78daf446f..99132e4b0b2 100644 --- a/src/cli/etc/onetemplate.yaml +++ b/src/cli/etc/onetemplate.yaml @@ -2,20 +2,22 @@ :ID: :desc: ONE identifier for the Template :size: 4 + :adjust: true :NAME: :desc: Name of the Template - :size: 27 + :size: 15 :left: true + :expand: true :USER: :desc: Username of the Template owner - :size: 15 + :size: 8 :left: true :GROUP: :desc: Group of the Template - :size: 15 + :size: 8 :left: true :REGTIME: diff --git a/src/cli/etc/oneuser.yaml b/src/cli/etc/oneuser.yaml index 3902af11855..9f80a5d8d1a 100644 --- a/src/cli/etc/oneuser.yaml +++ b/src/cli/etc/oneuser.yaml @@ -2,15 +2,17 @@ :ID: :desc: ONE identifier for the User :size: 4 + :adjust: true :NAME: :desc: Name of the User :size: 15 :left: true + :expand: true :GROUP: :desc: Group of the User - :size: 10 + :size: 8 :left: true :AUTH: @@ -20,15 +22,15 @@ :VMS: :desc: Number of VMS - :size: 9 + :size: 10 :MEMORY: :desc: Total memory allocated to user VMs - :size: 17 + :size: 10 :CPU: :desc: Total CPU allocated to user VMs - :size: 11 + :size: 10 :PASSWORD: :desc: Password of the User @@ -42,4 +44,3 @@ - :VMS - :MEMORY - :CPU - diff --git a/src/cli/etc/onevdc.yaml b/src/cli/etc/onevdc.yaml index a8a4d6c32ab..09cffefebdc 100644 --- a/src/cli/etc/onevdc.yaml +++ b/src/cli/etc/onevdc.yaml @@ -1,28 +1,30 @@ --- :ID: :desc: ONE identifier for the VDC - :size: 5 + :size: 4 + :adjust: true :NAME: :desc: Name of the VDC - :size: 30 + :size: 15 :left: true + :expand: true :GROUPS: :desc: Number of Groups - :size: 6 + :size: 8 :CLUSTERS: :desc: Number of Clusters - :size: 8 + :size: 10 :HOSTS: :desc: Number of Hosts - :size: 5 + :size: 10 :VNETS: :desc: Number of Networks - :size: 5 + :size: 10 :DATASTORES: :desc: Number of Datastores @@ -35,4 +37,4 @@ - :CLUSTERS - :HOSTS - :VNETS -- :DATASTORES \ No newline at end of file +- :DATASTORES diff --git a/src/cli/etc/onevm.yaml b/src/cli/etc/onevm.yaml index 088ae5dbd89..d70b523b2f9 100644 --- a/src/cli/etc/onevm.yaml +++ b/src/cli/etc/onevm.yaml @@ -1,12 +1,14 @@ --- :ID: :desc: ONE identifier for Virtual Machine - :size: 6 + :size: 4 + :adjust: true :NAME: :desc: Name of the Virtual Machine :size: 15 :left: true + :expand: true :USER: :desc: Username of the Virtual Machine owner diff --git a/src/cli/etc/onevmgroup.yaml b/src/cli/etc/onevmgroup.yaml index a0f96ff19ee..894d9db50bc 100644 --- a/src/cli/etc/onevmgroup.yaml +++ b/src/cli/etc/onevmgroup.yaml @@ -2,11 +2,13 @@ :ID: :desc: ONE identifier for the VM Group :size: 4 + :adjust: true :NAME: :desc: Name of the VM Group :size: 15 :left: true + :expand: true :USER: :desc: Username of the VM Group owner diff --git a/src/cli/etc/onevnet.yaml b/src/cli/etc/onevnet.yaml index 995fa25e93a..0c5b84c0752 100644 --- a/src/cli/etc/onevnet.yaml +++ b/src/cli/etc/onevnet.yaml @@ -2,21 +2,23 @@ :ID: :desc: ONE identifier for Virtual Network :size: 4 + :adjust: true :USER: :desc: Username of the Virtual Network owner - :size: 15 + :size: 8 :left: true :GROUP: :desc: Group of the Virtual Network - :size: 12 + :size: 8 :left: true :NAME: :desc: Name of the Virtual Network - :size: 19 + :size: 15 :left: true + :expand: true :CLUSTERS: :desc: Cluster IDs diff --git a/src/cli/etc/onevntemplate.yaml b/src/cli/etc/onevntemplate.yaml index 5a78daf446f..99132e4b0b2 100644 --- a/src/cli/etc/onevntemplate.yaml +++ b/src/cli/etc/onevntemplate.yaml @@ -2,20 +2,22 @@ :ID: :desc: ONE identifier for the Template :size: 4 + :adjust: true :NAME: :desc: Name of the Template - :size: 27 + :size: 15 :left: true + :expand: true :USER: :desc: Username of the Template owner - :size: 15 + :size: 8 :left: true :GROUP: :desc: Group of the Template - :size: 15 + :size: 8 :left: true :REGTIME: diff --git a/src/cli/etc/onevrouter.yaml b/src/cli/etc/onevrouter.yaml index 4ccb9028dc8..c30f1b7240d 100644 --- a/src/cli/etc/onevrouter.yaml +++ b/src/cli/etc/onevrouter.yaml @@ -2,20 +2,22 @@ :ID: :desc: ONE identifier for the Virtual Router :size: 4 + :adjust: true :NAME: :desc: Name of the Virtual Router - :size: 27 + :size: 15 :left: true + :expand: true :USER: :desc: Username of the Virtual Router owner - :size: 15 + :size: 8 :left: true :GROUP: :desc: Group of the Virtual Router - :size: 15 + :size: 8 :left: true :default: diff --git a/src/cli/etc/onezone.yaml b/src/cli/etc/onezone.yaml index a7f4d567256..059fb7ddb05 100644 --- a/src/cli/etc/onezone.yaml +++ b/src/cli/etc/onezone.yaml @@ -2,14 +2,17 @@ :CURRENT: :desc: Active Zone :size: 1 + :ID: :desc: ONE identifier for the Zone - :size: 5 + :size: 4 + :adjust: true :NAME: :desc: Name of the Zone - :size: 25 + :size: 15 :left: true + :expand: true :ENDPOINT: :desc: Endpoint of the Zone @@ -19,4 +22,4 @@ - :CURRENT - :ID - :NAME -- :ENDPOINT \ No newline at end of file +- :ENDPOINT diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 1b0e0a13430..d9336f258c4 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -624,7 +624,7 @@ def list_pool_table(table, pool, options, filter_flag) # ------- Rest of the pages in the pool, piped to pager -------- current = size - options[:noheader] = true + options[:no_header] = true loop do rc = pool.get_page(size, current, false) diff --git a/src/cli/one_helper/onesecgroup_helper.rb b/src/cli/one_helper/onesecgroup_helper.rb index fea83e20cde..b9b23ba2d21 100644 --- a/src/cli/one_helper/onesecgroup_helper.rb +++ b/src/cli/one_helper/onesecgroup_helper.rb @@ -157,7 +157,7 @@ def format_resource(secgroup, options = {}) d["ICMPV6_TYPE"] end - column :NETWORK, "", :left, :donottruncate, :size=>35 do |d| + column :NETWORK, "", :left, :adjust, :size=>35 do |d| network = "" if(!d["NETWORK_ID"].nil? && d["NETWORK_ID"] != "") network += "VNet " + d["NETWORK_ID"] @@ -185,7 +185,7 @@ def format_resource(secgroup, options = {}) network end - column :RANGE, "", :left, :donottruncate, :size=>16 do |d| + column :RANGE, "", :left, :adjust, :size=>16 do |d| d["RANGE"] end end.show(rule_list, {}) diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index f13b2e1a646..1a2c4bb29db 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -371,7 +371,7 @@ def format_pool(options) OpenNebulaHelper.period_to_str(dtime, false) end - column :IP, "VM IP addresses", :left, :donottruncate, :size=>15 do |d| + column :IP, "VM IP addresses", :left, :adjust, :size=>15 do |d| OneVMHelper.ip_str(d) end @@ -952,7 +952,7 @@ def format_resource(vm, options = {}) end end - column :IP, "",:left, :donottruncate, :size=>15 do |d| + column :IP, "",:left, :adjust, :size=>15 do |d| d["IP"] end @@ -1037,7 +1037,7 @@ def format_resource(vm, options = {}) d["NETWORK_ID"] end - column :START, "", :left, :donottruncate, :size=>17 do |d| + column :START, "", :left, :adjust, :size=>17 do |d| network = "" if(!d["IP"].nil? && d["IP"] != "") @@ -1049,11 +1049,11 @@ def format_resource(vm, options = {}) network end - column :SIZE, "", :left, :donottruncate, :size=>6 do |d| + column :SIZE, "", :left, :adjust, :size=>6 do |d| d["SIZE"] end - column :" ", "", :left, :donottruncate, :size=>15 do |d| + column :" ", "", :left, :adjust, :size=>15 do |d| d["RANGE"] end @@ -1153,7 +1153,7 @@ def format_resource(vm, options = {}) OpenNebulaHelper.time_to_str(d["DONE"], false) if !d.nil? end - column :"MESSAGE", "", :left, :donottruncate, :size=>35 do |d| + column :"MESSAGE", "", :left, :adjust, :size=>35 do |d| d["MESSAGE"] if !d.nil? end end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten, {}) diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index 11dbca8175f..003f4bd515c 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -296,7 +296,6 @@ def format_resource(vn, options = {}) puts CLIHelper.print_header(str_h1 % ["LEASES"], false) - ar_list = [] if !vn_hash['VNET']['AR_POOL']['AR'].nil? @@ -342,7 +341,7 @@ def format_resource(vn, options = {}) d["IP"]||"-" end - column :IP6, "", :donottruncate, :size=>26 do |d| + column :IP6, "", :adjust, :size=>26 do |d| d["IP6"]||d["IP6_GLOBAL"]||"-" end end.show(leases, {}) diff --git a/src/cli/one_helper/onevrouter_helper.rb b/src/cli/one_helper/onevrouter_helper.rb index ea8bb0d069a..7cd15bafc20 100644 --- a/src/cli/one_helper/onevrouter_helper.rb +++ b/src/cli/one_helper/onevrouter_helper.rb @@ -203,7 +203,7 @@ def format_resource(obj, options = {}) end - column :IP, "",:left, :donottruncate, :size=>15 do |d| + column :IP, "",:left, :adjust, :size=>15 do |d| d["IP"] end end.show(vm_nics,{})