diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index 61f8678ffb..6cb5a27760 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -100,10 +100,15 @@ module CLIHelper @default_columns = Array.new @ext = ext + @conf = conf instance_eval(&block) end + def helper + @ext + end + def column(name, desc, *conf, &block) column = Hash.new column[:desc] = desc @@ -193,7 +198,16 @@ module CLIHelper end def update_columns(options) + config = YAML.load_file(@conf) + + default = config.delete(:default) + @default_columns = default unless default.empty? + @default_columns = options[:list].collect{|o| o.to_sym} if options[:list] + + @columns.merge!(config) { |key, oldval, newval| + oldval.merge(newval) + } end def header_str diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index 5e22060c9a..dff2e46b22 100755 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -156,13 +156,16 @@ module CommandParser puts print_formatters puts - puts @version if @version + if @version + puts "== LICENSE" + puts @version + end end private def print_options - puts "Options:" + puts "== Options" shown_opts = Array.new opt_format = "#{' '*5}%-25s %s" @@ -186,10 +189,10 @@ module CommandParser end def print_commands - puts "Commands:" + puts "== Commands" - cmd_format5 = "#{' '*5}%s" - cmd_format10 = "#{' '*10}%s" + cmd_format5 = "#{' '*3}%s" + cmd_format10 = "#{' '*6}%s" @commands.each{ |key,value| printf cmd_format5, "* #{key}" puts @@ -221,10 +224,10 @@ module CommandParser end def print_formatters - puts "argument formats:" + puts "== Argument formats" - cmd_format5 = "#{' '*5}%s" - cmd_format10 = "#{' '*10}%s" + cmd_format5 = "#{' '*3}%s" + cmd_format10 = "#{' '*6}%s" @formats.each{ |key,value| printf cmd_format5, "* #{key}" puts diff --git a/src/cli/etc/onevm.yaml b/src/cli/etc/onevm.yaml new file mode 100644 index 0000000000..a4e415d201 --- /dev/null +++ b/src/cli/etc/onevm.yaml @@ -0,0 +1,50 @@ +--- +:ID: + :desc: ONE identifier for Virtual Machine + :size: 4 + +:NAME: + :desc: Name of the Virtual Machine + :size: 15 + :left: true + +:USER: + :desc: Username of the Virtual Machine owner + :size: 8 + :left: true + +:GROUP: + :desc: Group of the Virtual Machine + :size: 8 + :left: true + +:STAT: + :desc: Actual status + :size: 4 + +:CPU: + :desc: CPU percentage used by the VM + :size: 3 + +:MEM: + :desc: Memory used by the VM + :size: 7 + +:HOSTNAME: + :desc: Host where the VM is running + :size: 15 + +:TIME: + :desc: Time since the VM was submitted + :size: 11 + +:default: +- :ID +- :USER +- :GROUP +- :NAME +- :STAT +- :CPU +- :MEM +- :HOSTNAME +- :TIME diff --git a/src/cli/etc/onevnet.yaml b/src/cli/etc/onevnet.yaml new file mode 100644 index 0000000000..b35d75d920 --- /dev/null +++ b/src/cli/etc/onevnet.yaml @@ -0,0 +1,49 @@ +--- +:ID: + :desc: ONE identifier for Virtual Network + :size: 4 + +:NAME: + :desc: Name of the Virtual Network + :size: 15 + :left: true + +:USER: + :desc: Username of the Virtual Network owner + :size: 8 + :left: true + +:GROUP: + :desc: Group of the Virtual Network + :size: 8 + :left: true + +:TYPE: + :desc: Type of Virtual Network + :size: 6 + +:SIZE: + :desc: Size of the Virtual Network + :size: 6 + +:BRIDGE: + :desc: Bridge associated to the Virtual Network + :size: 6 + +:PUBLIC: + :desc: Whether the Virtual Network is public or not + :size: 1 + +:LEASES: + :desc: Number of this Virtual Networks given leases + :size: 7 + +:default: +- :ID +- :USER +- :GROUP +- :NAME +- :TYPE +- :BRIDGE +- :PUBLIC +- :LEASES diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 63739bef51..8283f93b48 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -29,6 +29,12 @@ not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 EOT + if ONE_LOCATION + TABLE_CONF_PATH=ONE_LOCATION+"/etc/cli" + else + TABLE_CONF_PATH="/etc/one/cli" + end + ######################################################################## # Options ######################################################################## diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 939fa68abe..b238f4d877 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -17,6 +17,8 @@ require 'one_helper' class OneVMHelper < OpenNebulaHelper::OneHelper + TABLE_CONF_FILE="#{OpenNebulaHelper::TABLE_CONF_PATH}/onevm.yaml" + def create_resource(template_file, options) template=File.read(template_file) super(template, options) diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index e6b749e4ae..52a8e9a6d2 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -17,6 +17,8 @@ require 'one_helper' class OneVNetHelper < OpenNebulaHelper::OneHelper + TABLE_CONF_FILE="#{OpenNebulaHelper::TABLE_CONF_PATH}/onevnet.yaml" + def create_resource(template_file, options) template=File.read(template_file) super(template, options)