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:
parent
4a9fadf7d4
commit
057da9492b
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user