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

feature #279: Default target values for CONTEXT and SWAP disks.

This commit is contained in:
Carlos Martín 2010-07-20 16:50:05 +02:00 committed by Ruben S. Montero
parent 0f6f7138f6
commit 51eedd87d9

View File

@ -450,6 +450,20 @@ int VirtualMachine::parse_context()
context_parsed = new VectorAttribute("CONTEXT"); context_parsed = new VectorAttribute("CONTEXT");
context_parsed->unmarshall(parsed," @^_^@ "); context_parsed->unmarshall(parsed," @^_^@ ");
string target = context_parsed->vector_value("TARGET");
if ( target.empty() )
{
Nebula& nd = Nebula::instance();
string dev_prefix;
nd.get_configuration_attribute("DEFAULT_DEVICE_PREFIX",dev_prefix);
dev_prefix += "b";
context_parsed->replace("TARGET", dev_prefix);
}
vm_template->set(context_parsed); vm_template->set(context_parsed);
} }
@ -829,10 +843,36 @@ int VirtualMachine::get_disk_images()
rc = ipool->disk_attribute(disk, &index); rc = ipool->disk_attribute(disk, &index);
if (rc == -1) // 0 OK, -2 not using the Image pool if (rc == -1) // 0 OK, -1 ERROR
{ {
return -1; return -1;
} }
// -2 not using the Image pool, and type is swap
if ( rc == -2 )
{
string type = disk->vector_value("TYPE");
transform (type.begin(), type.end(), type.begin(),
(int(*)(int))toupper);
if( type == "SWAP" )
{
string target = disk->vector_value("TARGET");
if ( target.empty() )
{
Nebula& nd = Nebula::instance();
string dev_prefix;
nd.get_configuration_attribute("DEFAULT_DEVICE_PREFIX",
dev_prefix);
dev_prefix += "d";
disk->replace("TARGET", dev_prefix);
}
}
}
} }
return 0; return 0;