mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-03 01:17:41 +03:00
F OpenNebula/one#6365: Improve oneflow listing commands CLI (#2870)
This commit is contained in:
parent
9b37568548
commit
9d5322fe1d
@ -33,27 +33,17 @@ _complete() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_one_list() {
|
_one_list() {
|
||||||
cmd=$1
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
column="$COL_NAME"
|
col="$COL_NAME"
|
||||||
else
|
else
|
||||||
column=$2
|
col=$2
|
||||||
fi
|
fi
|
||||||
filter=$3
|
|
||||||
|
|
||||||
case "$cmd" in
|
if [ -n "$3" ]; then
|
||||||
oneflow|oneflow-server|oneflow-template)
|
$1 list --no-header --csv -f "$3" -l "$col"
|
||||||
# everything under 4th column, NAME by default
|
else
|
||||||
$cmd list | awk 'NR > 1 {print $4}' # TODO: Implement --csv option for oneflow CLI
|
$1 list --no-header --csv -l "$col"
|
||||||
;;
|
fi
|
||||||
*)
|
|
||||||
if [ -n "$filter" ]; then
|
|
||||||
$cmd list --no-header --csv -f "$filter" -l "$column"
|
|
||||||
else
|
|
||||||
$cmd list --no-header --csv -l "$column"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_one_simple() {
|
_one_simple() {
|
||||||
|
@ -593,7 +593,7 @@ Bash symbols must be escaped on STDIN passing'
|
|||||||
|
|
||||||
OPTIONS = FORMAT, EXTENDED, NUMERIC, KILOBYTES
|
OPTIONS = FORMAT, EXTENDED, NUMERIC, KILOBYTES
|
||||||
|
|
||||||
BACKUP_MODES = %w[FULL INCREMENT]
|
BACKUP_MODES = ['FULL', 'INCREMENT']
|
||||||
|
|
||||||
class OneHelper
|
class OneHelper
|
||||||
|
|
||||||
@ -2323,7 +2323,7 @@ Bash symbols must be escaped on STDIN passing'
|
|||||||
answer = STDIN.readline.chop
|
answer = STDIN.readline.chop
|
||||||
|
|
||||||
answer = initial if answer == ''
|
answer = initial if answer == ''
|
||||||
noanswer = ((answer == '') && optional)
|
noanswer = (answer == '') && optional
|
||||||
end while !noanswer && (answer =~ exp).nil?
|
end while !noanswer && (answer =~ exp).nil?
|
||||||
|
|
||||||
if noanswer
|
if noanswer
|
||||||
@ -2389,7 +2389,7 @@ Bash symbols must be escaped on STDIN passing'
|
|||||||
answer = options[answer.to_i]
|
answer = options[answer.to_i]
|
||||||
end
|
end
|
||||||
|
|
||||||
noanswer = ((answer == '') && optional)
|
noanswer = (answer == '') && optional
|
||||||
end while !noanswer && !options.include?(answer)
|
end while !noanswer && !options.include?(answer)
|
||||||
|
|
||||||
if noanswer
|
if noanswer
|
||||||
|
@ -105,7 +105,10 @@ class OneFlowHelper < OpenNebulaHelper::OneHelper
|
|||||||
elsif options[:yaml]
|
elsif options[:yaml]
|
||||||
[0, array_list.to_yaml(:indent => 4)]
|
[0, array_list.to_yaml(:indent => 4)]
|
||||||
else
|
else
|
||||||
format_service_pool.show(array_list)
|
table = format_service_pool
|
||||||
|
|
||||||
|
table.show(array_list, options)
|
||||||
|
table.describe_columns if options[:describe]
|
||||||
|
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
@ -85,8 +85,11 @@ class OneFlowTemplateHelper < OpenNebulaHelper::OneHelper
|
|||||||
elsif options[:yaml]
|
elsif options[:yaml]
|
||||||
[0, JSON.parse(response.body).to_yaml(:indent => 4)]
|
[0, JSON.parse(response.body).to_yaml(:indent => 4)]
|
||||||
else
|
else
|
||||||
|
table = format_service_template_pool
|
||||||
documents = JSON.parse(response.body)['DOCUMENT_POOL']
|
documents = JSON.parse(response.body)['DOCUMENT_POOL']
|
||||||
format_service_template_pool.show(documents['DOCUMENT'])
|
|
||||||
|
table.show(documents['DOCUMENT'], options)
|
||||||
|
table.describe_columns if options[:describe]
|
||||||
|
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
@ -130,7 +130,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|||||||
List the available services
|
List the available services
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
command :list, list_desc, :options => FORMAT do
|
command :list, list_desc,
|
||||||
|
:options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE] do
|
||||||
helper.list_service_pool(helper.client(options), options)
|
helper.list_service_pool(helper.client(options), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -143,7 +143,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|||||||
List the available Service Templates
|
List the available Service Templates
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
command :list, list_desc, :options => FORMAT do
|
command :list, list_desc,
|
||||||
|
:options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE] do
|
||||||
helper.list_service_template_pool(helper.client(options), options)
|
helper.list_service_template_pool(helper.client(options), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user