mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #661: Add ShowTable configuration files
This commit is contained in:
parent
263ec3543f
commit
97871ef581
@ -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
|
||||
|
@ -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
|
||||
|
50
src/cli/etc/onevm.yaml
Normal file
50
src/cli/etc/onevm.yaml
Normal file
@ -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
|
49
src/cli/etc/onevnet.yaml
Normal file
49
src/cli/etc/onevnet.yaml
Normal file
@ -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
|
@ -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
|
||||
########################################################################
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user