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:
parent
f1f6972bae
commit
7791a6e3ba
@ -155,10 +155,9 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Generate context file to be sourced upon VM booting
|
* Generate context file to be sourced upon VM booting
|
||||||
* @param vm_id, ID of the VM to generate context for
|
* @param vm_id, ID of the VM to generate context for
|
||||||
* @param attrs, the template CONTEXT attributes (only the first one will
|
* @param attr, the template CONTEXT attribute (the first one)
|
||||||
* be used)
|
|
||||||
*/
|
*/
|
||||||
void generate_context(int vm_id, vector<Attribute *> attrs);
|
void generate_context(int vm_id, Attribute * attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to produce VM objects
|
* Factory method to produce VM objects
|
||||||
|
@ -33,7 +33,7 @@ int VirtualMachinePool::allocate (
|
|||||||
VirtualMachine * vm;
|
VirtualMachine * vm;
|
||||||
|
|
||||||
char * error_msg;
|
char * error_msg;
|
||||||
int rc;
|
int rc, num_attr;
|
||||||
|
|
||||||
vector<Attribute *> attrs;
|
vector<Attribute *> attrs;
|
||||||
|
|
||||||
@ -84,13 +84,16 @@ int VirtualMachinePool::allocate (
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Insert parsed context in the VM template and clean-up
|
// Insert parsed context in the VM template and clean-up
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
generate_context(*oid,attrs);
|
if ((num_attr = (int) attrs.size()) > 0)
|
||||||
|
|
||||||
for (int i = 0; i < (int) attrs.size() ; i++)
|
|
||||||
{
|
{
|
||||||
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;
|
VirtualMachine * vm;
|
||||||
VectorAttribute * context_parsed;
|
VectorAttribute * context_parsed;
|
||||||
@ -146,12 +149,7 @@ void VirtualMachinePool::generate_context(int vm_id, vector<Attribute *> attrs)
|
|||||||
|
|
||||||
char * error_msg;
|
char * error_msg;
|
||||||
|
|
||||||
if ( attrs.size() == 0 )
|
context = dynamic_cast<VectorAttribute *>(attr);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = dynamic_cast<VectorAttribute *>(attrs[0]);
|
|
||||||
|
|
||||||
if (context == 0)
|
if (context == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user