From eb9a54a930f3f28e49f3ceda89436547b605149d Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 27 Nov 2012 17:40:01 +0100 Subject: [PATCH] feature #1570: add user, password and endpoint to oneacct --- src/cli/one_helper/oneacct_helper.rb | 8 ++++---- src/cli/oneacct | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cli/one_helper/oneacct_helper.rb b/src/cli/one_helper/oneacct_helper.rb index f07d766fdb..ffd08c048f 100644 --- a/src/cli/one_helper/oneacct_helper.rb +++ b/src/cli/one_helper/oneacct_helper.rb @@ -33,10 +33,10 @@ class AcctHelper < OpenNebulaHelper::OneHelper :format => String # TODO Time } - USER = { - :name => "user", + USERFILTER = { + :name => "userfilter", :short => "-u user", - :large => "--user user" , + :large => "--userfilter user" , :description => "User name or id to filter the results", :format => String, :proc => lambda { |o, options| @@ -95,7 +95,7 @@ class AcctHelper < OpenNebulaHelper::OneHelper :description => "Split the output in a table for each VM" } - ACCT_OPTIONS = [START_TIME, END_TIME, USER, GROUP, HOST, XPATH, XML, JSON, SPLIT] + ACCT_OPTIONS = [START_TIME, END_TIME, USERFILTER, GROUP, HOST, XPATH, XML, JSON, SPLIT] ACCT_TABLE = CLIHelper::ShowTable.new("oneacct.yaml", nil) do diff --git a/src/cli/oneacct b/src/cli/oneacct index 97a269c029..178a39db7e 100755 --- a/src/cli/oneacct +++ b/src/cli/oneacct @@ -37,12 +37,17 @@ cmd = CommandParser::CmdParser.new(ARGV) do description "" version OpenNebulaHelper::ONE_VERSION - client = OpenNebulaHelper::OneHelper.get_client({}) + helper=OpenNebulaHelper::OneHelper.new - option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS + before_proc do + helper.set_client(options) + end + + option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS + + OpenNebulaHelper::CLIENT_OPTIONS main do - filter_flag = (options[:user] || VirtualMachinePool::INFO_ALL) + filter_flag = (options[:userfilter] || VirtualMachinePool::INFO_ALL) start_time = options[:start] ? options[:start].to_i : -1 end_time = options[:end] ? options[:end].to_i : -1 @@ -54,7 +59,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do :xpath => options[:xpath] } - pool = OpenNebula::VirtualMachinePool.new(client) + pool = OpenNebula::VirtualMachinePool.new(helper.client) if options[:json] || options[:xml] xml_str = pool.accounting_xml(filter_flag, common_opts)