mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-18 19:02:53 +09:00
Merge branch 'feature-203' of opennebula.org:one into feature-203
This commit is contained in:
commit
c267a070b8
37 files changed
+439
-301
No files matched your search
@@ -276,10 +276,11 @@ public:
|
||||
*/
|
||||
enum Operation
|
||||
{
|
||||
CREATE, /** Authorization to create an object (host, vm, net, image)*/
|
||||
DELETE, /** Authorization to delete an object */
|
||||
USE, /** Authorization to use an object */
|
||||
MANAGE /** Authorization to manage an object */
|
||||
CREATE, /** Authorization to create an object (host, vm, net, image)*/
|
||||
DELETE, /** Authorization to delete an object */
|
||||
USE, /** Authorization to use an object */
|
||||
MANAGE, /** Authorization to manage an object */
|
||||
INFO /** Authorization to view an object */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -291,7 +292,8 @@ public:
|
||||
HOST,
|
||||
NET,
|
||||
IMAGE,
|
||||
USER
|
||||
USER,
|
||||
CLUSTER
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+48
-10
@@ -24,8 +24,6 @@
|
||||
#include "VirtualNetworkPool.h"
|
||||
#include "ImagePool.h"
|
||||
|
||||
#include "NebulaLog.h"
|
||||
|
||||
#include <xmlrpc-c/base.hpp>
|
||||
#include <xmlrpc-c/registry.hpp>
|
||||
#include <xmlrpc-c/server_abyss.hpp>
|
||||
@@ -183,10 +181,17 @@ private:
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "[" << method << "]" << " User [" << uid << "] not authorized "
|
||||
<< " to perform " << action << " on " << object
|
||||
<< " [" << id << "]";
|
||||
|
||||
NebulaLog::log("RM",Log::ERROR,oss);
|
||||
<< " to perform " << action << " on " << object;
|
||||
|
||||
|
||||
if ( id != (int)NULL )
|
||||
{
|
||||
oss << " [" << id << "].";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << " Pool";
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@@ -196,9 +201,8 @@ private:
|
||||
ostringstream oss;
|
||||
|
||||
oss << "[" << method << "]" << " User couldn't be authenticated," <<
|
||||
" aborting call";
|
||||
NebulaLog::log("RM",Log::ERROR,oss);
|
||||
|
||||
" aborting call.";
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@@ -209,7 +213,41 @@ private:
|
||||
ostringstream oss;
|
||||
|
||||
oss << "[" << method << "]" << " Error getting " <<
|
||||
object << " [" << id << "]";
|
||||
object;
|
||||
|
||||
if ( id != (int)NULL )
|
||||
{
|
||||
oss << " [" << id << "].";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << " Pool.";
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
static string action_error (const string& method,
|
||||
const string &action,
|
||||
const string &object,
|
||||
int id,
|
||||
int rc)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "[" << method << "]" << " Error trying to " << action << " "
|
||||
<< object;
|
||||
|
||||
if ( id != (int)NULL )
|
||||
{
|
||||
oss << " [" << id << "].";
|
||||
}
|
||||
|
||||
if ( rc != (int)NULL )
|
||||
{
|
||||
oss << " .Returned error code [" << rc << "].";
|
||||
}
|
||||
|
||||
NebulaLog::log("RM",Log::ERROR,oss);
|
||||
|
||||
return oss.str();
|
||||
|
||||
@@ -80,11 +80,12 @@ void AuthRequest::add_auth(Object ob,
|
||||
|
||||
switch (ob)
|
||||
{
|
||||
case VM: oss << "VM:" ; break;
|
||||
case HOST: oss << "HOST:" ; break;
|
||||
case NET: oss << "NET:" ; break;
|
||||
case IMAGE: oss << "IMAGE:" ; break;
|
||||
case USER: oss << "USER:" ; break;
|
||||
case VM: oss << "VM:" ; break;
|
||||
case HOST: oss << "HOST:" ; break;
|
||||
case NET: oss << "NET:" ; break;
|
||||
case IMAGE: oss << "IMAGE:" ; break;
|
||||
case USER: oss << "USER:" ; break;
|
||||
case CLUSTER: oss << "CLUSTER:" ; break;
|
||||
}
|
||||
|
||||
if (op == CREATE) //encode the ob_id, it is a template
|
||||
@@ -123,6 +124,10 @@ void AuthRequest::add_auth(Object ob,
|
||||
case MANAGE:
|
||||
oss << "MANAGE:" ;
|
||||
break;
|
||||
|
||||
case INFO:
|
||||
oss << "INFO:" ;
|
||||
break;
|
||||
}
|
||||
|
||||
oss << owner << ":" << pub;
|
||||
@@ -166,6 +171,10 @@ void AuthRequest::add_auth(Object ob,
|
||||
case MANAGE:
|
||||
auth = owner == uid;
|
||||
break;
|
||||
|
||||
case INFO: // This is for completeness, as the only INFO existing
|
||||
// is for UserPool, and just oneadmin can see it
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ void RequestManager::VirtualMachineAction::execute(
|
||||
VirtualMachine * vm;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualMachineAction";
|
||||
|
||||
NebulaLog::log("ReM",Log::DEBUG,"VirtualMachineAction invoked");
|
||||
|
||||
@@ -150,23 +152,24 @@ error_operation:
|
||||
goto error_common;
|
||||
|
||||
error_vm_get:
|
||||
oss << "The virtual machine " << vid << " does not exists";
|
||||
oss.str(get_error(method_name, "VM", vid));
|
||||
goto error_common;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to perform VM operation";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "VM", rc, vid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false));
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
xmlrpc_c::value_array arrayresult_error(arrayData);
|
||||
|
||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||
|
||||
*retval = arrayresult_error;
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
{
|
||||
string session;
|
||||
string vm_template;
|
||||
|
||||
const string method_name = "VirtualMachineAllocate";
|
||||
|
||||
int vid;
|
||||
int rc;
|
||||
@@ -75,11 +77,11 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_allocate:
|
||||
oss << "Error inserting VM in the database, check oned.log";
|
||||
oss.str(action_error(method_name, "CREATE", "VM", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -29,6 +29,8 @@ void RequestManager::VirtualMachineCancel::execute(
|
||||
// <vid> of the vid to retrieve the information for
|
||||
int vid;
|
||||
int uid;
|
||||
|
||||
const string method_name = "VirtualMachineCancel";
|
||||
|
||||
VirtualMachine * vm;
|
||||
|
||||
@@ -95,15 +97,15 @@ void RequestManager::VirtualMachineCancel::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to canel VM";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "VM", uid, vid));
|
||||
goto error_common;
|
||||
|
||||
error_vm_get:
|
||||
oss << "Error getting vm for cancelling with VID = " << vid;
|
||||
oss.str(get_error(method_name, "VM", vid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -31,6 +31,8 @@ void RequestManager::ClusterAdd::execute(
|
||||
int hid;
|
||||
int clid;
|
||||
int rc;
|
||||
|
||||
const string method_name = "ClusterAdd";
|
||||
|
||||
Host * host;
|
||||
|
||||
@@ -59,8 +61,9 @@ void RequestManager::ClusterAdd::execute(
|
||||
if ( rc != 0 ) // rc == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(rc);
|
||||
|
||||
|
||||
ar.add_auth(AuthRequest::HOST,hid,AuthRequest::MANAGE,0,false);
|
||||
ar.add_auth(AuthRequest::CLUSTER,clid,AuthRequest::USE,0,false);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -101,22 +104,20 @@ void RequestManager::ClusterAdd::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authorized to add hosts to clusters";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to manage HOST";
|
||||
oss.str(authorization_error(method_name, "USE", "CLUSTER", rc, clid));
|
||||
goto error_common;
|
||||
|
||||
error_host_get:
|
||||
oss << "The host " << hid << " does not exists";
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_cluster_add:
|
||||
host->unlock();
|
||||
|
||||
oss << "Can not add host " << hid << " to cluster " << clid <<
|
||||
", returned error code [" << rc << "]";
|
||||
oss.str(action_error(method_name, "USE", "CLUSTER", clid, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -29,8 +29,9 @@ void RequestManager::ClusterAllocate::execute(
|
||||
string session;
|
||||
|
||||
string clustername;
|
||||
|
||||
int id;
|
||||
|
||||
const string method_name = "ClusterAllocate";
|
||||
|
||||
int rc;
|
||||
ostringstream oss;
|
||||
@@ -58,7 +59,7 @@ void RequestManager::ClusterAllocate::execute(
|
||||
{
|
||||
AuthRequest ar(rc);
|
||||
|
||||
ar.add_auth(AuthRequest::HOST,-1,AuthRequest::MANAGE,0,false);
|
||||
ar.add_auth(AuthRequest::CLUSTER,-1,AuthRequest::CREATE,0,false);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -86,16 +87,15 @@ void RequestManager::ClusterAllocate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authorized to add new clusters";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to manage HOST";
|
||||
oss.str(authorization_error(method_name, "CREATE", "CLUSTER", rc, -1));
|
||||
goto error_common;
|
||||
|
||||
error_cluster_allocate:
|
||||
oss << "Can not allocate cluster " << clustername <<
|
||||
" in the ClusterPool, returned error code [" << rc << "]";
|
||||
oss.str(action_error(method_name, "CREATE", "CLUSTER", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -32,6 +32,8 @@ void RequestManager::ClusterDelete::execute(
|
||||
int clid;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
const string method_name = "ClusterDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -56,7 +58,7 @@ void RequestManager::ClusterDelete::execute(
|
||||
{
|
||||
AuthRequest ar(rc);
|
||||
|
||||
ar.add_auth(AuthRequest::HOST,-1,AuthRequest::MANAGE,0,false);
|
||||
ar.add_auth(AuthRequest::CLUSTER,clid,AuthRequest::DELETE,0,false);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -83,16 +85,15 @@ void RequestManager::ClusterDelete::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authorized to delete clusters";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to manage HOST";
|
||||
oss.str(authorization_error(method_name, "DELETE", "CLUSTER", rc, clid));
|
||||
goto error_common;
|
||||
|
||||
error_cluster_delete:
|
||||
oss << "Can not delete cluster with CLID " << clid <<
|
||||
" from the ClusterPool, returned error code [" << rc << "]";
|
||||
oss.str(action_error(method_name, "DELETE", "CLUSTER", clid, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -31,6 +31,8 @@ void RequestManager::ClusterInfo::execute(
|
||||
|
||||
int clid;
|
||||
int rc;
|
||||
|
||||
const string method_name = "ClusterInfo";
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
@@ -73,11 +75,11 @@ void RequestManager::ClusterInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, ClusterInfo call aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_cluster:
|
||||
oss << "Error getting cluster with CLID = " << clid;
|
||||
oss.str(get_error(method_name, "CLUSTER", clid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -28,7 +28,9 @@ void RequestManager::ClusterPoolInfo::execute(
|
||||
{
|
||||
string session;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
const string method_name = "ClusterPoolInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -70,11 +72,11 @@ void RequestManager::ClusterPoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, RequestManagerClusterPoolInfo aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_dump:
|
||||
oss << "Error getting Cluster pool";
|
||||
oss.str(get_error(method_name, "CLUSTER", NULL));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -26,12 +26,14 @@ void RequestManager::ClusterRemove::execute(
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const retval)
|
||||
{
|
||||
string session;
|
||||
string session;
|
||||
|
||||
int hid;
|
||||
int rc;
|
||||
|
||||
const string method_name = "ClusterRemove";
|
||||
|
||||
int hid;
|
||||
int rc;
|
||||
|
||||
Host * host;
|
||||
Host * host;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
@@ -99,26 +101,23 @@ void RequestManager::ClusterRemove::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authorized to remove hosts from clusters";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to manage HOST";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "HOST", rc, -1));
|
||||
goto error_common;
|
||||
|
||||
error_host_get:
|
||||
oss << "The host " << hid << " does not exists";
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_cluster_remove:
|
||||
host->unlock();
|
||||
|
||||
oss << "Can not remove host " << hid << " from its cluster, "
|
||||
<< "returned error code [" << rc << "]";
|
||||
oss.str(action_error(method_name, "MANAGE", "HOST", hid, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ void RequestManager::VirtualMachineDeploy::execute(
|
||||
string vmm_mad;
|
||||
string tm_mad;
|
||||
string vmdir;
|
||||
|
||||
const string method_name = "VirtualMachineDeploy";
|
||||
|
||||
VirtualMachine * vm;
|
||||
Host * host;
|
||||
@@ -138,27 +140,28 @@ void RequestManager::VirtualMachineDeploy::execute(
|
||||
return;
|
||||
|
||||
error_host_get:
|
||||
oss << "The host " << hid << " does not exists";
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_vm_get:
|
||||
oss << "The virtual machine " << vid << " does not exists";
|
||||
oss.str(get_error(method_name, "VM", vid));
|
||||
goto error_common;
|
||||
|
||||
error_state:
|
||||
oss << "Can not deploy VM, wrong state";
|
||||
oss.str(action_error(method_name, "MANAGE", "VM", vid, rc));
|
||||
oss << " Reason: VM in wrong state.";
|
||||
goto error_common_lock;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common_lock;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to deploy VM on host";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "VM", rc, vid));
|
||||
goto error_common_lock;
|
||||
|
||||
error_history:
|
||||
oss << "Can not insert history to deploy VM";
|
||||
oss.str(action_error(method_name, "INSERT HISTORY", "VM", vid, rc));
|
||||
goto error_common_lock;
|
||||
|
||||
error_common_lock:
|
||||
@@ -167,6 +170,8 @@ error_common_lock:
|
||||
error_common:
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false));
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
NebulaLog::log("ReM",Log::ERROR,oss);
|
||||
|
||||
xmlrpc_c::value_array arrayresult_error(arrayData);
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ void RequestManager::HostAllocate::execute(
|
||||
string im_mad_name;
|
||||
string vmm_mad_name;
|
||||
string tm_mad_name;
|
||||
|
||||
const string method_name = "HostAllocate";
|
||||
|
||||
int hid;
|
||||
|
||||
@@ -95,15 +97,15 @@ void RequestManager::HostAllocate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to allocate a new HOST";
|
||||
oss.str(authorization_error(method_name, "CREATE", "HOST", rc, NULL));
|
||||
goto error_common;
|
||||
|
||||
error_host_allocate:
|
||||
oss << "Error inserting HOST in the database, check oned.log";
|
||||
oss.str(action_error(method_name, "CREATE", "HOST", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -32,7 +32,9 @@ void RequestManager::HostDelete::execute(
|
||||
int hid;
|
||||
Host * host;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
const string method_name = "HostDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -89,15 +91,15 @@ void RequestManager::HostDelete::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to delete HOST";
|
||||
oss.str(authorization_error(method_name, "DELETE", "HOST", rc, hid));
|
||||
goto error_common;
|
||||
|
||||
error_host_get:
|
||||
oss << "Error getting host with HID = " <<hid;
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -30,12 +30,14 @@ void RequestManager::HostEnable::execute(
|
||||
|
||||
int hid;
|
||||
int rc;
|
||||
bool enable;
|
||||
bool enable;
|
||||
Host * host;
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "HostEnable";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
|
||||
NebulaLog::log("ReM",Log::DEBUG,"HostEnable method invoked");
|
||||
@@ -97,15 +99,15 @@ void RequestManager::HostEnable::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to enable HOST";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "HOST", rc, hid));
|
||||
goto error_common;
|
||||
|
||||
error_host_get:
|
||||
oss << "Error getting host with HID = " << hid;
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -24,13 +24,15 @@ void RequestManager::HostInfo::execute(
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const retval)
|
||||
{
|
||||
string session;
|
||||
|
||||
int hid;
|
||||
int rc;
|
||||
Host * host;
|
||||
string session;
|
||||
|
||||
int hid;
|
||||
int rc;
|
||||
Host * host;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "HostInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -75,15 +77,14 @@ void RequestManager::HostInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_host_get:
|
||||
oss << "Error getting host with HID = " << hid;
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ void RequestManager::HostPoolInfo::execute(
|
||||
{
|
||||
string session;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
const string method_name = "HostPoolInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -68,11 +70,11 @@ void RequestManager::HostPoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_dump:
|
||||
oss << "Error getting host pool";
|
||||
oss.str(get_error(method_name, "HOST", -1));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -36,6 +36,8 @@ void RequestManager::ImageAllocate::execute(
|
||||
int rc;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImageAllocate";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -49,15 +51,13 @@ void RequestManager::ImageAllocate::execute(
|
||||
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImageAllocate::upool->authenticate(session);
|
||||
uid = ImageAllocate::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
|
||||
rc = ImageAllocate::ipool->allocate(uid,image_template,&iid);
|
||||
|
||||
if ( rc < 0 )
|
||||
@@ -78,18 +78,11 @@ void RequestManager::ImageAllocate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting ImageAllocate call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_allocate:
|
||||
if (rc == -1)
|
||||
{
|
||||
oss << "Error allocating image, check oned.log";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << "Error parsing image template";
|
||||
}
|
||||
oss.str(action_error(method_name, "CREATE", "IMAGE", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -33,10 +33,15 @@ void RequestManager::ImageDelete::execute(
|
||||
int iid;
|
||||
int uid;
|
||||
int rc;
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImageDelete";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -49,21 +54,36 @@ void RequestManager::ImageDelete::execute(
|
||||
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImageDelete::upool->authenticate(session);
|
||||
uid = ImageDelete::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImageDelete::ipool->get(iid,true);
|
||||
|
||||
uid = rc;
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
image->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,iid,AuthRequest::DELETE,0,false);
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::DELETE,
|
||||
image_owner,
|
||||
is_public);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -101,19 +121,20 @@ void RequestManager::ImageDelete::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting ImageDelete call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_image_get:
|
||||
oss << "Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to delete image, aborting ImageDelete call.";
|
||||
oss.str(authorization_error(method_name, "DELETE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_delete:
|
||||
oss << "Cannot delete image, VMs might be running on it.";
|
||||
oss.str(action_error(method_name, "DELETE", "IMAGE", iid, rc));
|
||||
oss << " VMs might be running on it.";
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
@@ -35,9 +35,14 @@ void RequestManager::ImageEnable::execute(
|
||||
int uid;
|
||||
int rc;
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImageEnable";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -50,21 +55,36 @@ void RequestManager::ImageEnable::execute(
|
||||
enable_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImageEnable::upool->authenticate(session);
|
||||
uid = ImageEnable::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
// Get image from the ImagePool
|
||||
image = ImageEnable::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
image->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,iid,AuthRequest::MANAGE,0,false);
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::MANAGE,
|
||||
image_owner,
|
||||
is_public);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -104,20 +124,19 @@ void RequestManager::ImageEnable::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "[ImageEnable] User not authenticated, aborting call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_image_get:
|
||||
oss << "[ImageEnable] Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "[ImageEnable] User not authorized to enable/disable image" <<
|
||||
" attributes, aborting call.";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_enable:
|
||||
oss << "[ImageEnable] Cannot enable/disable image [" << iid << "]";
|
||||
oss.str(action_error(method_name, "ENABLE/DISABLE", "IMAGE", iid, rc));
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
@@ -28,12 +28,14 @@ void RequestManager::ImageInfo::execute(
|
||||
{
|
||||
string session;
|
||||
|
||||
int iid;
|
||||
int uid; // Image owner user id
|
||||
int rc; // Requesting user id
|
||||
Image * image;
|
||||
|
||||
int iid;
|
||||
int uid; // Image owner user id
|
||||
int rc; // Requesting user id
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImageInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -63,23 +65,6 @@ void RequestManager::ImageInfo::execute(
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
//Authorize the operation
|
||||
if ( rc != 0 ) // rc == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(rc);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::USE,
|
||||
0,
|
||||
image->isPublic());
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
oss << *image;
|
||||
|
||||
image->unlock();
|
||||
@@ -97,17 +82,11 @@ void RequestManager::ImageInfo::execute(
|
||||
return;
|
||||
|
||||
error_image_get:
|
||||
oss << "Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Cannot authenticate user, aborting ImageInfo call.";
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to use image with " <<
|
||||
"ID = " << iid << " , ImageInfo call aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ void RequestManager::ImagePoolInfo::execute(
|
||||
int rc;
|
||||
int uid;
|
||||
int filter_flag;
|
||||
|
||||
const string method_name = "ImagePoolInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -44,14 +46,12 @@ void RequestManager::ImagePoolInfo::execute(
|
||||
filter_flag = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
|
||||
// Check if it is a valid user
|
||||
rc = ImagePoolInfo::upool->authenticate(session);
|
||||
uid = ImagePoolInfo::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
|
||||
where_string.str("");
|
||||
|
||||
@@ -68,21 +68,13 @@ void RequestManager::ImagePoolInfo::execute(
|
||||
switch(filter_flag)
|
||||
{
|
||||
case -2:
|
||||
if ( uid != 0 )
|
||||
{
|
||||
goto error_authorization;
|
||||
}
|
||||
// TODO define authentication bug #278
|
||||
// where remains empty.
|
||||
break;
|
||||
case -1:
|
||||
where_string << "UID=" << uid << " OR public = 'YES'";
|
||||
break;
|
||||
default:
|
||||
// Only oneadmin or the user can list a specific user's images.
|
||||
if ( uid != 0 && uid != filter_flag )
|
||||
{
|
||||
goto error_authorization;
|
||||
}
|
||||
where_string << "UID=" << filter_flag;
|
||||
}
|
||||
|
||||
@@ -109,23 +101,18 @@ void RequestManager::ImagePoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, ImagePoolInfo call aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorization:
|
||||
oss << "User not authorized to perform this operation.";
|
||||
goto error_common;
|
||||
|
||||
error_filter_flag:
|
||||
oss << "Incorrect filter_flag, must be >= -2.";
|
||||
goto error_common;
|
||||
|
||||
error_dump:
|
||||
oss << "Error getting image pool";
|
||||
oss.str(get_error(method_name, "IMAGE", -1));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
|
||||
@@ -33,11 +33,15 @@ void RequestManager::ImagePublish::execute(
|
||||
int iid;
|
||||
bool publish_flag;
|
||||
int uid;
|
||||
int rc;
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImagePublish";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -50,32 +54,13 @@ void RequestManager::ImagePublish::execute(
|
||||
publish_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImagePublish::upool->authenticate(session);
|
||||
uid = ImagePublish::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::MANAGE,
|
||||
0,
|
||||
image->isPublic());
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImagePublish::ipool->get(iid,true);
|
||||
|
||||
@@ -84,6 +69,36 @@ void RequestManager::ImagePublish::execute(
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
image->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::MANAGE,
|
||||
image_owner,
|
||||
is_public);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the image locked again
|
||||
image = ImagePublish::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image->publish(publish_flag);
|
||||
|
||||
ImagePublish::ipool->update(image);
|
||||
@@ -102,16 +117,15 @@ void RequestManager::ImagePublish::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "[ImagePublish] User not authenticated, aborting call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_image_get:
|
||||
oss << "[ImagePublish] Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "[ImagePublish] User not authorized to publish/unpublish image" <<
|
||||
", aborting call.";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -34,10 +34,15 @@ void RequestManager::ImageRemoveAttribute::execute(
|
||||
int iid;
|
||||
int uid;
|
||||
int rc;
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "ImageRemoveAttribute";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -50,14 +55,25 @@ void RequestManager::ImageRemoveAttribute::execute(
|
||||
name = xmlrpc_c::value_string(paramList.getString(2));
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImageRemoveAttribute::upool->authenticate(session);
|
||||
uid = ImageRemoveAttribute::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImageRemoveAttribute::ipool->get(iid,true);
|
||||
|
||||
uid = rc;
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
image->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
@@ -67,8 +83,8 @@ void RequestManager::ImageRemoveAttribute::execute(
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::MANAGE,
|
||||
0,
|
||||
image->isPublic());
|
||||
image_owner,
|
||||
is_public);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -105,21 +121,19 @@ void RequestManager::ImageRemoveAttribute::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "[ImageRemoveAttribute] User not authenticated, aborting call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_image_get:
|
||||
oss << "[ImageRemoveAttribute] Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "[ImageRemoveAttribute] User not authorized to remove image" <<
|
||||
" attributes aborting call.";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_remove_attribute:
|
||||
oss << "[ImageRemoveAttribute] Cannot remove attribute with name = "
|
||||
<< name << " for image [" << iid << "]";
|
||||
oss.str(action_error(method_name, "PUBLISH/UNPUBLISH", "IMAGE", iid, rc));
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ void RequestManager::ImageUpdate::execute(
|
||||
string name;
|
||||
string value;
|
||||
int rc;
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
@@ -42,7 +45,8 @@ void RequestManager::ImageUpdate::execute(
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
|
||||
|
||||
const string method_name = "ImageUpdate";
|
||||
|
||||
NebulaLog::log("ReM",Log::DEBUG,"ImageUpdate invoked");
|
||||
|
||||
@@ -52,14 +56,25 @@ void RequestManager::ImageUpdate::execute(
|
||||
value = xmlrpc_c::value_string(paramList.getString(3));
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = ImageUpdate::upool->authenticate(session);
|
||||
uid = ImageUpdate::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImageUpdate::ipool->get(iid,true);
|
||||
|
||||
uid = rc;
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
image->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
@@ -69,8 +84,8 @@ void RequestManager::ImageUpdate::execute(
|
||||
ar.add_auth(AuthRequest::IMAGE,
|
||||
iid,
|
||||
AuthRequest::MANAGE,
|
||||
0,
|
||||
image->isPublic());
|
||||
image_owner,
|
||||
is_public);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
@@ -109,20 +124,19 @@ void RequestManager::ImageUpdate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting ImageUpdate call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_image_get:
|
||||
oss << "Error getting image with ID = " << iid;
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to modify image attributes " <<
|
||||
", aborting ImageUpdate call.";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_update:
|
||||
oss << "Cannot modify image [" << iid << "] attribute with name = " << name;
|
||||
oss.str(action_error(method_name, "UPDATE ATTRIBUTE", "IMAGE", iid, rc));
|
||||
image->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ void RequestManager::VirtualMachineInfo::execute(
|
||||
int vid, rc;
|
||||
VirtualMachine * vm;
|
||||
|
||||
ostringstream oss;
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualMachineInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -74,11 +76,11 @@ void RequestManager::VirtualMachineInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_vm_get:
|
||||
oss << "Error getting VM " << vid;
|
||||
oss.str(get_error(method_name, "VM", vid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -48,6 +48,8 @@ void RequestManager::VirtualMachineMigrate::execute(
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualMachineMigrate";
|
||||
|
||||
NebulaLog::log("ReM",Log::DEBUG,"VirtualMachineMigrate invoked");
|
||||
|
||||
@@ -146,27 +148,28 @@ void RequestManager::VirtualMachineMigrate::execute(
|
||||
|
||||
|
||||
error_host_get:
|
||||
oss << "The host " << hid << " does not exists";
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_vm_get:
|
||||
oss << "The virtual machine " << vid << " does not exists";
|
||||
oss.str(get_error(method_name, "VM", vid));
|
||||
goto error_common;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common_lock;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to migrate VM on host";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "VM", uid, vid));
|
||||
goto error_common_lock;
|
||||
|
||||
error_history:
|
||||
oss << "Can not insert history to migrate VM";
|
||||
oss.str(action_error(method_name, "INSERT HISTORY", "VM", vid, rc));
|
||||
goto error_common_lock;
|
||||
|
||||
error_state:
|
||||
oss << "Can not migrate VM, wrong state";
|
||||
oss.str(action_error(method_name, "MANAGE", "VM", vid, rc));
|
||||
oss << " Reason: VM in wrong state.";
|
||||
goto error_common_lock;
|
||||
|
||||
error_common_lock:
|
||||
|
||||
@@ -37,6 +37,8 @@ void RequestManager::VirtualMachinePoolInfo::execute(
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
|
||||
const string method_name = "VirtualMachinePoolInfo";
|
||||
|
||||
NebulaLog::log("ReM",Log::DEBUG,"VirtualMachinePoolInfo method invoked");
|
||||
|
||||
@@ -86,11 +88,11 @@ void RequestManager::VirtualMachinePoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "Error in user authentication";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_dump:
|
||||
oss << "Error getting the pool info";
|
||||
oss.str(get_error(method_name, "VM", -1));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -37,6 +37,8 @@ void RequestManager::UserAllocate::execute(
|
||||
ostringstream oss;
|
||||
|
||||
User * user;
|
||||
|
||||
const string method_name = "UserAllocate";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -103,20 +105,21 @@ void RequestManager::UserAllocate::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting UserAllocate call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to add new users, aborting UserAllocate call.";
|
||||
oss.str(authorization_error(method_name, "CREATE", "USER", rc, NULL));
|
||||
goto error_common;
|
||||
|
||||
error_duplicate:
|
||||
oss << "Existing user, cannot duplicate.";
|
||||
oss.str(action_error(method_name, "CREATE", "USER", NULL, NULL));
|
||||
oss << " Reason: Existing user, cannot duplicate.";
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_allocate:
|
||||
oss << "Error allocating user.";
|
||||
oss.str(action_error(method_name, "CREATE", "USER", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -26,13 +26,15 @@ void RequestManager::UserDelete::execute(
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const retval)
|
||||
{
|
||||
string session;
|
||||
string session;
|
||||
|
||||
int uid;
|
||||
User * user;
|
||||
int uid;
|
||||
User * user;
|
||||
|
||||
int rc;
|
||||
int rc;
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "UserDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -103,24 +105,24 @@ void RequestManager::UserDelete::execute(
|
||||
return;
|
||||
|
||||
error_oneadmin_deletion:
|
||||
oss << "User oneadmin cannot be deleted";
|
||||
oss.str(action_error(method_name, "DELETE", "USER", uid, NULL));
|
||||
oss << " Reason: Oneadmin cannot be deleted.";
|
||||
goto error_common;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting UserDelete call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to delete user with uid " << uid
|
||||
<< ", aborting UserDelete call.";
|
||||
oss.str(authorization_error(method_name, "DELETE", "USER", rc, uid));
|
||||
goto error_common;
|
||||
|
||||
error_get_user:
|
||||
oss << "Error retrieving user " << uid;
|
||||
oss.str(get_error(method_name, "USER", uid));
|
||||
goto error_common;
|
||||
|
||||
error_delete:
|
||||
oss << "Error deleting user " << uid;
|
||||
oss.str(action_error(method_name, "DELETE", "USER", uid, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "RequestManager.h"
|
||||
#include "NebulaLog.h"
|
||||
|
||||
#include "AuthManager.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -26,8 +28,11 @@ void RequestManager::UserPoolInfo::execute(
|
||||
{
|
||||
string session;
|
||||
|
||||
int rc;
|
||||
int rc;
|
||||
int uid;
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "UserPoolInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -39,15 +44,31 @@ void RequestManager::UserPoolInfo::execute(
|
||||
session = xmlrpc_c::value_string(paramList.getString(0));
|
||||
|
||||
// Only oneadmin can list the whole user pool
|
||||
rc = UserPoolInfo::upool->authenticate(session);
|
||||
uid = UserPoolInfo::upool->authenticate(session);
|
||||
|
||||
if ( rc != 0 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
// Now let's get the info
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::USER,
|
||||
-1,
|
||||
AuthRequest::INFO,
|
||||
0,
|
||||
false);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
// Now let's get the info
|
||||
rc = UserPoolInfo::upool->dump(oss,"");
|
||||
|
||||
if ( rc != 0 )
|
||||
@@ -67,15 +88,18 @@ void RequestManager::UserPoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authorized to pull user pool info. Error code: " << rc;
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss.str(authorization_error(method_name, "INFO", "USER", uid, -1));
|
||||
goto error_common;
|
||||
|
||||
error_dumping:
|
||||
oss << "Error dumping pool info";
|
||||
oss.str(get_error(method_name, "USER", -1));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ void RequestManager::VirtualNetworkAllocate::execute(
|
||||
User * user;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualNetworkAllocate";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -52,7 +54,7 @@ void RequestManager::VirtualNetworkAllocate::execute(
|
||||
|
||||
if ( User::split_secret(session,username,password) != 0 )
|
||||
{
|
||||
goto error_session;
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
// Now let's get the user
|
||||
@@ -86,16 +88,16 @@ void RequestManager::VirtualNetworkAllocate::execute(
|
||||
return;
|
||||
|
||||
|
||||
error_session:
|
||||
oss << "Session information malformed, cannot allocate VirtualNetwork";
|
||||
error_authenticate:
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_get_user:
|
||||
oss << "User not recognized, cannot allocate VirtualNetwork";
|
||||
oss.str(get_error(method_name, "USER", -1));
|
||||
goto error_common;
|
||||
|
||||
error_vn_allocate:
|
||||
oss << "Error allocating VN with template: " << endl << stemplate;
|
||||
oss.str(action_error(method_name, "ALLOCATE", "NET", NULL, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -36,6 +36,8 @@ void RequestManager::VirtualNetworkDelete::execute(
|
||||
|
||||
int rc;
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualNetworkDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -94,19 +96,19 @@ void RequestManager::VirtualNetworkDelete::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting VirtualNetworkDelete call";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to delete Virtual Network with NID = " << nid;
|
||||
oss.str(authorization_error(method_name, "DELETE", "NET", rc, nid));
|
||||
goto error_common;
|
||||
|
||||
error_vn_get:
|
||||
oss << "Error getting Virtual Network with NID = " << nid;
|
||||
oss.str(get_error(method_name, "NET", nid));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
NebulaLog::log ("Rem",Log::ERROR,oss);
|
||||
NebulaLog::log ("ReM",Log::ERROR,oss);
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
@@ -35,6 +35,8 @@ void RequestManager::VirtualNetworkInfo::execute(
|
||||
VirtualNetwork * vn;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualNetworkInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -61,23 +63,6 @@ void RequestManager::VirtualNetworkInfo::execute(
|
||||
goto error_vn_get;
|
||||
}
|
||||
|
||||
//Authorize the operation
|
||||
if ( rc != 0 ) // rc == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(rc);
|
||||
|
||||
ar.add_auth(AuthRequest::NET,
|
||||
nid,
|
||||
AuthRequest::USE,
|
||||
0,
|
||||
vn->isPublic());
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
oss << *vn;
|
||||
|
||||
vn->unlock();
|
||||
@@ -95,19 +80,13 @@ void RequestManager::VirtualNetworkInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, VirtualNetworkInfo call aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_vn_get:
|
||||
oss << "Error getting Virtual Network with NID = " << nid;
|
||||
oss.str(get_error(method_name, "NET", nid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
vn->unlock();
|
||||
oss << "User not authorized to view VirtualNetwork" <<
|
||||
", VirtualNetworkInfo call aborted.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
|
||||
arrayData.push_back(xmlrpc_c::value_string(oss.str()));
|
||||
|
||||
@@ -31,11 +31,13 @@ void RequestManager::VirtualNetworkPoolInfo::execute(
|
||||
ostringstream oss;
|
||||
ostringstream where_string;
|
||||
|
||||
int rc;
|
||||
int rc;
|
||||
int filter_flag;
|
||||
|
||||
User * user;
|
||||
|
||||
|
||||
const string method_name = "VirtualNetworkPoolInfo";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
@@ -61,6 +63,8 @@ void RequestManager::VirtualNetworkPoolInfo::execute(
|
||||
* -1 :: User's VMs
|
||||
* >=0 :: UID User's VMs
|
||||
**/
|
||||
|
||||
// TODO define authorization (bug #278)
|
||||
if (filter_flag == -1)
|
||||
{
|
||||
User::split_secret(session,username,password);
|
||||
@@ -105,15 +109,15 @@ void RequestManager::VirtualNetworkPoolInfo::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, NetworkPoolInfo call aborted.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_get_user:
|
||||
oss << "Error getting user, aborting NetworkPoolInfo call";
|
||||
oss.str(get_error(method_name, "USER", -1));
|
||||
goto error_common;
|
||||
|
||||
error_dump:
|
||||
oss << "Error getting virtual network pool";
|
||||
oss.str(get_error(method_name, "HOST", -1));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
||||
@@ -39,6 +39,8 @@ void RequestManager::VirtualNetworkPublish::execute(
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
const string method_name = "VirtualNetworkPublish";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
xmlrpc_c::value_array * arrayresult;
|
||||
|
||||
@@ -50,15 +52,13 @@ void RequestManager::VirtualNetworkPublish::execute(
|
||||
publish_flag = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
|
||||
// First, we need to authenticate the user
|
||||
rc = VirtualNetworkPublish::upool->authenticate(session);
|
||||
uid = VirtualNetworkPublish::upool->authenticate(session);
|
||||
|
||||
if ( rc == -1 )
|
||||
if ( uid == -1 )
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
|
||||
// Get virtual network from the VirtualNetworkPool
|
||||
vn = VirtualNetworkPublish::vnpool->get(nid,true);
|
||||
|
||||
@@ -102,16 +102,15 @@ void RequestManager::VirtualNetworkPublish::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss << "[VirtualNetworkPublish] User not authenticated, aborting call.";
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
error_vn_get:
|
||||
oss << "[VirtualNetworkPublish] Error getting VN with ID = " << nid;
|
||||
oss.str(get_error(method_name, "NET", nid));
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "[VirtualNetworkPublish] User not authorized to (un)publish VN" <<
|
||||
", aborting call.";
|
||||
oss.str(authorization_error(method_name, "MANAGE", "NET", uid, nid));
|
||||
vn->unlock();
|
||||
goto error_common;
|
||||
|
||||
|
||||
Reference in new issue
Block a user