feature #3826: support for named list configurations

Add a new set of columns in :default_conf and use them with

$ onevm list --listconf user

For example, in the onevm.yaml cli configuration file:

:default_conf:
  :user:
    - :ID
    - :NAME
    - :STAT
    - :UCPU
    - :UMEM
    - :HOST
    - :IP
    - :TIME
This commit is contained in:
Javi Fontan committed 2015-06-05 16:32:39 -04:00
1 parent ced1a29bfb
commit c0ae441f10
2 files changed
+40 -13

No files matched your search

+18 -2
View File
@@ -25,6 +25,14 @@ module CLIHelper
:description => "Selects columns to display with list command"
}
LISTCONF = {
:name => "listconf",
:short => "-c conf",
:large => "--listconf conf",
:format => String,
:description => "Selects a predefined column list"
}
CSV_OPT = {
:name => "csv",
:large => "--csv",
@@ -64,7 +72,7 @@ module CLIHelper
}
#OPTIONS = [LIST, ORDER, FILTER, HEADER, DELAY]
OPTIONS = [LIST, DELAY, FILTER, CSV_OPT]
OPTIONS = [LIST, LISTCONF, DELAY, FILTER, CSV_OPT]
# Sets bold font
def CLIHelper.scr_bold
@@ -320,7 +328,15 @@ module CLIHelper
config = YAML.load_file(@conf)
default = config.delete(:default)
@default_columns = default unless default.empty?
default_conf = config.delete(:default_conf) || {}
listconf = default_conf[options[:listconf].to_sym]
if options[:listconf] && listconf
@default_columns = listconf
else
@default_columns = default unless default.empty?
end
# Filter show options with available columns
@default_columns &= @columns.keys
+22 -11
View File
@@ -1,36 +1,36 @@
---
:ID:
---
:ID:
:desc: ONE identifier for Virtual Machine
:size: 6
:NAME:
:NAME:
:desc: Name of the Virtual Machine
:size: 15
:left: true
:USER:
:USER:
:desc: Username of the Virtual Machine owner
:size: 8
:left: true
:GROUP:
:GROUP:
:desc: Group of the Virtual Machine
:size: 8
:left: true
:STAT:
:STAT:
:desc: Actual status
:size: 4
:UCPU:
:UCPU:
:desc: CPU percentage used by the VM
:size: 4
:UMEM:
:UMEM:
:desc: Memory used by the VM
:size: 7
:HOST:
:HOST:
:desc: Host where the VM is running
:size: 10
:left: true
@@ -40,7 +40,7 @@
:size: 10
:left: true
:TIME:
:TIME:
:desc: Time since the VM was submitted
:size: 10
@@ -49,7 +49,7 @@
:left: true
:size: 15
:default:
:default:
- :ID
- :USER
- :GROUP
@@ -59,3 +59,14 @@
- :UMEM
- :HOST
- :TIME
:default_conf:
:user:
- :ID
- :NAME
- :STAT
- :UCPU
- :UMEM
- :HOST
- :IP
- :TIME