mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-01 05:47:01 +03:00
F #2770 Allow updating Image metadata while being copied/saved/imported to the Datastore
Co-authored-by: Christian González <cgonzalez@opennebula.systems>
This commit is contained in:
parent
ac487b5ea9
commit
8b632fbf05
@ -191,6 +191,13 @@ public:
|
||||
return (persistent_img == 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return true if the image is in a locked state
|
||||
*/
|
||||
bool is_locked() const
|
||||
{
|
||||
return state == LOCKED || state == LOCKED_USED || state == LOCKED_USED_PERS;
|
||||
};
|
||||
/**
|
||||
* Check the PERSISTENT attribute in an image Template, if not set the
|
||||
* DEFAULT_IMAGE_PERSISTENT and DEFAULT_IMAGE_PERSISTENT_NEW are check in
|
||||
|
@ -60,7 +60,7 @@ protected:
|
||||
RequestAttributes& att);
|
||||
|
||||
ErrorCode delete_object(int oid, bool recursive,
|
||||
RequestAttributes& att);
|
||||
RequestAttributes& att, AuthRequest::Operation auth);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@ -105,7 +105,7 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, bool recursive, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, recursive, att);
|
||||
return delete_object(oid, recursive, att, auth_op);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -133,7 +133,7 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, bool recursive, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, recursive, att);
|
||||
return delete_object(oid, recursive, att, auth_op);
|
||||
}
|
||||
|
||||
};
|
||||
@ -188,9 +188,12 @@ public:
|
||||
|
||||
ErrorCode request_execute(int oid, RequestAttributes& att)
|
||||
{
|
||||
return delete_object(oid, false, att);
|
||||
return delete_object(oid, false, att, auth_op);
|
||||
};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att);
|
||||
|
||||
protected:
|
||||
|
||||
int drop(PoolObjectSQL * obj, bool resive, RequestAttributes& att);
|
||||
|
@ -223,7 +223,6 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
}
|
||||
|
||||
state = LOCKED; //LOCKED till the ImageManager copies it to the Repository
|
||||
lock_db(-1,-1, PoolObjectSQL::LockStates::ST_USE);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Insert the Image
|
||||
|
@ -17,8 +17,6 @@
|
||||
#include "RequestManagerDelete.h"
|
||||
#include "NebulaUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -66,7 +64,42 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
recursive = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
}
|
||||
|
||||
ErrorCode ec = delete_object(oid, recursive, att);
|
||||
ErrorCode ec = delete_object(oid, recursive, att, auth_op);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
success_response(oid, att);
|
||||
}
|
||||
else
|
||||
{
|
||||
failure_response(ec, att);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
AuthRequest::Operation auth = auth_op;
|
||||
|
||||
//get the image
|
||||
Image* img = static_cast<ImagePool *>(pool)->get_ro(oid);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
att.resp_id = oid;
|
||||
failure_response(NO_EXISTS, att);
|
||||
return;
|
||||
}
|
||||
|
||||
if (img->is_locked())
|
||||
{
|
||||
auth = AuthRequest::ADMIN;
|
||||
}
|
||||
|
||||
img->unlock();
|
||||
|
||||
ErrorCode ec = delete_object(oid, false, att, auth);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
@ -83,10 +116,12 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Request::ErrorCode RequestManagerDelete::delete_object(int oid,
|
||||
bool recursive, RequestAttributes& att)
|
||||
bool recursive, RequestAttributes& att, AuthRequest::Operation auth)
|
||||
{
|
||||
string err;
|
||||
ErrorCode ec = delete_authorization(pool, oid, auth_op, att);
|
||||
ErrorCode ec;
|
||||
|
||||
ec = delete_authorization(pool, oid, auth, att);
|
||||
|
||||
if ( ec != SUCCESS )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user