1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #407: Remove usernames from owned resources, only user-id is stored now.

This commit is contained in:
Carlos Martín 2011-05-12 17:10:35 +02:00
parent ae53d43789
commit 09c93c7528
27 changed files with 131 additions and 282 deletions

View File

@ -271,11 +271,6 @@ private:
// Image Description
// -------------------------------------------------------------------------
/**
* Image owner's name
*/
string user_name;
/**
* Type of the Image
*/
@ -346,8 +341,7 @@ protected:
// Constructor
// *************************************************************************
Image(int uid,
const string& user_name,
Image(int uid,
ImageTemplate* img_template);
virtual ~Image();

View File

@ -47,15 +47,15 @@ public:
/**
* Function to allocate a new Image object
* @param uid the user id of the image's owner
* @param stemplate template associated with the image
* @param img_template template associated with the image
* @param oid the id assigned to the Image
* @param error_str Returns the error reason, if any
* @return the oid assigned to the object,
* -1 in case of failure
* -2 in case of template parse failure
*/
int allocate (
int uid,
string user_name,
ImageTemplate * img_template,
int * oid,
string& error_str);
@ -179,7 +179,7 @@ private:
*/
PoolObjectSQL * create()
{
return new Image(-1,"",0);
return new Image(-1,0);
};
};

View File

@ -104,11 +104,6 @@ private:
// VMTemplate Attributes
// -------------------------------------------------------------------------
/**
* Owner's name
*/
string user_name;
/**
* Public scope of the VMTemplate
*/
@ -154,8 +149,7 @@ protected:
// *************************************************************************
// Constructor
// *************************************************************************
VMTemplate(int id, int uid, string _user_name,
VirtualMachineTemplate * _template_contents);
VMTemplate(int id, int uid, VirtualMachineTemplate * _template_contents);
~VMTemplate();

View File

@ -35,7 +35,6 @@ public:
* Allocates a new object, writting it in the pool database. No memory is
* allocated for the object.
* @param uid user id (the owner of the Template)
* @param user_name Owner's user name
* @param template_contents a VM Template object
* @param oid the id assigned to the Template
* @param error_str Returns the error reason, if any
@ -43,7 +42,6 @@ public:
* @return the oid assigned to the object, -1 in case of failure
*/
int allocate(int uid,
string user_name,
VirtualMachineTemplate * template_contents,
int * oid,
string& error_str);
@ -139,7 +137,7 @@ private:
*/
PoolObjectSQL * create()
{
return new VMTemplate(-1,-1,"", 0);
return new VMTemplate(-1,-1, 0);
};
};

View File

@ -668,14 +668,6 @@ private:
// Virtual Machine Attributes
// *************************************************************************
// -------------------------------------------------------------------------
// Identification variables
// -------------------------------------------------------------------------
/**
* Owner's name
*/
string user_name;
// -------------------------------------------------------------------------
// VM Scheduling & Managing Information
// -------------------------------------------------------------------------
@ -855,8 +847,7 @@ protected:
// Constructor
//**************************************************************************
VirtualMachine(int id, int uid, string _user_name,
VirtualMachineTemplate * _vm_template);
VirtualMachine(int id, int uid, VirtualMachineTemplate * _vm_template);
virtual ~VirtualMachine();

View File

@ -41,7 +41,6 @@ public:
/**
* Function to allocate a new VM object
* @param uid user id (the owner of the VM)
* @param user_name Owner's user name
* @param vm_template a VM Template object describing the VM
* @param oid the id assigned to the VM (output)
* @param error_str Returns the error reason, if any
@ -51,7 +50,6 @@ public:
*/
int allocate (
int uid,
string user_name,
VirtualMachineTemplate * vm_template,
int * oid,
string& error_str,
@ -146,7 +144,6 @@ public:
* pool
* @param oss the output stream to dump the pool contents
* @param where filter for the objects, defaults to all
* @param extended condition to include history and username data
* @param state include only VMs in this state. -1 means any state,
* except DONE
*
@ -161,7 +158,7 @@ private:
*/
PoolObjectSQL * create()
{
return new VirtualMachine(-1,-1,"", 0);
return new VirtualMachine(-1,-1, 0);
};
};

View File

@ -187,14 +187,6 @@ private:
// Virtual Network Private Attributes
// *************************************************************************
// -------------------------------------------------------------------------
// Identification variables
// -------------------------------------------------------------------------
/**
* Owner's name
*/
string user_name;
// -------------------------------------------------------------------------
// Binded physical attributes
// -------------------------------------------------------------------------
@ -269,7 +261,6 @@ private:
//**************************************************************************
VirtualNetwork(int uid,
string _user_name,
VirtualNetworkTemplate * _vn_template = 0);
~VirtualNetwork();

View File

@ -44,14 +44,14 @@ public:
* @param uid user identifier
* @param vn_template a VirtualNetworkTemplate describing the VNET
* @param oid the id assigned to the VM (output)
* @param error_str Returns the error reason, if any
* @return oid on success, -1 error
*/
int allocate (
int uid,
string user_name,
VirtualNetworkTemplate * vn_template,
int * oid,
string& error_str);
int uid,
VirtualNetworkTemplate * vn_template,
int * oid,
string& error_str);
/**
* Function to get a VN from the pool, if the object is not in memory
@ -154,7 +154,7 @@ private:
*/
PoolObjectSQL * create()
{
return new VirtualNetwork(0,"",0);
return new VirtualNetwork(0, 0);
};
};

