1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Merge branch 'master' of git.opennebula.org:one

This commit is contained in:
Tino Vazquez 2012-01-25 18:37:18 +01:00
commit 614bb56f2e
3 changed files with 46 additions and 2 deletions

View File

@ -82,6 +82,20 @@ public:
*/
PoolObjectSQL * get(const string& name, int uid, bool lock);
/**
* Updates the cache name index. Must be called when the owner of an object
* is changed
*
* @param old_name Object's name before the change
* @param old_uid Object's owner ID before the change
* @param new_name Object's name after the change
* @param new_uid Object's owner ID after the change
*/
void update_cache_index(string& old_name,
int old_uid,
string& new_name,
int new_uid);
/**
* Finds a set objects that satisfies a given condition
* @param oids a vector with the oids of the objects.

View File

@ -339,6 +339,32 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid, bool olock)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void PoolSQL::update_cache_index(string& old_name,
int old_uid,
string& new_name,
int new_uid)
{
map<string,PoolObjectSQL *>::iterator index;
lock();
string old_key = key(old_name, old_uid);
string new_key = key(new_name, new_uid);
index = name_pool.find(old_key);
if ( index != name_pool.end() )
{
name_pool.erase(old_key);
name_pool.insert(make_pair(new_key, index->second));
}
unlock();
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void PoolSQL::replace()
{
bool removed = false;

View File

@ -134,11 +134,16 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList,
{
failure_response(NO_EXISTS,get_error(object_name(auth_object),oid),att);
return;
}
}
if ( noid != -1 )
{
string obj_name = object->get_name();
int old_uid = object->get_uid();
object->set_user(noid,nuname);
pool->update_cache_index(obj_name, old_uid, obj_name, noid);
}
if ( ngid != -1 )
@ -273,4 +278,3 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
return;
}