diff --git a/lib/pve/cli/base.rb b/lib/pve/cli/base.rb index 3b244a9..1c5dcc9 100644 --- a/lib/pve/cli/base.rb +++ b/lib/pve/cli/base.rb @@ -27,8 +27,7 @@ def cli_base node_opt( node). each( &push). flat_map {|n| [ n.method(:lxc), n.method(:qemu) ] }. - flat_pmap {|m| m.call }. - each {|n| n.value.each &push } + peach {|m| exc2warn( nil) { m.call.each &push } } end }). opt( :sort, '-s', '--sort=COLUMNS', "Sort by COLUMNs eg hn for host and name ([s]tatus, h[a], [i]d, [n]ame (default), [h]ost, [u]ptime, [c]pu, [m]em, [d]isk)", default: 'n'). diff --git a/lib/pve/cli/qm.rb b/lib/pve/cli/qm.rb index 0635c8d..f8b7e0e 100644 --- a/lib/pve/cli/qm.rb +++ b/lib/pve/cli/qm.rb @@ -5,8 +5,8 @@ def cli_qm connect nodes = Proxmox::Node.all nodes = nodes.select {|n| node == n.name } if node - nodes.flat_map do |n| - n.qemu.map {|c| c.vmid.to_i } + nodes.flat_pmap do |n| + exc2warn( []) { n.qemu.map {|c| c.vmid.to_i } } end.sort.each {|c| puts c } } @@ -53,9 +53,7 @@ def cli_qm qm_cli.cmd( :status, "Lists VMs with status", aliases: [nil], &lambda {|target=nil, sort: nil, node: nil, status: nil, tags: nil| hosting_table target: target, status: status, sort: sort, tags: tags do |push| - node_opt( node).lazy. - flat_map {|n| [ Thread.new( n, &:qemu) ] }. - each {|n| n.value.each &push } + node_opt( node).flat_pmap( &:qemu).peach &push end }). opt( :sort, '-s', '--sort=COLUMNS', "Sort by COLUMNs eg hn for host and name ([s]tatus, h[a], [i]d, [n]ame (default), [h]ost, [u]ptime, [c]pu, [m]em, [d]isk)", default: 'n').