View File

@ -68,6 +68,45 @@ protected:
PoolTest():pool(0){};
virtual ~PoolTest(){};
/**
* Replaces all <REGTIME> elements, padding them with 0
*/
string fix_regtimes(string& xml)
{
return fix_time(xml, "REGTIME");
}
string fix_stimes(string& xml)
{
return fix_time(xml, "STIME");
}
string fix_time(string& xml, string elem_name)
{
string start = "<" + elem_name + ">";
string end = "</" + elem_name + ">";
string replacement = "0000000000";
unsigned int pos = 0;
unsigned int end_pos = 0;
unsigned int length;
pos = xml.find(start, pos+1);
while( pos != xml.npos )
{
end_pos = xml.find(end, pos);
length = end_pos - pos - start.size();
xml.replace( pos+start.size(), length, replacement, 0, length);
pos = xml.find(start, pos+2);
}
return xml;
}
public:
void setUp()

View File

@ -34,11 +34,9 @@
/* Image :: Constructor/Destructor */
/* ************************************************************************ */
Image::Image(int _uid,
const string& _user_name,
Image::Image(int _uid,
ImageTemplate * _image_template):
PoolObjectSQL(-1,"",_uid,table),
user_name(_user_name),
type(OS),
regtime(time(0)),
source("-"),
@ -335,7 +333,6 @@ string& Image::to_xml(string& xml) const
"<IMAGE>" <<
"<ID>" << oid << "</ID>" <<
"<UID>" << uid << "</UID>" <<
"<USERNAME>" << user_name << "</USERNAME>" <<
"<NAME>" << name << "</NAME>" <<
"<TYPE>" << type << "</TYPE>" <<
"<PUBLIC>" << public_img << "</PUBLIC>" <<
@ -369,7 +366,6 @@ int Image::from_xml(const string& xml)
// Get class base attributes
rc += xpath(oid, "/IMAGE/ID", -1);
rc += xpath(uid, "/IMAGE/UID", -1);
rc += xpath(user_name, "/IMAGE/USERNAME", "not_found");
rc += xpath(name, "/IMAGE/NAME", "not_found");
rc += xpath(int_type, "/IMAGE/TYPE", 0);

View File

@ -56,7 +56,6 @@ ImagePool::ImagePool(SqlDB * db,
int ImagePool::allocate (
int uid,
string user_name,
ImageTemplate* img_template,
int * oid,
string& error_str)
@ -66,7 +65,7 @@ int ImagePool::allocate (
string name;
ostringstream oss;
img = new Image(uid, user_name, img_template);
img = new Image(uid, img_template);
// Check name
img->get_template_attribute("NAME", name);

View File

@ -24,7 +24,6 @@
using namespace std;
const int uids[] = {0,1,2};
const string user_names[] = {"A user","B user","C user"};
const string names[] = {"Image one", "Second Image", "The third image"};
@ -50,21 +49,20 @@ const string templates[] =
const string xmls[] =
{
"<IMAGE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE>",
"<IMAGE><ID>0</ID><UID>0</UID><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE>",
"<IMAGE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE>",
"<IMAGE><ID>1</ID><UID>1</UID><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE>",
"<IMAGE><ID>0</ID><UID>2</UID><USERNAME>C user</USERNAME><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[The third image]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE>"
"<IMAGE><ID>0</ID><UID>2</UID><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[The third image]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE>"
};
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>2</ID><UID>2</UID><USERNAME>C user</USERNAME><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[The third image]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE></IMAGE_POOL>";
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>2</ID><UID>2</UID><NAME>The third image</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><BUS><![CDATA[SCSI]]></BUS><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[The third image]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH><PROFILE><![CDATA[STUDENT]]></PROFILE></TEMPLATE></IMAGE></IMAGE_POOL>";
const string xml_dump_where =
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE></IMAGE_POOL>";
"<IMAGE_POOL><IMAGE><ID>0</ID><UID>0</UID><NAME>Image one</NAME><TYPE>0</TYPE><PUBLIC>0</PUBLIC><PERSISTENT>1</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a very long description of an image, and to achieve the longness I will copy this over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over. This is a very long description of an image, and to achieve the longness I will copy this over. And over.This is a very long description of an image, and to achieve the longness I will copy this over.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Image one]]></NAME><PATH><![CDATA[/tmp/image_test]]></PATH></TEMPLATE></IMAGE><IMAGE><ID>1</ID><UID>1</UID><NAME>Second Image</NAME><TYPE>0</TYPE><PUBLIC>1</PUBLIC><PERSISTENT>0</PERSISTENT><REGTIME>0000000000</REGTIME><SOURCE>-</SOURCE><STATE>4</STATE><RUNNING_VMS>0</RUNNING_VMS><TEMPLATE><DESCRIPTION><![CDATA[This is a rather short description.]]></DESCRIPTION><DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX><NAME><![CDATA[Second Image]]></NAME><PATH><![CDATA[/tmp/image_second_test]]></PATH></TEMPLATE></IMAGE></IMAGE_POOL>";
const string replacement = "0000000000";
class ImagePoolFriend : public ImagePool
{
@ -90,7 +88,7 @@ public:
if( rc == 0 )
{
return ImagePool::allocate(uid, user_names[uid], img_template, oid, err);
return ImagePool::allocate(uid, img_template, oid, err);
}
else
{
@ -167,7 +165,7 @@ protected:
// Get the xml and replace the REGTIME to 0, so we can compare
// it.
((Image*)obj)->to_xml(xml_str);
xml_str.replace( xml_str.find("<REGTIME>")+9, 10, replacement);
fix_regtimes(xml_str);
/*
if( xml_str != xmls[index] )
@ -868,17 +866,14 @@ public:
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(157, 10, replacement);
result.replace(1076, 10, replacement);
result.replace(1535, 10, replacement);
fix_regtimes(result);
/*
if( result != xml_dump )
{
cout << endl << result << endl << xml_dump << endl;
}
*/
//*/
CPPUNIT_ASSERT( result == xml_dump );
}
@ -904,15 +899,14 @@ public:
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(157, 10, replacement);
result.replace(1076, 10, replacement);
fix_regtimes(result);
/*
if( result != xml_dump_where )
{
cout << endl << result << endl << xml_dump_where << endl;
}
//*/
CPPUNIT_ASSERT( result == xml_dump_where );
}

View File

@ -185,7 +185,7 @@ private:
if( rc == 0 )
{
return vmpool->allocate(uids[index], "username", vm_template, &oid,
return vmpool->allocate(uids[index], vm_template, &oid,
err, false);
}
else

View File

@ -29,7 +29,6 @@ void RequestManager::VirtualMachineAllocate::execute(
string session;
string str_template;
string error_str;
string user_name;
string template_id_str = "TEMPLATE_ID";;
const string method_name = "VirtualMachineAllocate";
@ -44,7 +43,6 @@ void RequestManager::VirtualMachineAllocate::execute(
VirtualMachineTemplate * vm_template;
VirtualMachineTemplate * vm_template_aux;
User * user;
VMTemplate * registered_template;
bool using_template_pool;
int template_owner;
@ -198,26 +196,10 @@ void RequestManager::VirtualMachineAllocate::execute(
}
}
//--------------------------------------------------------------------------
// Get the User Name
//--------------------------------------------------------------------------
user = VirtualMachineAllocate::upool->get(uid,true);
if ( user == 0 )
{
goto error_user_get;
}
user_name = user->get_name();
user->unlock();
//--------------------------------------------------------------------------
// Allocate the VirtualMAchine
//--------------------------------------------------------------------------
rc = VirtualMachineAllocate::vmpool->allocate(uid,
user_name,
vm_template,
&vid,
error_str,
@ -244,12 +226,6 @@ error_template_get:
delete vm_template;
goto error_common;
error_user_get:
oss.str(get_error(method_name, "USER", uid));
delete vm_template;
goto error_common;
error_authenticate:
oss.str(authenticate_error(method_name));
goto error_common;

View File

@ -31,10 +31,8 @@ void RequestManager::ImageAllocate::execute(
string session;
string str_template;
string error_str;
string user_name;
ImageTemplate * img_template = 0;
User * user;
int iid;
int uid;
@ -101,27 +99,11 @@ void RequestManager::ImageAllocate::execute(
}
}
//--------------------------------------------------------------------------
// Get the User Name
//--------------------------------------------------------------------------
user = ImageAllocate::upool->get(uid,true);
if ( user == 0 )
{
goto error_user_get;
}
user_name = user->get_name();
user->unlock();
//--------------------------------------------------------------------------
// Allocate the Image
//--------------------------------------------------------------------------
rc = ImageAllocate::ipool->allocate(uid,user_name,
img_template,&iid, error_str);
rc = ImageAllocate::ipool->allocate(uid, img_template, &iid, error_str);
if ( rc < 0 )
{
@ -148,11 +130,6 @@ void RequestManager::ImageAllocate::execute(
return;
error_user_get:
oss.str(get_error(method_name, "USER", uid));
delete img_template;
goto error_common;
error_authenticate:
oss.str(authenticate_error(method_name));
goto error_common;

View File

@ -34,7 +34,6 @@ void RequestManager::VirtualMachineSaveDisk::execute(
string img_name;
int vm_owner;
string user_name;
int rc;
int uid;
@ -47,7 +46,6 @@ void RequestManager::VirtualMachineSaveDisk::execute(
VirtualMachine * vm;
Image * image;
ImageTemplate * img_template;
User * user;
Image * source_img;
int source_img_id;
@ -79,17 +77,6 @@ void RequestManager::VirtualMachineSaveDisk::execute(
goto error_authenticate;
}
user = VirtualMachineSaveDisk::upool->get(uid,true);
if ( user == 0 )
{
goto error_user_get;
}
user_name = user->get_name();
user->unlock();
//-------------------------------------------------------------------------
// Check that the image does not exist & prepare the template
//-------------------------------------------------------------------------
@ -148,8 +135,7 @@ void RequestManager::VirtualMachineSaveDisk::execute(
//--------------------------------------------------------------------------
// Create the image
//--------------------------------------------------------------------------
rc = VirtualMachineSaveDisk::ipool->allocate(uid,user_name,img_template,
&iid,estr);
rc = VirtualMachineSaveDisk::ipool->allocate(uid, img_template, &iid,estr);
if ( rc < 0 )
{
@ -245,10 +231,6 @@ error_vm_get_disk_id:
vm->unlock();
goto error_common;
error_user_get:
oss.str(get_error(method_name, "USER", uid));
goto error_common;
error_authenticate:
oss.str(authenticate_error(method_name));
goto error_common;

View File

@ -29,7 +29,6 @@ void RequestManager::TemplateAllocate::execute(
string session;
string str_template;
string error_str;
string user_name;
const string method_name = "TemplateAllocate";
@ -42,7 +41,6 @@ void RequestManager::TemplateAllocate::execute(
xmlrpc_c::value_array * arrayresult;
VirtualMachineTemplate * template_contents;
User * user;
char * error_msg = 0;
@ -94,26 +92,10 @@ void RequestManager::TemplateAllocate::execute(
}
}
//--------------------------------------------------------------------------
// Get the User Name
//--------------------------------------------------------------------------
user = TemplateAllocate::upool->get(uid,true);
if ( user == 0 )
{
goto error_user_get;
}
user_name = user->get_name();
user->unlock();
//--------------------------------------------------------------------------
// Allocate the VMTemplate
//--------------------------------------------------------------------------
rc = TemplateAllocate::tpool->allocate(uid,
user_name,
template_contents,
&oid,
error_str);
@ -135,12 +117,6 @@ void RequestManager::TemplateAllocate::execute(
return;
error_user_get:
oss.str(get_error(method_name, "USER", uid));
delete template_contents;
goto error_common;
error_authenticate:
oss.str(authenticate_error(method_name));
goto error_common;

View File

@ -29,12 +29,10 @@ void RequestManager::VirtualNetworkAllocate::execute(
{
string session;
string name;
string user_name;
string str_template;
string error_str;
VirtualNetworkTemplate * vn_template;
User * user;
int nid;
int uid;
@ -99,25 +97,10 @@ void RequestManager::VirtualNetworkAllocate::execute(
}
}
//--------------------------------------------------------------------------
// Get the User Name
//--------------------------------------------------------------------------
user = VirtualNetworkAllocate::upool->get(uid,true);
if ( user == 0 )
{
goto error_user_get;
}
user_name = user->get_name();
user->unlock();
//--------------------------------------------------------------------------
// Allocate the Virtual Network
//--------------------------------------------------------------------------
rc = vnpool->allocate(uid,user_name,vn_template,&nid,error_str);
rc = vnpool->allocate(uid,vn_template,&nid,error_str);
if ( rc < 0 )
{
@ -136,12 +119,6 @@ void RequestManager::VirtualNetworkAllocate::execute(
return;
error_user_get:
oss.str(get_error(method_name, "USER", uid));
delete vn_template;
goto error_common;
error_authenticate:
oss.str(authenticate_error(method_name));
goto error_common;

View File

@ -38,10 +38,8 @@
VirtualMachine::VirtualMachine(int id,
int _uid,
string _user_name,
VirtualMachineTemplate * _vm_template):
PoolObjectSQL(id,"",_uid,table),
user_name(_user_name),
last_poll(0),
state(INIT),
lcm_state(LCM_INIT),
@ -1106,7 +1104,6 @@ string& VirtualMachine::to_xml(string& xml) const
oss << "<VM>"
<< "<ID>" << oid << "</ID>"
<< "<UID>" << uid << "</UID>"
<< "<USERNAME>" << user_name << "</USERNAME>"
<< "<NAME>" << name << "</NAME>"
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
<< "<STATE>" << state << "</STATE>"
@ -1146,7 +1143,6 @@ int VirtualMachine::from_xml(const string &xml_str)
// Get class base attributes
rc += xpath(oid, "/VM/ID", -1);
rc += xpath(uid, "/VM/UID", -1);
rc += xpath(user_name, "/VM/USERNAME", "not_found");
rc += xpath(name, "/VM/NAME", "not_found");
rc += xpath(last_poll, "/VM/LAST_POLL",0);

View File

@ -167,7 +167,6 @@ VirtualMachinePool::VirtualMachinePool(SqlDB * db,
int VirtualMachinePool::allocate (
int uid,
string user_name,
VirtualMachineTemplate * vm_template,
int * oid,
string& error_str,
@ -178,7 +177,7 @@ int VirtualMachinePool::allocate (
// ------------------------------------------------------------------------
// Build a new Virtual Machine object
// ------------------------------------------------------------------------
vm = new VirtualMachine(-1, uid, user_name, vm_template);
vm = new VirtualMachine(-1, uid, vm_template);
if (on_hold == true)
{

View File

@ -25,7 +25,6 @@
using namespace std;
const int uids[] = {123, 261, 123};
const string user_names[] = {"A user","B user","C user"};
const string names[] = {"VM one", "Second VM", "VM one"};
@ -47,21 +46,21 @@ const string templates[] =
const string xmls[] =
{
"<VM><ID>0</ID><UID>123</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"<VM><ID>0</ID><UID>123</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"ATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ET"
"IME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX"
"><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]"
"]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID>"
"</TEMPLATE></VM>",
"<VM><ID>1</ID><UID>261</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL>"
"<VM><ID>1</ID><UID>261</UID><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL>"
"<STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0<"
"/ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET"
"_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY>"
"<![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID>"
"<![CDATA[1]]></VMID></TEMPLATE></VM>",
"<VM><ID>0</ID><UID>123</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"<VM><ID>0</ID><UID>123</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><ST"
"ATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ET"
"IME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX"
"><NET_RX>0</NET_RX><TEMPLATE><CPU>1</CPU><MEMORY>1024</MEMORY><NAME>VM one"
@ -71,15 +70,14 @@ const string xmls[] =
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>1</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>2</UID><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE></VM></VM_POOL>";
const string xml_dump_where =
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>1</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM></VM_POOL>";
const string xml_history_dump =
"<VM_POOL><VM><ID>0</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><VM_DIR>A_vm_dir</VM_DIR><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>A_vmm_mad</VMMMAD><TMMAD>A_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[2]]></VMID></TEMPLATE><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><VM_DIR>C_vm_dir</VM_DIR><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>C_vmm_mad</VMMMAD><TMMAD>C_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>";
"<VM_POOL><VM><ID>0</ID><UID>0</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>0</UID><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><VM_DIR>A_vm_dir</VM_DIR><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>A_vmm_mad</VMMMAD><TMMAD>A_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2</ID><UID>0</UID><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[2]]></VMID></TEMPLATE><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><VM_DIR>C_vm_dir</VM_DIR><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><VMMMAD>C_vmm_mad</VMMMAD><TMMAD>C_tm_mad</TMMAD><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>";
const string replacement = "0000000000";
/* ************************************************************************* */
/* ************************************************************************* */
@ -94,7 +92,6 @@ public:
int allocate (
int uid,
const string& user_name,
const string& stemplate,
int * oid,
bool on_hold = false)
@ -109,8 +106,8 @@ public:
if( rc == 0 )
{
return VirtualMachinePool::allocate(uid, user_name,
vm_template, oid, err, on_hold);
return VirtualMachinePool::allocate(uid, vm_template,
oid, err, on_hold);
}
else
{
@ -159,7 +156,6 @@ protected:
{
int oid;
return ((VirtualMachinePoolFriend*)pool)->allocate( uids[index],
user_names[index],
templates[index],
&oid, false);
};
@ -172,7 +168,7 @@ protected:
// Get the xml and replace the STIME to 0, so we can compare it
((VirtualMachine*)obj)->to_xml(xml_str);
xml_str.replace( xml_str.find("<STIME>")+7, 10, replacement);
fix_stimes(xml_str);
/*
if( xml_str != xmls[index] )
@ -256,15 +252,14 @@ public:
ostringstream oss;
int oid, rc;
vmp->allocate(1, user_names[0], templates[0], &oid, false);
vmp->allocate(2, user_names[1], templates[1], &oid, true);
vmp->allocate(1, templates[0], &oid, false);
vmp->allocate(2, templates[1], &oid, true);
rc = vmp->dump(oss, "");
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(152, 10, replacement);
result.replace(560, 10, replacement);
fix_stimes(result);
/*
if( result != xml_dump )
@ -286,15 +281,16 @@ public:
ostringstream oss;
ostringstream where;
vmp->allocate(1, user_names[0], templates[0], &oid, false);
vmp->allocate(2, user_names[1], templates[1], &oid, true);
vmp->allocate(1, templates[0], &oid, false);
vmp->allocate(2, templates[1], &oid, true);
where << "uid < 2";
rc = vmp->dump(oss, where.str());
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(152, 10, replacement);
fix_stimes(result);
CPPUNIT_ASSERT( result == xml_dump_where );
}
@ -315,13 +311,13 @@ public:
// Allocate a VM
rc = vmp->allocate(0, "one_user_test", templates[0], &oid, false);
rc = vmp->allocate(0, templates[0], &oid, false);
CPPUNIT_ASSERT( rc == oid );
CPPUNIT_ASSERT( oid >= 0 );
//----------------------------------------------------------------------
// Allocate a VM with one history item
rc = vmp->allocate(0, "one_user_test", templates[1], &oid, true);
rc = vmp->allocate(0, templates[1], &oid, true);
CPPUNIT_ASSERT( rc == oid );
CPPUNIT_ASSERT( oid >= 0 );
@ -339,7 +335,7 @@ public:
//----------------------------------------------------------------------
// Allocate a VM with two history items
rc = vmp->allocate(0, "one_user_test", templates[2], &oid, true);
rc = vmp->allocate(0, templates[2], &oid, true);
CPPUNIT_ASSERT( rc == oid );
CPPUNIT_ASSERT( oid >= 0 );
@ -366,7 +362,7 @@ public:
//----------------------------------------------------------------------
// Allocate a VM, will be set to DONE
rc = vmp->allocate(1, "one_user_test", templates[0], &oid, false);
rc = vmp->allocate(1, templates[0], &oid, false);
CPPUNIT_ASSERT( rc == oid );
CPPUNIT_ASSERT( oid >= 0 );
@ -388,10 +384,7 @@ public:
// Get the xml and replace the STIME to 0, so we can compare it
string result = oss.str();
result.replace(159, 10, replacement);
result.replace(574, 10, replacement);
result.replace(1295,10, replacement);
fix_stimes(result);
/*
if( result != xml_history_dump )

View File

@ -25,10 +25,8 @@
VMTemplate::VMTemplate(int id,
int _uid,
string _user_name,
VirtualMachineTemplate * _template_contents):
PoolObjectSQL(id,"",_uid,table),
user_name(_user_name),
regtime(time(0))
{
if (_template_contents != 0)
@ -195,7 +193,6 @@ string& VMTemplate::to_xml(string& xml) const
oss << "<VMTEMPLATE>"
<< "<ID>" << oid << "</ID>"
<< "<UID>" << uid << "</UID>"
<< "<USERNAME>" << user_name << "</USERNAME>"
<< "<NAME>" << name << "</NAME>"
<< "<PUBLIC>" << public_template << "</PUBLIC>"
<< "<REGTIME>" << regtime << "</REGTIME>"
@ -221,7 +218,6 @@ int VMTemplate::from_xml(const string& xml)
// Get class base attributes
rc += xpath(oid, "/VMTEMPLATE/ID", -1);
rc += xpath(uid, "/VMTEMPLATE/UID", -1);
rc += xpath(user_name, "/VMTEMPLATE/USERNAME", "not_found");
rc += xpath(name, "/VMTEMPLATE/NAME", "not_found");
rc += xpath(public_template,"/VMTEMPLATE/PUBLIC", 0);
rc += xpath(regtime, "/VMTEMPLATE/REGTIME", 0);

View File

@ -25,7 +25,6 @@
int VMTemplatePool::allocate (
int uid,
string user_name,
VirtualMachineTemplate * template_contents,
int * oid,
string& error_str)
@ -38,7 +37,7 @@ int VMTemplatePool::allocate (
// ------------------------------------------------------------------------
// Build a new VMTemplate object
// ------------------------------------------------------------------------
vm_template = new VMTemplate(-1, uid, user_name, template_contents);
vm_template = new VMTemplate(-1, uid, template_contents);
// Check name
vm_template->get_template_attribute("NAME", name);

View File

@ -24,7 +24,6 @@
using namespace std;
const int uids[] = {0,1,2};
const string user_names[] = {"A user","B user","C user"};
const string names[] = {"Template one", "Second Template", "Third Template"};
@ -46,21 +45,19 @@ const string templates[] =
const string xmls[] =
{
"<VMTEMPLATE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>0</ID><UID>0</UID><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>1</ID><UID>1</UID><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE>",
"<VMTEMPLATE><ID>2</ID><UID>2</UID><USERNAME>C user</USERNAME><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME></TEMPLATE></VMTEMPLATE>"
"<VMTEMPLATE><ID>2</ID><UID>2</UID><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME></TEMPLATE></VMTEMPLATE>"
};
// This xml dump result has the STIMEs modified to 0000000000
const string xml_dump =
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>2</ID><UID>2</UID><USERNAME>C user</USERNAME><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>2</ID><UID>2</UID><NAME>Third Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[3]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[Third Template]]></NAME></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
const string xml_dump_where =
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><USERNAME>A user</USERNAME><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><USERNAME>B user</USERNAME><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
const string replacement = "0000000000";
"<VMTEMPLATE_POOL><VMTEMPLATE><ID>0</ID><UID>0</UID><NAME>Template one</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[Template one]]></NAME></TEMPLATE></VMTEMPLATE><VMTEMPLATE><ID>1</ID><UID>1</UID><NAME>Second Template</NAME><PUBLIC>0</PUBLIC><REGTIME>0000000000</REGTIME><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second Template]]></NAME></TEMPLATE></VMTEMPLATE></VMTEMPLATE_POOL>";
class VMTemplatePoolFriend : public VMTemplatePool
{
@ -81,7 +78,7 @@ public:
if( rc == 0 )
{
return VMTemplatePool::allocate(uid, user_names[uid], template_contents, oid, err);
return VMTemplatePool::allocate(uid, template_contents, oid, err);
}
else
{
@ -147,7 +144,7 @@ protected:
// Get the xml and replace the REGTIME to 0, so we can compare
// it.
((VMTemplate*)obj)->to_xml(xml_str);
xml_str.replace( xml_str.find("<REGTIME>")+9, 10, replacement);
fix_regtimes( xml_str );
/*
if( xml_str != xmls[index] )
@ -490,10 +487,7 @@ public:
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(130, 10, replacement);
result.replace(393, 10, replacement);
result.replace(658, 10, replacement);
fix_regtimes(result);
/*
if( result != xml_dump )
@ -526,9 +520,7 @@ public:
CPPUNIT_ASSERT(rc == 0);
string result = oss.str();
result.replace(130, 10, replacement);
result.replace(393, 10, replacement);
fix_regtimes(result);
/*
if( result != xml_dump_where )

View File

@ -24,17 +24,16 @@
#include "FixedLeases.h"
#include "AuthManager.h"
#include "UserPool.h"
// TODO: check not needed
//#include "UserPool.h"
/* ************************************************************************** */
/* Virtual Network :: Constructor/Destructor */
/* ************************************************************************** */
VirtualNetwork::VirtualNetwork(int uid,
string _user_name,
VirtualNetworkTemplate *_vn_template):
PoolObjectSQL(-1,"",uid,table),
user_name(_user_name),
bridge(""),
type(UNINITIALIZED),
leases(0)
@ -501,7 +500,6 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended) const
"<VNET>" <<
"<ID>" << oid << "</ID>" <<
"<UID>" << uid << "</UID>" <<
"<USERNAME>" << user_name << "</USERNAME>" <<
"<NAME>" << name << "</NAME>" <<
"<TYPE>" << type << "</TYPE>" <<
"<BRIDGE>" << bridge << "</BRIDGE>" <<
@ -537,7 +535,6 @@ int VirtualNetwork::from_xml(const string &xml_str)
// Get class base attributes
rc += xpath(oid, "/VNET/ID", -1);
rc += xpath(uid, "/VNET/UID", -1);
rc += xpath(user_name, "/VNET/USERNAME", "not_found");
rc += xpath(name, "/VNET/NAME", "not_found");
rc += xpath(int_type, "/VNET/TYPE", -1);
rc += xpath(bridge, "/VNET/BRIDGE", "not_found");

View File

@ -71,7 +71,6 @@ VirtualNetworkPool::VirtualNetworkPool(SqlDB * db,
int VirtualNetworkPool::allocate (
int uid,
string user_name,
VirtualNetworkTemplate * vn_template,
int * oid,
string& error_str)
@ -80,7 +79,7 @@ int VirtualNetworkPool::allocate (
VirtualNetwork * vn_aux;
string name;
vn = new VirtualNetwork(uid, user_name, vn_template);
vn = new VirtualNetwork(uid, vn_template);
// Check for duplicates
vn->get_template_attribute("NAME", name);

View File

@ -29,7 +29,6 @@ using namespace std;
/* ************************************************************************* */
const int uids[] = {123, 261, 133, 78};
const string user_names[] = {"A user","B user","C user","D user"};
const string names[] = {"Net number one", "A virtual network","Net number two"};
@ -72,18 +71,18 @@ const string templates[] =
const string xmls[] =
{
"<VNET><ID>0</ID><UID>123</UID><USERNAME>A user</USERNAME><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.0.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number one]]></NAME><TYPE><![CDATA[FIXED]]></TYPE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>0</ID><UID>123</UID><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.0.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number one]]></NAME><TYPE><![CDATA[FIXED]]></TYPE></TEMPLATE><LEASES><LEASE><IP>130.10.0.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>",
"<VNET><ID>1</ID><UID>261</UID><USERNAME>B user</USERNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE><LEASES></LEASES></VNET>",
"<VNET><ID>1</ID><UID>261</UID><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE><LEASES></LEASES></VNET>",
"<VNET><ID>0</ID><UID>133</UID><USERNAME>C user</USERNAME><NAME>Net number two</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.2.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number two]]></NAME><TYPE><![CDATA[fixed]]></TYPE></TEMPLATE><LEASES><LEASE><IP>130.10.2.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>"
"<VNET><ID>0</ID><UID>133</UID><NAME>Net number two</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.2.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number two]]></NAME><TYPE><![CDATA[fixed]]></TYPE></TEMPLATE><LEASES><LEASE><IP>130.10.2.1</IP><MAC>50:20:20:20:20:20</MAC><USED>0</USED><VID>-1</VID></LEASE></LEASES></VNET>"
};
const string xml_dump =
"<VNET_POOL><VNET><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.0.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number one]]></NAME><TYPE><![CDATA[FIXED]]></TYPE></TEMPLATE></VNET><VNET><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE></VNET></VNET_POOL>";
"<VNET_POOL><VNET><ID>0</ID><UID>1</UID><NAME>Net number one</NAME><TYPE>1</TYPE><BRIDGE>br1</BRIDGE><PUBLIC>0</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br1]]></BRIDGE><LEASES><IP><![CDATA[130.10.0.1]]></IP><MAC><![CDATA[50:20:20:20:20:20]]></MAC></LEASES><NAME><![CDATA[Net number one]]></NAME><TYPE><![CDATA[FIXED]]></TYPE></TEMPLATE></VNET><VNET><ID>1</ID><UID>2</UID><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE></VNET></VNET_POOL>";
const string xml_dump_where =
"<VNET_POOL><VNET><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE></VNET></VNET_POOL>";
"<VNET_POOL><VNET><ID>1</ID><UID>2</UID><NAME>A virtual network</NAME><TYPE>0</TYPE><BRIDGE>br0</BRIDGE><PUBLIC>1</PUBLIC><TOTAL_LEASES>0</TOTAL_LEASES><TEMPLATE><BRIDGE><![CDATA[br0]]></BRIDGE><NAME><![CDATA[A virtual network]]></NAME><NETWORK_ADDRESS><![CDATA[192.168.0.0]]></NETWORK_ADDRESS><NETWORK_SIZE><![CDATA[C]]></NETWORK_SIZE><TYPE><![CDATA[RANGED]]></TYPE></TEMPLATE></VNET></VNET_POOL>";
/* ************************************************************************* */
/* ************************************************************************* */
@ -100,8 +99,7 @@ public:
{};
int allocate(const int& uid, const std::string& user_name,
const std::string& stemplate, int* oid)
int allocate(const int& uid, const std::string& stemplate, int* oid)
{
VirtualNetworkTemplate * vn_template;
char * error_msg = 0;
@ -113,8 +111,7 @@ public:
if( rc == 0 )
{
return VirtualNetworkPool::allocate(uid, user_name,
vn_template, oid, err);
return VirtualNetworkPool::allocate(uid, vn_template, oid, err);
}
else
{
@ -188,7 +185,7 @@ protected:
{
int oid;
return ((VirtualNetworkPoolFriend*)pool)->allocate(
uids[index],user_names[index],templates[index], &oid);
uids[index],templates[index], &oid);
};
void check(int index, PoolObjectSQL* obj)
@ -377,7 +374,7 @@ public:
for (int i = 0 ; i < 7 ; i++)
{
rc = vnpool->allocate(uids[0], user_names[0], templ[i], &oid[i]);
rc = vnpool->allocate(uids[0], templ[i], &oid[i]);
CPPUNIT_ASSERT( rc >= 0 );
vnet = vnpool->get(oid[i], false);
@ -406,22 +403,22 @@ public:
VirtualNetwork * vnet;
// Allocate a vnet
rc = vnpool->allocate(uids[0], user_names[0], templates[0], &oid_0);
rc = vnpool->allocate(uids[0], templates[0], &oid_0);
CPPUNIT_ASSERT( rc == oid_0 );
CPPUNIT_ASSERT( rc == 0 );
// Allocate the same vnet twice, with the same user ID. Should fail
rc = vnpool->allocate(uids[0], user_names[0], templates[0], &oid_1);
rc = vnpool->allocate(uids[0], templates[0], &oid_1);
CPPUNIT_ASSERT( rc == oid_1 );
CPPUNIT_ASSERT( rc == -1 );
// Same VNet, with different user ID. Should succeed
rc = vnpool->allocate(uids[1], user_names[1], templates[0], &oid_2);
rc = vnpool->allocate(uids[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_3);
rc = vnpool->allocate(uids[1], templates[1], &oid_3);
CPPUNIT_ASSERT( rc == oid_3 );
CPPUNIT_ASSERT( rc == 2 );
@ -454,8 +451,8 @@ public:
int oid, rc;
ostringstream oss;
vnpool->allocate(1, user_names[0], templates[0], &oid);
vnpool->allocate(2, user_names[1], templates[1], &oid);
vnpool->allocate(1, templates[0], &oid);
vnpool->allocate(2, templates[1], &oid);
rc = pool->dump(oss, "");
@ -463,7 +460,7 @@ public:
string result = oss.str();
/*
//*
if( result != xml_dump )
{
cout << endl << result << endl << "========"
@ -484,8 +481,8 @@ public:
int oid, rc;
ostringstream oss;
vnpool->allocate(1, user_names[0], templates[0], &oid);
vnpool->allocate(2, user_names[1], templates[1], &oid);
vnpool->allocate(1, templates[0], &oid);
vnpool->allocate(2, templates[1], &oid);
string where = "name LIKE '%virtual%'";
rc = pool->dump(oss, where);
@ -494,7 +491,7 @@ public:
string result = oss.str();
/*
//*
if( result != xml_dump_where )
{
cout << endl << result << endl << "========"
@ -606,7 +603,7 @@ public:
"NETWORK_ADDRESS = 192.168.50.0\n";
vnpool->allocate(45, user_names[0], tmpl, &oid);
vnpool->allocate(45, tmpl, &oid);
CPPUNIT_ASSERT( oid != -1 );
vn = vnpool->get(oid, false);
@ -830,11 +827,11 @@ public:
// First VNet template
vnpool->allocate(13, user_names[0], tmpl_A, &oid_0);
vnpool->allocate(13, tmpl_A, &oid_0);
CPPUNIT_ASSERT( oid_0 != -1 );
// Second VNet
vnpool->allocate(45, user_names[0], tmpl_B, &oid_new);
vnpool->allocate(45, tmpl_B, &oid_new);
CPPUNIT_ASSERT( oid_new != -1 );
// Get this second VNet
@ -1050,7 +1047,7 @@ public:
while( templates[i] != "END" )
{
vnp->allocate(0, user_names[0], templates[i], &oid);
vnp->allocate(0, templates[i], &oid);
CPPUNIT_ASSERT( oid >= 0 );
@ -1088,10 +1085,10 @@ public:
"BRIDGE = br2\n"
"LEASES = [IP=130.10.0.5, MAC=50:20:20:20:20:25]";
vnp->allocate(0, user_names[0], template_0, &oid_0);
vnp->allocate(0, template_0, &oid_0);
CPPUNIT_ASSERT( oid_0 == 0 );
vnp->allocate(0, user_names[0], template_1, &oid_1);
vnp->allocate(0, template_1, &oid_1);
CPPUNIT_ASSERT( oid_1 == 1 );
// Disk using network 0