1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #662: Add error message to PoolSQL::drop

This commit is contained in:
Carlos Martín 2011-06-08 19:18:12 +02:00
parent a5062dc68d
commit edf3df5671
10 changed files with 25 additions and 37 deletions

View File

@ -108,18 +108,6 @@ public:
return group->update(db);
};
/**
* Drops the Group from the data base. The object mutex SHOULD be
* locked.
* @param objsql a pointer to a Group object
* @return 0 on success.
*/
int drop(PoolObjectSQL * objsql)
{
string err;
return drop(objsql, err);
};
/**
* Drops the Group from the data base. The object mutex SHOULD be
* locked.

View File

@ -121,12 +121,20 @@ public:
* Drops the object's data in the data base. The object mutex SHOULD be
* locked.
* @param objsql a pointer to the object
* @return 0 on success.
* @param error_msg Error reason, if any
* @return 0 on success, -1 DB error
*/
virtual int drop(
PoolObjectSQL * objsql)
virtual int drop(PoolObjectSQL * objsql, string& error_msg)
{
return objsql->drop(db);
int rc = objsql->drop(db);
if ( rc != 0 )
{
error_msg = "SQL DB error";
return -1;
}
return 0;
};
/**

View File

@ -42,13 +42,6 @@ protected:
/* -------------------------------------------------------------------- */
void request_execute(xmlrpc_c::paramList const& _paramList);
/* -------------------------------------------------------------------- */
virtual int drop(PoolObjectSQL * object, string& error_msg)
{
return pool->drop(object);
};
};
@ -138,13 +131,6 @@ public:
};
~GroupDelete(){};
/* -------------------------------------------------------------------- */
int drop(PoolObjectSQL * object, string& error_msg)
{
return static_cast<GroupPool*>(pool)->drop(object, error_msg);
};
};
/* ------------------------------------------------------------------------- */

View File

@ -211,6 +211,7 @@ public:
void drop_and_get()
{
int oid_0, oid_1;
string error_str;
// Allocate two objects
oid_0 = allocate(0);
@ -232,7 +233,7 @@ public:
obj->lock();
// Delete it
pool->drop(obj);
pool->drop(obj, error_str);
if(obj != 0)
{

View File

@ -152,6 +152,7 @@ int GroupPool::drop(PoolObjectSQL * objsql, string& error_msg)
if( rc != 0 )
{
error_msg = "SQL DB error";
rc = -1;
}

View File

@ -207,7 +207,7 @@ public:
group = gpool->get(101, false);
CPPUNIT_ASSERT( group != 0 );
rc = gpool->drop(group);
rc = gpool->drop(group, err);
CPPUNIT_ASSERT( rc == 0 );
// dump the pool

View File

@ -229,10 +229,11 @@ void ImageManagerDriver::protocol(
else if ( action == "RM" )
{
int rc;
string tmp_error;
source = image->get_source();
rc = ipool->drop(image);
rc = ipool->drop(image, tmp_error);
if ( rc < 0 )
{

View File

@ -47,7 +47,7 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList)
group_set = user->get_groups();
}
int rc = drop(object, error_msg);
int rc = pool->drop(object, error_msg);
object->unlock();

View File

@ -412,7 +412,8 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
if ( (img = ipool->get(iid,true)) != 0 )
{
ipool->drop(img);
string tmp_error;
ipool->drop(img, tmp_error);
img->unlock();
}
@ -434,7 +435,8 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
if ( (img = ipool->get(iid,true)) != 0 )
{
ipool->drop(img);
string tmp_error;
ipool->drop(img, tmp_error);
img->unlock();
}

View File

@ -943,6 +943,7 @@ public:
string bridge = "";
vector<int> results;
string tmp_error;
// Allocate a VNet
oid = allocate(0);
@ -952,7 +953,7 @@ public:
CPPUNIT_ASSERT( vn != 0 );
// Drop the VNet
pool->drop(vn);
pool->drop(vn, tmp_error);
// Check that the leases were also dropped
const char * table = "leases";