more cli: Thread -> pmap. exc2warn

This commit is contained in:
Denis Knauf 2024-09-21 14:54:42 +02:00
parent ba7fbed101
commit 9786e145c1
2 changed files with 4 additions and 7 deletions

View file

@ -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').

View file

@ -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').