Revision 8c1dacab

View differences:

include/Attribute.h
257 257
    int vector_value(const char *name, int& value) const;
258 258

  
259 259
    /**
260
     * Returns the float value
261
     *
262
     * @param name Name of the attribute
263
     * @param value Float value
264
     *
265
     * @return 0 on success, -1 otherwise
266
     */
267
    int vector_value(const char *name, float& value) const;
268

  
269
    /**
260 270
     * Returns the integer value
261 271
     *
262 272
     * @param name Name of the attribute
263
     * @param value Integer value, if an error ocurred the string returned is 
273
     * @param value Integer value, if an error occurred the string returned is
264 274
     * empty and value set to -1;
265 275
     *
266 276
     * @return the value in string form on success, "" otherwise
include/Quota.h
110 110
     *    @return true if the request does not exceed current limits
111 111
     */
112 112
    bool check_quota(const string& qid, 
113
                     map<string, int>& usage_req,
113
                     map<string, float>& usage_req,
114 114
                     string& error);
115 115

  
116 116
    /**
......
179 179
     *    @param va_name name of the quota in the vector attribute
180 180
     *    @param num value to add to the current quota;
181 181
     */
182
    void add_to_quota(VectorAttribute * attr, const string& va_name, int num);
182
    void add_to_quota(VectorAttribute * attr, const string& va_name, float num);
183 183

  
184 184
    /** 
185 185
     *  Sets new limit values for the quota
src/cli/one_helper/onegroup_helper.rb
84 84

  
85 85
            column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
86 86
                if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
87
                    "%4d / %4d" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
87
                    "%4.0f / %4.0f" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
88 88
                else
89 89
                    "-"
90 90
                end
src/cli/one_helper/onequota_helper.rb
60 60
        end
61 61

  
62 62
        column :"CPU", "", :right, :size=>20 do |d|
63
            "%4d / %4d" % [d["CPU_USED"], d["CPU"]] if !d.nil?
63
            "%8.2f / %8.2f" % [d["CPU_USED"], d["CPU"]] if !d.nil?
64 64
        end
65 65
    end
66 66

  
src/cli/one_helper/oneuser_helper.rb
184 184

  
185 185
            column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
186 186
                if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
187
                    "%4d / %4d" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
187
                    "%4.0f / %4.0f" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
188 188
                else
189 189
                    "-"
190 190
                end
src/common/Attribute.cc
244 244
/* -------------------------------------------------------------------------- */
245 245
/* -------------------------------------------------------------------------- */
246 246

  
247
int VectorAttribute::vector_value(const char *name, float & value) const
248
{
249
    map<string,string>::const_iterator it;
250

  
251
    it = attribute_value.find(name);
252

  
253
    if ( it == attribute_value.end() )
254
    {
255
        return -1;
256
    }
257

  
258
    if ( it->second.empty() )
259
    {
260
        return -1;
261
    }
262

  
263
    istringstream iss(it->second);
264
    iss >> value;
265

  
266
    return 0;
267
}
268

  
269
/* -------------------------------------------------------------------------- */
270
/* -------------------------------------------------------------------------- */
271

  
247 272
string VectorAttribute::vector_value_str(const char *name, int& value) const
248 273
{
249 274
    map<string,string>::const_iterator it;
src/um/Quota.cc
60 60
/* -------------------------------------------------------------------------- */
61 61
/* -------------------------------------------------------------------------- */
62 62

  
63
void Quota::add_to_quota(VectorAttribute * attr, const string& va_name, int num)
63
void Quota::add_to_quota(VectorAttribute * attr, const string& va_name, float num)
64 64
{
65 65
    istringstream iss;
66 66
    ostringstream oss;
......
151 151
/* -------------------------------------------------------------------------- */
152 152

  
153 153
bool Quota::check_quota(const string& qid, 
154
                        map<string, int>& usage_req, 
154
                        map<string, float>& usage_req,
155 155
                        string& error)
156 156
{
157 157
    VectorAttribute * q;
158
    map<string, int>::iterator it;
158
    map<string, float>::iterator it;
159 159

  
160 160
    bool check;
161
    int  limit;
162
    int  usage;
161
    float limit;
162
    float usage;
163 163

  
164 164
    if ( get_quota(qid, &q) == -1 )
165 165
    {
src/um/QuotaDatastore.cc
28 28

  
29 29
bool QuotaDatastore::check(Template * tmpl,  string& error)
30 30
{
31
    map<string, int> ds_request;
31
    map<string, float> ds_request;
32 32

  
33 33
    string ds_id;
34 34
    int    size;
src/um/QuotaImage.cc
34 34
    string image_id;
35 35
    int num;
36 36

  
37
    map<string, int> image_request;
37
    map<string, float> image_request;
38 38

  
39 39
    image_request.insert(make_pair("RVMS",1));
40 40

  
src/um/QuotaNetwork.cc
34 34
    string net_id;
35 35
    int num;
36 36

  
37
    map<string, int> net_request;
37
    map<string, float> net_request;
38 38

  
39 39
    net_request.insert(make_pair("LEASES",1));
40 40

  
src/um/QuotaVirtualMachine.cc
50 50

  
51 51
bool QuotaVirtualMachine::check(Template * tmpl,  string& error)
52 52
{
53
    map<string, int> vm_request;
53
    map<string, float> vm_request;
54 54

  
55 55
    int memory;
56
    int cpu;
56
    float cpu;
57 57

  
58 58
    if ( tmpl->get("MEMORY", memory) == false )
59 59
    {
......
80 80
    map<string, int> vm_request;
81 81

  
82 82
    int memory;
83
    int cpu;
83
    float cpu;
84 84

  
85 85
    if ( tmpl->get("MEMORY", memory) == false )
86 86
    {

Also available in: Unified diff