mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-29 18:50:08 +03:00
Feature #3264: Report errors in VMPool::calculate_showback
This commit is contained in:
parent
215079a8ea
commit
ded633b813
@ -294,12 +294,16 @@ public:
|
||||
* Use -1 to unset
|
||||
* @param end_year Last year (+month) to process. e.g. 2014.
|
||||
* Use -1 to unset
|
||||
* @param error_str Returns the error reason, if any
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
void calculate_showback(
|
||||
int calculate_showback(
|
||||
int start_month,
|
||||
int start_year,
|
||||
int end_month,
|
||||
int end_year);
|
||||
int end_year,
|
||||
string &error_str);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -2232,6 +2232,7 @@ void VirtualMachinePoolCalculateShowback::request_execute(
|
||||
ostringstream oss;
|
||||
string where;
|
||||
int rc;
|
||||
string error_str;
|
||||
|
||||
// TODO: do a better auth? allow any user in the oneadmin group?
|
||||
if ( att.uid != 0 )
|
||||
@ -2242,10 +2243,17 @@ void VirtualMachinePoolCalculateShowback::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
(static_cast<VirtualMachinePool *>(pool))->calculate_showback(
|
||||
start_month, start_year, end_month, end_year);
|
||||
rc = (static_cast<VirtualMachinePool *>(pool))->calculate_showback(
|
||||
start_month, start_year, end_month, end_year, error_str);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
failure_response(AUTHORIZATION,
|
||||
request_error(error_str, ""),
|
||||
att);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: return value?
|
||||
success_response("", att);
|
||||
|
||||
return;
|
||||
|
@ -492,11 +492,12 @@ string put_time(time_t t)
|
||||
}
|
||||
//==============================================================================
|
||||
|
||||
void VirtualMachinePool::calculate_showback(
|
||||
int VirtualMachinePool::calculate_showback(
|
||||
int start_month,
|
||||
int start_year,
|
||||
int end_month,
|
||||
int end_year)
|
||||
int end_year,
|
||||
string &error_str)
|
||||
{
|
||||
vector<xmlNodePtr> nodes;
|
||||
vector<xmlNodePtr>::iterator node_it;
|
||||
@ -788,7 +789,8 @@ void VirtualMachinePool::calculate_showback(
|
||||
|
||||
if ( sql_body == 0 )
|
||||
{
|
||||
// TODO
|
||||
error_str = "Error creating XML body.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_entries == 0)
|
||||
@ -818,7 +820,8 @@ void VirtualMachinePool::calculate_showback(
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
// TODO
|
||||
error_str = "Error writing to DB.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
n_entries = 0;
|
||||
@ -845,7 +848,8 @@ void VirtualMachinePool::calculate_showback(
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
// TODO
|
||||
error_str = "Error writing to DB.";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,4 +869,6 @@ void VirtualMachinePool::calculate_showback(
|
||||
debug << "Time to write to db: " << debug_t_3 - debug_t_2;
|
||||
NebulaLog::log("SHOWBACK", Log::DEBUG, debug);
|
||||
//================================================================*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user