1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

New checking code for attributes in template so empty attributes don't break the Core. Things like:

NIC =

git-svn-id: http://svn.opennebula.org/trunk@67 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Constantino Vázquez Blanco 2008-07-22 14:43:38 +00:00
parent 6e0f7e2f0f
commit 9fd188581d
2 changed files with 72 additions and 38 deletions

View File

@ -157,12 +157,15 @@ int LibVirtDriver::deployment_description(
{
const VectorAttribute * os;
os = static_cast<const VectorAttribute *>(attrs[0]);
kernel = os->vector_value("KERNEL");
initrd = os->vector_value("INITRD");
boot = os->vector_value("BOOT");
root = os->vector_value("ROOT");
os = dynamic_cast<const VectorAttribute *>(attrs[0]);
if( os != 0 )
{
kernel = os->vector_value("KERNEL");
initrd = os->vector_value("INITRD");
boot = os->vector_value("BOOT");
root = os->vector_value("ROOT");
}
}
if ( kernel.empty() )
@ -229,7 +232,10 @@ int LibVirtDriver::deployment_description(
for (int i=0; i < num ;i++,source="",target="",ro="")
{
disk = static_cast<const VectorAttribute *>(attrs[i]);
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
if ( disk == 0 )
continue;
type = disk->vector_value("TYPE");
source = disk->vector_value("SOURCE");
@ -291,7 +297,10 @@ int LibVirtDriver::deployment_description(
for(int i=0; i<num;i++,mac="",bridge="",target="",script="")
{
nic = static_cast<const VectorAttribute *>(attrs[i]);
nic = dynamic_cast<const VectorAttribute *>(attrs[i]);
if ( nic == 0 )
continue;
bridge = nic->vector_value("BRIDGE");
@ -338,12 +347,15 @@ int LibVirtDriver::deployment_description(
if ( vm->get_template_attribute("GRAPHICS",attrs) > 0 )
{
graphics = static_cast<const VectorAttribute *>(attrs[0]);
type = graphics->vector_value("TYPE");
listen = graphics->vector_value("LISTEN");
port = graphics->vector_value("PORT");
passwd = graphics->vector_value("PASSWD");
graphics = dynamic_cast<const VectorAttribute *>(attrs[0]);
if ( graphics != 0)
{
type = graphics->vector_value("TYPE");
listen = graphics->vector_value("LISTEN");
port = graphics->vector_value("PORT");
passwd = graphics->vector_value("PASSWD");
}
if ( type == "vnc" || type == "VNC" )
{
@ -380,10 +392,13 @@ int LibVirtDriver::deployment_description(
if ( vm->get_template_attribute("INPUT",attrs) > 0 )
{
input = static_cast<const VectorAttribute *>(attrs[0]);
type = graphics->vector_value("TYPE");
bus = graphics->vector_value("BUS");
input = dynamic_cast<const VectorAttribute *>(attrs[0]);
if ( input != 0)
{
type = input->vector_value("TYPE");
bus = input->vector_value("BUS");
}
if ( !type.empty() )
{
@ -410,10 +425,13 @@ int LibVirtDriver::deployment_description(
if ( num > 0 )
{
features = static_cast<const VectorAttribute *>(attrs[0]);
pae = features->vector_value("PAE");
acpi = features->vector_value("ACPI");
features = dynamic_cast<const VectorAttribute *>(attrs[0]);
if ( features != 0 )
{
pae = features->vector_value("PAE");
acpi = features->vector_value("ACPI");
}
file << "\t<features>" << endl;
@ -440,9 +458,10 @@ int LibVirtDriver::deployment_description(
for(int i=0; i<num;i++)
{
raw = static_cast<const VectorAttribute *>(attrs[i]);
type = raw->vector_value("TYPE");
raw = dynamic_cast<const VectorAttribute *>(attrs[i]);
if ( raw != 0 )
type = raw->vector_value("TYPE");
transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);

View File

@ -126,11 +126,14 @@ int XenDriver::deployment_description(
{
const VectorAttribute * os;
os = static_cast<const VectorAttribute *>(attrs[0]);
os = dynamic_cast<const VectorAttribute *>(attrs[0]);
kernel = os->vector_value("KERNEL");
initrd = os->vector_value("INITRD");
root = os->vector_value("ROOT");
if ( os != 0 )
{
kernel = os->vector_value("KERNEL");
initrd = os->vector_value("INITRD");
root = os->vector_value("ROOT");
}
}
if ( kernel.empty() )
@ -183,7 +186,10 @@ int XenDriver::deployment_description(
for (int i=0; i < num ;i++,source="",target="",ro="")
{
disk = static_cast<const VectorAttribute *>(attrs[i]);
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
if (disk == 0)
continue;
source = disk->vector_value("SOURCE");
target = disk->vector_value("TARGET");
@ -229,7 +235,10 @@ int XenDriver::deployment_description(
{
char pre_char = ' ';
nic = static_cast<const VectorAttribute *>(attrs[i]);
nic = dynamic_cast<const VectorAttribute *>(attrs[i]);
if (nic == 0)
continue;
file << " '";
@ -240,7 +249,7 @@ int XenDriver::deployment_description(
file << "mac=" << mac;
pre_char = ',';
}
bridge = nic->vector_value("BRIDGE");
if( !bridge.empty() )
@ -262,12 +271,15 @@ int XenDriver::deployment_description(
if ( vm->get_template_attribute("GRAPHICS",attrs) > 0 )
{
graphics = static_cast<const VectorAttribute *>(attrs[0]);
graphics = dynamic_cast<const VectorAttribute *>(attrs[0]);
type = graphics->vector_value("TYPE");
listen = graphics->vector_value("LISTEN");
port = graphics->vector_value("PORT");
passwd = graphics->vector_value("PASSWD");
if ( graphics != 0 )
{
type = graphics->vector_value("TYPE");
listen = graphics->vector_value("LISTEN");
port = graphics->vector_value("PORT");
passwd = graphics->vector_value("PASSWD");
}
if ( type == "vnc" || type == "VNC" )
{
@ -306,7 +318,10 @@ int XenDriver::deployment_description(
for(int i=0; i<num;i++)
{
raw = static_cast<const VectorAttribute *>(attrs[i]);
raw = dynamic_cast<const VectorAttribute *>(attrs[i]);
if ( raw == 0 )
continue;
type = raw->vector_value("TYPE");