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

Revert "bug #1402: Always parse int values as floats and then truncate them"

breaks value tests, in quotas and VirtualMachine creation

This reverts commit 7dd75027e3f1722c138032b97ae949419e7fe217.
This commit is contained in:
Javi Fontan 2012-08-31 13:19:57 +02:00
parent 00e655d58b
commit fec2cbb07f
2 changed files with 32 additions and 11 deletions

View File

@ -173,6 +173,7 @@ int Host::update_info(string &parse_str)
{
char * error_msg;
int rc;
float fv;
rc = obj_template->parse(parse_str, &error_msg);
@ -184,14 +185,20 @@ int Host::update_info(string &parse_str)
return -1;
}
get_template_attribute("TOTALCPU",host_share.max_cpu);
get_template_attribute("TOTALMEMORY",host_share.max_mem);
get_template_attribute("TOTALCPU", fv);
host_share.max_cpu = static_cast<int>(fv);
get_template_attribute("TOTALMEMORY", fv);
host_share.max_mem = static_cast<int>(fv);
get_template_attribute("FREECPU",host_share.free_cpu);
get_template_attribute("FREEMEMORY",host_share.free_mem);
get_template_attribute("FREECPU", fv);
host_share.free_cpu = static_cast<int>(fv);
get_template_attribute("FREEMEMORY", fv);
host_share.free_mem = static_cast<int>(fv);
get_template_attribute("USEDCPU",host_share.used_cpu);
get_template_attribute("USEDMEMORY",host_share.used_mem);
get_template_attribute("USEDCPU", fv);
host_share.used_cpu = static_cast<int>(fv);
get_template_attribute("USEDMEMORY", fv);
host_share.used_mem = static_cast<int>(fv);
return 0;
}

View File

@ -417,13 +417,27 @@ bool Template::get(
const string& name,
int& value) const
{
float fvalue;
bool rc;
string sval;
rc = get(name, fvalue);
value = static_cast<int>(fvalue);
get(name, sval);
return rc;
if ( sval == "" )
{
value = 0;
return false;
}
istringstream iss(sval);
iss >> value;
if (iss.fail() || !iss.eof())
{
value = 0;
return false;
}
return true;
}
/* -------------------------------------------------------------------------- */