1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

bug #1363: Better check for int and float values

This commit is contained in:
Ruben S. Montero 2012-07-19 01:18:51 +02:00
parent 4a9fadf7d4
commit 057da9492b
3 changed files with 2 additions and 25 deletions

View File

@ -348,23 +348,6 @@ public:
return obj_template->replace(name, value);
}
/**
* Adds a new attribute to the template (replacing it if
* already defined), the object's mutex SHOULD be locked
* @param name of the new attribute
* @param value of the new attribute
* @return 0 on success
*/
int replace_template_attribute(
const string& name,
const int& value)
{
ostringstream oss;
oss << value;
return replace_template_attribute(name, oss.str());
}
/**
* Generates a XML string for the template of the Object
* @param xml the string to store the XML description.

View File

@ -431,7 +431,7 @@ bool Template::get(
iss >> value;
if ( iss.fail() )
if (iss.fail() || !iss.eof())
{
value = 0;
return false;
@ -461,7 +461,7 @@ bool Template::get(
iss >> value;
if ( iss.fail() )
if (iss.fail() || !iss.eof())
{
value = 0;
return false;

View File

@ -252,23 +252,17 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
goto error_memory;
}
replace_template_attribute("MEMORY", ivalue);
if ( get_template_attribute("CPU", fvalue) == false || fvalue <= 0 )
{
goto error_cpu;
}
get_template_attribute("VCPU", value);
if ( value.empty() == false )
{
if ( get_template_attribute("VCPU", ivalue) == false || ivalue <= 0 )
{
goto error_vcpu;
}
replace_template_attribute("VCPU", ivalue);
}
// ------------------------------------------------------------------------