From ab767a74aa6b1329319609db0a6853d3926ab034 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Tue, 3 Sep 2019 16:59:31 +0200 Subject: [PATCH] B #3628: fix xml paginated list bug (#3640) --- src/cli/one_helper.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index d9336f258c..bf7af371f6 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -191,7 +191,7 @@ EOT :format => Integer, :description => 'The Group ID to instantiate the VM' } - + #NOTE: Other options defined using this array, add new options at the end TEMPLATE_OPTIONS=[ { @@ -674,7 +674,7 @@ EOT def list_pool_xml(pool, options, filter_flag) extended = options.include?(:extended) && options[:extended] - if $stdout.isatty + if $stdout.isatty and (!options.key?:no_pager) size = $stdout.winsize[0] - 1 # ----------- First page, check if pager is needed ------------- @@ -702,6 +702,13 @@ EOT return 0 end + if elements < size + return 0 + elsif !pool.is_paginated? + stop_pager(ppid) + return 0 + end + # ------- Rest of the pages in the pool, piped to pager -------- current = size @@ -712,6 +719,12 @@ EOT current += size + begin + Process.waitpid(ppid, Process::WNOHANG) + rescue Errno::ECHILD + break + end + elements, page = print_page(pool, options) puts page @@ -1061,7 +1074,7 @@ EOT end end - def OpenNebulaHelper.time_to_str(time, print_seconds=true, + def OpenNebulaHelper.time_to_str(time, print_seconds=true, print_hours=true, print_years=false) value = time.to_i