mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Bug #1347: quota update accepts float values
This commit is contained in:
parent
6cc05f5b81
commit
c94bfcab5e
@ -277,6 +277,17 @@ public:
|
||||
*/
|
||||
string vector_value_str(const char *name, int& value) const;
|
||||
|
||||
/**
|
||||
* Returns the float value
|
||||
*
|
||||
* @param name Name of the attribute
|
||||
* @param value Float value, if an error occurred the string returned is
|
||||
* empty and value set to -1;
|
||||
*
|
||||
* @return the value in string form on success, "" otherwise
|
||||
*/
|
||||
string vector_value_str(const char *name, float& value) const;
|
||||
|
||||
/**
|
||||
* Marshall the attribute in a single string. The string MUST be freed
|
||||
* by the calling function. The string is in the form:
|
||||
|
@ -119,7 +119,7 @@ protected:
|
||||
* @param usage_req usage for each metric
|
||||
*/
|
||||
void del_quota(const string& qid,
|
||||
map<string, int>& usage_req);
|
||||
map<string, float>& usage_req);
|
||||
|
||||
/**
|
||||
* Gets a quota identified by its ID.
|
||||
|
@ -301,3 +301,36 @@ string VectorAttribute::vector_value_str(const char *name, int& value) const
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string VectorAttribute::vector_value_str(const char *name, float& value) const
|
||||
{
|
||||
map<string,string>::const_iterator it;
|
||||
|
||||
it = attribute_value.find(name);
|
||||
|
||||
if ( it == attribute_value.end() )
|
||||
{
|
||||
value = -1;
|
||||
return "";
|
||||
}
|
||||
|
||||
if ( it->second.empty() )
|
||||
{
|
||||
value = -1;
|
||||
return "";
|
||||
}
|
||||
|
||||
istringstream iss(it->second);
|
||||
iss >> value;
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
value = -1;
|
||||
return "";
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -269,10 +269,10 @@ bool Quota::check_quota(const string& qid,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Quota::del_quota(const string& qid, map<string, int>& usage_req)
|
||||
void Quota::del_quota(const string& qid, map<string, float>& usage_req)
|
||||
{
|
||||
VectorAttribute * q;
|
||||
map<string, int>::iterator it;
|
||||
map<string, float>::iterator it;
|
||||
|
||||
if ( get_quota(qid, &q) == -1)
|
||||
{
|
||||
@ -309,11 +309,10 @@ void Quota::del_quota(const string& qid, map<string, int>& usage_req)
|
||||
void Quota::cleanup_quota(const string& qid)
|
||||
{
|
||||
VectorAttribute * q;
|
||||
map<string, int>::iterator it;
|
||||
map<string, Attribute *>::iterator q_it;
|
||||
|
||||
int limit, limit_tmp;
|
||||
int usage, usage_tmp;
|
||||
float limit, limit_tmp;
|
||||
float usage, usage_tmp;
|
||||
|
||||
if ( get_quota(qid, &q, q_it) == -1)
|
||||
{
|
||||
@ -355,7 +354,7 @@ void Quota::cleanup_quota(const string& qid)
|
||||
int Quota::update_limits(VectorAttribute * quota, const VectorAttribute * va)
|
||||
{
|
||||
string limit;
|
||||
int limit_i;
|
||||
float limit_i;
|
||||
|
||||
for (int i=0; i < num_metrics; i++)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ bool QuotaDatastore::check(Template * tmpl, string& error)
|
||||
|
||||
void QuotaDatastore::del(Template * tmpl)
|
||||
{
|
||||
map<string, int> ds_request;
|
||||
map<string, float> ds_request;
|
||||
|
||||
string ds_id;
|
||||
int size;
|
||||
|
@ -75,7 +75,7 @@ void QuotaImage::del(Template * tmpl)
|
||||
string image_id;
|
||||
int num;
|
||||
|
||||
map<string, int> image_request;
|
||||
map<string, float> image_request;
|
||||
|
||||
image_request.insert(make_pair("RVMS",1));
|
||||
|
||||
|
@ -75,7 +75,7 @@ void QuotaNetwork::del(Template * tmpl)
|
||||
string net_id;
|
||||
int num;
|
||||
|
||||
map<string, int> net_request;
|
||||
map<string, float> net_request;
|
||||
|
||||
net_request.insert(make_pair("LEASES",1));
|
||||
|
||||
|
@ -77,7 +77,7 @@ bool QuotaVirtualMachine::check(Template * tmpl, string& error)
|
||||
|
||||
void QuotaVirtualMachine::del(Template * tmpl)
|
||||
{
|
||||
map<string, int> vm_request;
|
||||
map<string, float> vm_request;
|
||||
|
||||
int memory;
|
||||
float cpu;
|
||||
|
Loading…
x
Reference in New Issue
Block a user