mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'feature-407' of dsa-research.org:one into feature-407
This commit is contained in:
commit
7b113d0c09
@ -82,10 +82,12 @@ int ImagePool::allocate (
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "NAME is already taken by image " << img_aux->get_oid() << ".";
|
||||
oss << "NAME is already taken by IMAGE " << img_aux->get_oid() << ".";
|
||||
error_str = oss.str();
|
||||
|
||||
*oid = -1;
|
||||
|
||||
delete img;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ const char * VirtualNetwork::db_names = "oid, name, body, uid";
|
||||
|
||||
const char * VirtualNetwork::db_bootstrap = "CREATE TABLE IF NOT EXISTS"
|
||||
" network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256),"
|
||||
" body TEXT, uid INTEGER, UNIQUE(name))";
|
||||
" body TEXT, uid INTEGER, UNIQUE(name,uid))";
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -77,10 +77,30 @@ int VirtualNetworkPool::allocate (
|
||||
string& error_str)
|
||||
{
|
||||
VirtualNetwork * vn;
|
||||
VirtualNetwork * vn_aux;
|
||||
string name;
|
||||
|
||||
vn = new VirtualNetwork(uid, user_name, vn_template);
|
||||
|
||||
*oid = PoolSQL::allocate(vn, error_str);
|
||||
// Check for duplicates
|
||||
vn->get_template_attribute("NAME", name);
|
||||
vn_aux = get(name,uid,false);
|
||||
|
||||
if( vn_aux != 0 )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "NAME is already taken by NET " << vn_aux->get_oid() << ".";
|
||||
error_str = oss.str();
|
||||
|
||||
*oid = -1;
|
||||
|
||||
delete vn;
|
||||
}
|
||||
else
|
||||
{
|
||||
*oid = PoolSQL::allocate(vn, error_str);
|
||||
}
|
||||
|
||||
return *oid;
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ public:
|
||||
|
||||
void duplicates()
|
||||
{
|
||||
int rc, oid_0, oid_1;
|
||||
int rc, oid_0, oid_1, oid_2, oid_3;
|
||||
VirtualNetworkPoolFriend * vnpool =
|
||||
static_cast<VirtualNetworkPoolFriend *>(pool);
|
||||
VirtualNetwork * vnet;
|
||||
@ -414,15 +414,15 @@ public:
|
||||
CPPUNIT_ASSERT( rc == oid_1 );
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
|
||||
// With different user ID
|
||||
rc = vnpool->allocate(uids[1], user_names[1], templates[0], &oid_1);
|
||||
CPPUNIT_ASSERT( rc == oid_1 );
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
// Same VNet, with different user ID
|
||||
rc = vnpool->allocate(uids[1], user_names[1], templates[0], &oid_2);
|
||||
CPPUNIT_ASSERT( rc == oid_2 );
|
||||
CPPUNIT_ASSERT( rc == 1 );
|
||||
|
||||
// Insert a different template, with the same user ID
|
||||
rc = vnpool->allocate(uids[1], user_names[1], templates[1], &oid_1);
|
||||
CPPUNIT_ASSERT( rc == oid_1 );
|
||||
CPPUNIT_ASSERT( rc == 1 );
|
||||
rc = vnpool->allocate(uids[1], user_names[1], templates[1], &oid_3);
|
||||
CPPUNIT_ASSERT( rc == oid_3 );
|
||||
CPPUNIT_ASSERT( rc == 2 );
|
||||
|
||||
|
||||
// Make sure the table contains only one vnet with name[0]
|
||||
@ -434,8 +434,9 @@ public:
|
||||
|
||||
ret = pool->search(results, table, where);
|
||||
CPPUNIT_ASSERT(ret == 0);
|
||||
CPPUNIT_ASSERT(results.size() == 1);
|
||||
CPPUNIT_ASSERT(results.size() == 2);
|
||||
CPPUNIT_ASSERT(results.at(0) == oid_0);
|
||||
CPPUNIT_ASSERT(results.at(1) == oid_2);
|
||||
|
||||
// Get the vnet and check it, to make sure the user id was not rewritten
|
||||
vnet = vnpool->get(oid_0, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user