1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-22 22:03:39 +03:00

better deal with context attributes

git-svn-id: http://svn.opennebula.org/one/trunk@395 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Rubén S. Montero 2009-03-08 00:06:16 +00:00
parent f1f6972bae
commit 7791a6e3ba
2 changed files with 13 additions and 16 deletions

View File

@ -155,10 +155,9 @@ private:
/**
* Generate context file to be sourced upon VM booting
* @param vm_id, ID of the VM to generate context for
* @param attrs, the template CONTEXT attributes (only the first one will
* be used)
* @param attr, the template CONTEXT attribute (the first one)
*/
void generate_context(int vm_id, vector<Attribute *> attrs);
void generate_context(int vm_id, Attribute * attr);
/**
* Factory method to produce VM objects

View File

@ -33,7 +33,7 @@ int VirtualMachinePool::allocate (
VirtualMachine * vm;
char * error_msg;
int rc;
int rc, num_attr;
vector<Attribute *> attrs;
@ -84,13 +84,16 @@ int VirtualMachinePool::allocate (
// ------------------------------------------------------------------------
// Insert parsed context in the VM template and clean-up
// ------------------------------------------------------------------------
generate_context(*oid,attrs);
for (int i = 0; i < (int) attrs.size() ; i++)
if ((num_attr = (int) attrs.size()) > 0)
{
if (attrs[i] != 0)
generate_context(*oid,attrs[0]);
for (int i = 0; i < num_attr ; i++)
{
delete attrs[i];
if (attrs[i] != 0)
{
delete attrs[i];
}
}
}
@ -133,7 +136,7 @@ int VirtualMachinePool::get_pending(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachinePool::generate_context(int vm_id, vector<Attribute *> attrs)
void VirtualMachinePool::generate_context(int vm_id, Attribute * attr)
{
VirtualMachine * vm;
VectorAttribute * context_parsed;
@ -146,12 +149,7 @@ void VirtualMachinePool::generate_context(int vm_id, vector<Attribute *> attrs)
char * error_msg;
if ( attrs.size() == 0 )
{
return;
}
context = dynamic_cast<VectorAttribute *>(attrs[0]);
context = dynamic_cast<VectorAttribute *>(attr);
if (context == 0)
{