mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
feature #203: Adding comments, fixing pools accesors in RM
This commit is contained in:
parent
498102b786
commit
f3fc078b6c
@ -173,6 +173,16 @@ private:
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Logs authorization errors
|
||||
* @param method name of the RM method where the error arose
|
||||
* @param action authorization action
|
||||
* @param object object that needs to be authorized
|
||||
* @param uid user that is authorized
|
||||
* @param id id of the object, -1 for Pool
|
||||
* @returns string for logging
|
||||
*/
|
||||
static string authorization_error (const string& method,
|
||||
const string &action,
|
||||
const string &object,
|
||||
@ -180,7 +190,7 @@ private:
|
||||
int id)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "[" << method << "]" << " User [" << uid << "] not authorized "
|
||||
oss << "[" << method << "]" << " User [" << uid << "] not authorized"
|
||||
<< " to perform " << action << " on " << object;
|
||||
|
||||
|
||||
@ -196,6 +206,11 @@ private:
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs authenticate errors
|
||||
* @param method name of the RM method where the error arose
|
||||
* @returns string for logging
|
||||
*/
|
||||
static string authenticate_error (const string& method)
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -205,7 +220,14 @@ private:
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs get object errors
|
||||
* @param method name of the RM method where the error arose
|
||||
* @param object over which the get failed
|
||||
* @param id of the object over which the get failed
|
||||
* @returns string for logging
|
||||
*/
|
||||
static string get_error (const string& method,
|
||||
const string &object,
|
||||
int id)
|
||||
@ -227,6 +249,16 @@ private:
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs action errors
|
||||
* @param method name of the RM method where the error arose
|
||||
* @param action that triggered the error
|
||||
* @param object over which the action was applied
|
||||
* @param id id of the object, -1 for Pool, -2 for no-id objects
|
||||
* (allocate error, parse error)
|
||||
* @param rc returned error code (NULL to ignore)
|
||||
* @returns string for logging
|
||||
*/
|
||||
static string action_error (const string& method,
|
||||
const string &action,
|
||||
const string &object,
|
||||
@ -271,8 +303,14 @@ private:
|
||||
{
|
||||
public:
|
||||
VirtualMachineAllocate(
|
||||
UserPool * _upool):
|
||||
upool(_upool)
|
||||
VirtualMachinePool * _vmpool,
|
||||
VirtualNetworkPool * _vnpool,
|
||||
ImagePool * _ipool,
|
||||
UserPool * _upool):
|
||||
vmpool(_vmpool),
|
||||
vnpool(_vnpool),
|
||||
ipool(_ipool),
|
||||
upool(_upool)
|
||||
{
|
||||
_signature="A:ss";
|
||||
_help="Allocates a virtual machine in the pool";
|
||||
@ -284,6 +322,9 @@ private:
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const retval);
|
||||
private:
|
||||
VirtualMachinePool * vmpool;
|
||||
VirtualNetworkPool * vnpool;
|
||||
ImagePool * ipool;
|
||||
UserPool * upool;
|
||||
};
|
||||
|
||||
@ -294,8 +335,8 @@ private:
|
||||
public:
|
||||
VirtualMachineDeploy(
|
||||
VirtualMachinePool * _vmpool,
|
||||
HostPool * _hpool,
|
||||
UserPool * _upool):
|
||||
HostPool * _hpool,
|
||||
UserPool * _upool):
|
||||
vmpool(_vmpool),
|
||||
hpool(_hpool),
|
||||
upool(_upool)
|
||||
|
@ -214,7 +214,7 @@ void RequestManager::do_action(
|
||||
void RequestManager::register_xml_methods()
|
||||
{
|
||||
xmlrpc_c::methodPtr vm_allocate(new
|
||||
RequestManager::VirtualMachineAllocate(upool));
|
||||
RequestManager::VirtualMachineAllocate(vmpool, vnpool, ipool, upool));
|
||||
|
||||
xmlrpc_c::methodPtr vm_deploy(new
|
||||
RequestManager::VirtualMachineDeploy(vmpool,hpool,upool));
|
||||
|
@ -34,11 +34,6 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
int vid, uid;
|
||||
int rc;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImagePool * ipool = nd.get_ipool();
|
||||
VirtualNetworkPool* vnpool= nd.get_vnpool();
|
||||
VirtualMachinePool* vmpool= nd.get_vmpool();
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@ -96,7 +91,7 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
continue;
|
||||
}
|
||||
|
||||
ipool->authorize_disk(vector,&ar);
|
||||
VirtualMachineAllocate::ipool->authorize_disk(vector,&ar);
|
||||
}
|
||||
|
||||
num = vm_template->get("NIC",vectors);
|
||||
@ -110,7 +105,7 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
continue;
|
||||
}
|
||||
|
||||
vnpool->authorize_nic(vector,&ar);
|
||||
VirtualMachineAllocate::vnpool->authorize_nic(vector,&ar);
|
||||
}
|
||||
|
||||
ar.add_auth(AuthRequest::VM,
|
||||
@ -128,7 +123,7 @@ void RequestManager::VirtualMachineAllocate::execute(
|
||||
//--------------------------------------------------------------------------
|
||||
// Allocate the VirtualMAchine
|
||||
//--------------------------------------------------------------------------
|
||||
rc = vmpool->allocate(uid,vm_template,&vid,false);
|
||||
rc = VirtualMachineAllocate::vmpool->allocate(uid,vm_template,&vid,false);
|
||||
|
||||
if ( rc < 0 )
|
||||
{
|
||||
@ -157,10 +152,10 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_parse:
|
||||
oss.str(action_error(method_name, "PARSE", "VM TEMPLATE",-2,rc));
|
||||
oss << action_error(method_name, "PARSE", "VM TEMPLATE",-2,rc);
|
||||
if (error_msg != 0)
|
||||
{
|
||||
oss << "Reason: " << error_msg;
|
||||
oss << ". Reason: " << error_msg;
|
||||
free(error_msg);
|
||||
}
|
||||
|
||||
|
@ -127,10 +127,10 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_parse:
|
||||
oss.str(action_error(method_name, "PARSE", "IMAGE TEMPLATE",-2,rc));
|
||||
oss << action_error(method_name, "PARSE", "IMAGE TEMPLATE",-2,rc);
|
||||
if (error_msg != 0)
|
||||
{
|
||||
oss << "Reason: " << error_msg;
|
||||
oss << ". Reason: " << error_msg;
|
||||
free(error_msg);
|
||||
}
|
||||
|
||||
|
@ -127,10 +127,10 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_parse:
|
||||
oss.str(action_error(method_name, "PARSE", "VNET TEMPLATE",-2,rc));
|
||||
oss << action_error(method_name, "PARSE", "VNET TEMPLATE",-2,rc);
|
||||
if (error_msg != 0)
|
||||
{
|
||||
oss << "Reason: " << error_msg;
|
||||
oss << ". Reason: " << error_msg;
|
||||
free(error_msg);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user