mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #1484: merge all user data in oneacct csv
This commit is contained in:
parent
e49687be51
commit
308484fa54
@ -100,6 +100,10 @@ class AcctHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
|
||||
ACCT_TABLE = CLIHelper::ShowTable.new("oneacct.yaml", nil) do
|
||||
column :UID, "User ID", :size=>4 do |d|
|
||||
d["UID"]
|
||||
end
|
||||
|
||||
column :VID, "Virtual Machine ID", :size=>4 do |d|
|
||||
d["OID"]
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
|
||||
option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS +
|
||||
[OpenNebulaHelper::DESCRIBE, CLIHelper::LIST] +
|
||||
[OpenNebulaHelper::DESCRIBE, CLIHelper::LIST, CLIHelper::CSV] +
|
||||
OpenNebulaHelper::CLIENT_OPTIONS
|
||||
|
||||
main do
|
||||
@ -87,7 +87,10 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
||||
else
|
||||
order_by = Hash.new
|
||||
order_by[:order_by_1] = 'VM/UID'
|
||||
order_by[:order_by_2] = 'VM/ID' if options[:split]
|
||||
|
||||
if options[:split] && !options[:csv]
|
||||
order_by[:order_by_2] = 'VM/ID'
|
||||
end
|
||||
|
||||
acct_hash = pool.accounting(filter_flag,
|
||||
common_opts.merge(order_by))
|
||||
@ -96,6 +99,21 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
||||
exit -1
|
||||
end
|
||||
|
||||
if options[:csv]
|
||||
a=Array.new
|
||||
acct_hash.each do |user_id, value|
|
||||
value['HISTORY_RECORDS']['HISTORY'].each do |l|
|
||||
l['UID']=user_id
|
||||
a << l
|
||||
end
|
||||
end
|
||||
|
||||
cols=AcctHelper::ACCT_TABLE.default_columns
|
||||
AcctHelper::ACCT_TABLE.default(:UID, *cols)
|
||||
|
||||
AcctHelper::ACCT_TABLE.show(a, options)
|
||||
exit(0)
|
||||
end
|
||||
|
||||
if ( start_time != -1 or end_time != -1 )
|
||||
AcctHelper.print_start_end_time_header(start_time, end_time)
|
||||
|
Loading…
x
Reference in New Issue
Block a user