mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-28 14:50:08 +03:00
bug #274: Added Cluster allocate messages
This commit is contained in:
parent
7ac6121da9
commit
b4c0fa6046
@ -73,7 +73,7 @@ private:
|
||||
* @param clid the id assigned to the cluster
|
||||
* @return the id assigned to the cluster or -1 in case of failure
|
||||
*/
|
||||
int allocate(int * clid, string name, SqlDB *db);
|
||||
int allocate(int * clid, string name, SqlDB *db, string& error_str);
|
||||
|
||||
/**
|
||||
* Returns the xml representation of the given cluster
|
||||
|
@ -170,9 +170,9 @@ public:
|
||||
* @param clid the id assigned to the cluster
|
||||
* @return the id assigned to the cluster or -1 in case of failure
|
||||
*/
|
||||
int allocate_cluster(int * clid, string name)
|
||||
int allocate_cluster(int * clid, const string& name, string& error_str)
|
||||
{
|
||||
return cluster_pool.allocate(clid, name, db);
|
||||
return cluster_pool.allocate(clid, name, db, error_str);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ const string ClusterPool::DEFAULT_CLUSTER_NAME = "default";
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int ClusterPool::allocate(int * clid, string name, SqlDB *db)
|
||||
int ClusterPool::allocate(int * clid, string name, SqlDB *db, string& error_str)
|
||||
{
|
||||
int rc;
|
||||
map<int, string>::iterator it;
|
||||
@ -61,15 +61,15 @@ int ClusterPool::allocate(int * clid, string name, SqlDB *db)
|
||||
|
||||
error_existing_name:
|
||||
oss << "Could not allocate new cluster: Name \""
|
||||
<< name << "\" already exists.";
|
||||
<< name << "\" already exists";
|
||||
|
||||
goto error_common;
|
||||
error_db:
|
||||
oss << "Could not allocate new cluster \"" << name
|
||||
<< "\": Database returned error code " << rc << ".";
|
||||
oss << "Could not allocate new cluster \"" << name;
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
error_str = oss.str();
|
||||
NebulaLog::log("CLUSTER", Log::ERROR, oss);
|
||||
|
||||
*clid = -1;
|
||||
|
@ -27,10 +27,11 @@ void RequestManager::ClusterAllocate::execute(
|
||||
xmlrpc_c::value * const retval)
|
||||
{
|
||||
string session;
|
||||
string error_str;
|
||||
|
||||
string clustername;
|
||||
int id;
|
||||
|
||||
|
||||
const string method_name = "ClusterAllocate";
|
||||
|
||||
int rc;
|
||||
@ -68,7 +69,7 @@ void RequestManager::ClusterAllocate::execute(
|
||||
}
|
||||
|
||||
// Perform the allocation in the hostpool
|
||||
rc = ClusterAllocate::hpool->allocate_cluster(&id, clustername);
|
||||
rc = ClusterAllocate::hpool->allocate_cluster(&id, clustername, error_str);
|
||||
|
||||
if ( rc == -1 )
|
||||
{
|
||||
@ -95,7 +96,8 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_cluster_allocate:
|
||||
oss.str(action_error(method_name, "CREATE", "CLUSTER", -2, rc));
|
||||
oss << action_error(method_name, "CREATE", "CLUSTER", -2, 0);
|
||||
oss << ". " << error_str;
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
@ -31,18 +31,18 @@ void RequestManager::ImagePersistent::execute(
|
||||
string session;
|
||||
|
||||
int iid;
|
||||
bool persistent_flag;
|
||||
bool persistent_flag;
|
||||
int uid;
|
||||
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
|
||||
bool response;
|
||||
|
||||
|
||||
const string method_name = "ImagePersistent";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@ -62,20 +62,20 @@ void RequestManager::ImagePersistent::execute(
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImagePersistent::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
image = ImagePersistent::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
|
||||
{
|
||||
@ -92,22 +92,22 @@ void RequestManager::ImagePersistent::execute(
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get the image locked again
|
||||
image = ImagePersistent::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image = ImagePersistent::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
response = image->persistent(persistent_flag);
|
||||
|
||||
|
||||
if (!response)
|
||||
{
|
||||
goto error_persistent;
|
||||
}
|
||||
|
||||
|
||||
ImagePersistent::ipool->update(image);
|
||||
|
||||
image->unlock();
|
||||
@ -124,20 +124,20 @@ void RequestManager::ImagePersistent::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss.str(authenticate_error(method_name));
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_image_get:
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_authorize:
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_persistent:
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, NULL)
|
||||
<< " Is the image public? An Image cannot be public and persistent.";
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, 0)
|
||||
<< ". Is the image public? An Image cannot be public and persistent.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
@ -31,18 +31,18 @@ void RequestManager::ImagePublish::execute(
|
||||
string session;
|
||||
|
||||
int iid;
|
||||
bool publish_flag;
|
||||
bool publish_flag;
|
||||
int uid;
|
||||
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
|
||||
Image * image;
|
||||
|
||||
|
||||
bool response;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
|
||||
const string method_name = "ImagePublish";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@ -62,20 +62,20 @@ void RequestManager::ImagePublish::execute(
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImagePublish::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
image = ImagePublish::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
|
||||
{
|
||||
@ -92,22 +92,22 @@ void RequestManager::ImagePublish::execute(
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get the image locked again
|
||||
image = ImagePublish::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
image = ImagePublish::ipool->get(iid,true);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
response = image->publish(publish_flag);
|
||||
|
||||
|
||||
if (!response)
|
||||
{
|
||||
goto error_publish;
|
||||
}
|
||||
|
||||
|
||||
ImagePublish::ipool->update(image);
|
||||
|
||||
image->unlock();
|
||||
@ -124,20 +124,20 @@ void RequestManager::ImagePublish::execute(
|
||||
return;
|
||||
|
||||
error_authenticate:
|
||||
oss.str(authenticate_error(method_name));
|
||||
oss.str(authenticate_error(method_name));
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_image_get:
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
oss.str(get_error(method_name, "IMAGE", iid));
|
||||
goto error_common;
|
||||
|
||||
|
||||
error_authorize:
|
||||
oss.str(authorization_error(method_name, "MANAGE", "IMAGE", uid, iid));
|
||||
goto error_common;
|
||||
|
||||
error_publish:
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, NULL)
|
||||
<< " Is the image persistent? An Image cannot be public and persistent.";
|
||||
oss<< action_error(method_name, "MANAGE", "IMAGE", iid, 0)
|
||||
<<". Is the image persistent? An Image cannot be public and persistent.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
Loading…
x
Reference in New Issue
Block a user