mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-16 09:43:18 +09:00
1 parent
d68fa4bba8
commit
a088af7d3e
3 files changed
+72
-1
No files matched your search
@@ -1,5 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $ONE_LOCATION ]; then
|
||||
echo "ONE_LOCATION not defined."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
ONEDCONF_LOCATION="$ONE_LOCATION/etc/oned.conf"
|
||||
|
||||
if [ -f $ONEDCONF_LOCATION ]; then
|
||||
echo "$ONEDCONF_LOCATION has to be overwritten, move it to a safe place."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
cp oned.conf $ONEDCONF_LOCATION
|
||||
|
||||
export ONE_XMLRPC=http://localhost:2666/RPC2
|
||||
|
||||
|
||||
./test.sh ClusterTest
|
||||
./test.sh HostTest
|
||||
./test.sh ImageTest
|
||||
|
||||
@@ -30,13 +30,30 @@ int VMTemplatePool::allocate (
|
||||
int * oid,
|
||||
string& error_str)
|
||||
{
|
||||
VMTemplate * vm_template;
|
||||
VMTemplate * vm_template;
|
||||
VMTemplate * vm_template_aux = 0;
|
||||
string name;
|
||||
ostringstream oss;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Build a new VMTemplate object
|
||||
// ------------------------------------------------------------------------
|
||||
vm_template = new VMTemplate(-1, uid, user_name, template_contents);
|
||||
|
||||
// Check name
|
||||
vm_template->get_template_attribute("NAME", name);
|
||||
|
||||
if ( !name.empty() )
|
||||
{
|
||||
// Check for duplicates
|
||||
vm_template_aux = get(name,uid,false);
|
||||
|
||||
if( vm_template_aux != 0 )
|
||||
{
|
||||
goto error_duplicated;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Insert the Object in the pool
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -44,4 +61,16 @@ int VMTemplatePool::allocate (
|
||||
*oid = PoolSQL::allocate(vm_template, error_str);
|
||||
|
||||
return *oid;
|
||||
|
||||
|
||||
error_duplicated:
|
||||
oss << "NAME is already taken by TEMPLATE "
|
||||
<< vm_template_aux->get_oid() << ".";
|
||||
|
||||
delete vm_template;
|
||||
|
||||
*oid = -1;
|
||||
error_str = oss.str();
|
||||
|
||||
return *oid;
|
||||
}
|
||||
@@ -109,6 +109,7 @@ class VMTemplatePoolTest : public PoolTest
|
||||
CPPUNIT_TEST ( update );
|
||||
CPPUNIT_TEST ( get_using_name );
|
||||
CPPUNIT_TEST ( wrong_get_name );
|
||||
CPPUNIT_TEST ( duplicates );
|
||||
CPPUNIT_TEST ( public_attribute );
|
||||
CPPUNIT_TEST ( dump );
|
||||
CPPUNIT_TEST ( dump_where );
|
||||
@@ -313,6 +314,30 @@ public:
|
||||
CPPUNIT_ASSERT( obj == 0 );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void duplicates()
|
||||
{
|
||||
int rc, oid;
|
||||
VMTemplatePoolFriend * tpool = static_cast<VMTemplatePoolFriend*>(pool);
|
||||
|
||||
// Allocate a template
|
||||
rc = tpool->allocate(uids[0], templates[0], &oid);
|
||||
CPPUNIT_ASSERT( oid == 0 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
|
||||
// Try to allocate twice the same template, should fail
|
||||
rc = tpool->allocate(uids[0], templates[0], &oid);
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
|
||||
// Try again, this time with different uid. Should be allowed
|
||||
rc = tpool->allocate(uids[1], templates[0], &oid);
|
||||
CPPUNIT_ASSERT( rc >= 0 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
Reference in new issue
Block a user