mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #662: Moved string representation of Auth objects for error printing
This commit is contained in:
parent
25068e4d59
commit
5bde303fc8
@ -127,6 +127,14 @@ protected:
|
||||
*/
|
||||
void failure_response(ErrorCode ec, const string& val);
|
||||
|
||||
/**
|
||||
* Gets a string representation for the Auth object in the
|
||||
* request.
|
||||
* @param ob object for the auth operation
|
||||
* @returns string equivalent of the object
|
||||
*/
|
||||
static string object_name(AuthRequest::Object ob);
|
||||
|
||||
/**
|
||||
* Logs authorization errors
|
||||
* @param action authorization action
|
||||
|
@ -147,6 +147,34 @@ void Request::success_response(const string& val)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string Request::object_name(AuthRequest::Object ob)
|
||||
{
|
||||
switch (ob)
|
||||
{
|
||||
case AuthRequest::VM:
|
||||
return "virtual machine";
|
||||
case AuthRequest::HOST:
|
||||
return "host";
|
||||
case AuthRequest::NET:
|
||||
return "virtual network";
|
||||
case AuthRequest::IMAGE:
|
||||
return "image";
|
||||
case AuthRequest::USER:
|
||||
return "user";
|
||||
case AuthRequest::CLUSTER:
|
||||
return "cluster";
|
||||
case AuthRequest::TEMPLATE:
|
||||
return "virtual machine template";
|
||||
case AuthRequest::GROUP:
|
||||
return "group";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string Request::authorization_error (const string &action,
|
||||
const string &object,
|
||||
int uid,
|
||||
|
@ -27,7 +27,7 @@ string RequestManagerAllocate::allocate_error (const string& error)
|
||||
ostringstream oss;
|
||||
|
||||
oss << "[" << method_name << "]" << " Error allocating a new "
|
||||
<< AuthRequest::object_name(auth_object) << ".";
|
||||
<< object_name(auth_object) << ".";
|
||||
|
||||
if (!error.empty())
|
||||
{
|
||||
@ -45,7 +45,7 @@ string RequestManagerAllocate::allocate_error (char *error)
|
||||
ostringstream oss;
|
||||
|
||||
oss << "[" << method_name << "]" << " Error allocating a new "
|
||||
<< AuthRequest::object_name(auth_object) << ". Parse error";
|
||||
<< object_name(auth_object) << ". Parse error";
|
||||
|
||||
if ( error != 0 )
|
||||
{
|
||||
@ -147,7 +147,7 @@ int VirtualNetworkAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList,
|
||||
string& error_str)
|
||||
{
|
||||
VirtualNetworkPool * vpool = static_cast<VirtualNetworkPool *>(pool);
|
||||
VirtualNetworkTemplate * vtmpl = static_cast<VirtualNetworkTemplate *>(tmpl);
|
||||
VirtualNetworkTemplate * vtmpl=static_cast<VirtualNetworkTemplate *>(tmpl);
|
||||
|
||||
return vpool->allocate(uid, gid, vtmpl, &id, error_str);
|
||||
}
|
||||
@ -175,7 +175,8 @@ int TemplateAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList,
|
||||
string& error_str)
|
||||
{
|
||||
VMTemplatePool * tpool = static_cast<VMTemplatePool *>(pool);
|
||||
VirtualMachineTemplate * ttmpl = static_cast<VirtualMachineTemplate *>(tmpl);
|
||||
|
||||
VirtualMachineTemplate * ttmpl=static_cast<VirtualMachineTemplate *>(tmpl);
|
||||
|
||||
return tpool->allocate(uid, gid, ttmpl, &id, error_str);
|
||||
}
|
||||
@ -238,6 +239,7 @@ int GroupAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
|
||||
string& error_str)
|
||||
{
|
||||
string gname = xmlrpc_c::value_string(paramList.getString(1));
|
||||
|
||||
GroupPool * gpool = static_cast<GroupPool *>(pool);
|
||||
|
||||
return gpool->allocate(uid, gname, &id, error_str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user