Revision 7373770e

View differences:

include/Attribute.h
278 278
    string vector_value_str(const char *name, int& value) const;
279 279

  
280 280
    /**
281
     * Returns the float value
282
     *
283
     * @param name Name of the attribute
284
     * @param value Float value, if an error occurred the string returned is
285
     * empty and value set to -1;
286
     *
287
     * @return the value in string form on success, "" otherwise
288
     */
289
    string vector_value_str(const char *name, float& value) const;
290

  
291
    /**
281 292
     *  Marshall the attribute in a single string. The string MUST be freed
282 293
     *  by the calling function. The string is in the form:
283 294
     *  "VAL_NAME_1=VAL_VALUE_1,...,VAL_NAME_N=VAL_VALUE_N".
include/Quota.h
119 119
     *    @param usage_req usage for each metric
120 120
     */
121 121
    void del_quota(const string& qid, 
122
                   map<string, int>& usage_req);
122
                   map<string, float>& usage_req);
123 123

  
124 124
    /**
125 125
     *  Gets a quota identified by its ID.
src/common/Attribute.cc
301 301

  
302 302
/* -------------------------------------------------------------------------- */
303 303
/* -------------------------------------------------------------------------- */
304

  
305
string VectorAttribute::vector_value_str(const char *name, float& value) const
306
{
307
    map<string,string>::const_iterator it;
308

  
309
    it = attribute_value.find(name);
310

  
311
    if ( it == attribute_value.end() )
312
    {
313
        value = -1;
314
        return  "";
315
    }
316

  
317
    if ( it->second.empty() )
318
    {
319
        value = -1;
320
        return "";
321
    }
322

  
323
    istringstream iss(it->second);
324
    iss >> value;
325

  
326
    if (iss.fail() || !iss.eof())
327
    {
328
        value = -1;
329
        return "";
330
    }
331

  
332
    return it->second;
333
}
334

  
335
/* -------------------------------------------------------------------------- */
336
/* -------------------------------------------------------------------------- */
src/um/Quota.cc
269 269
/* -------------------------------------------------------------------------- */
270 270
/* -------------------------------------------------------------------------- */
271 271

  
272
void Quota::del_quota(const string& qid, map<string, int>& usage_req)
272
void Quota::del_quota(const string& qid, map<string, float>& usage_req)
273 273
{
274 274
    VectorAttribute * q;
275
    map<string, int>::iterator it;
275
    map<string, float>::iterator it;
276 276

  
277 277
    if ( get_quota(qid, &q) == -1)
278 278
    {
......
309 309
void Quota::cleanup_quota(const string& qid)
310 310
{
311 311
    VectorAttribute * q;
312
    map<string, int>::iterator it;
313 312
    map<string, Attribute *>::iterator q_it;
314 313

  
315
    int limit, limit_tmp;
316
    int usage, usage_tmp;
314
    float limit, limit_tmp;
315
    float usage, usage_tmp;
317 316

  
318 317
    if ( get_quota(qid, &q, q_it) == -1)
319 318
    {
......
355 354
int Quota::update_limits(VectorAttribute * quota, const VectorAttribute * va)
356 355
{        
357 356
    string limit;
358
    int    limit_i;
357
    float  limit_i;
359 358

  
360 359
    for (int i=0; i < num_metrics; i++)
361 360
    {
src/um/QuotaDatastore.cc
58 58

  
59 59
void QuotaDatastore::del(Template * tmpl)
60 60
{
61
    map<string, int> ds_request;
61
    map<string, float> ds_request;
62 62

  
63 63
    string ds_id;
64 64
    int    size;
src/um/QuotaImage.cc
75 75
    string image_id;
76 76
    int num;
77 77

  
78
    map<string, int> image_request;
78
    map<string, float> image_request;
79 79

  
80 80
    image_request.insert(make_pair("RVMS",1));
81 81

  
src/um/QuotaNetwork.cc
75 75
    string net_id;
76 76
    int num;
77 77

  
78
    map<string, int> net_request;
78
    map<string, float> net_request;
79 79

  
80 80
    net_request.insert(make_pair("LEASES",1));
81 81

  
src/um/QuotaVirtualMachine.cc
77 77

  
78 78
void QuotaVirtualMachine::del(Template * tmpl)
79 79
{
80
    map<string, int> vm_request;
80
    map<string, float> vm_request;
81 81

  
82 82
    int memory;
83 83
    float cpu;

Also available in: Unified diff