Revision a519eb13 src/vm/VirtualMachine.cc

View differences:

src/vm/VirtualMachine.cc
213 213
    string name;
214 214

  
215 215
    string        value;
216
    int           ivalue;
217
    float         fvalue;
216 218
    ostringstream oss;
217 219

  
218 220
    // ------------------------------------------------------------------------
......
242 244
    this->name = name;
243 245

  
244 246
    // ------------------------------------------------------------------------
245
    // Check for CPU and MEMORY attributes
247
    // Check for CPU, VCPU and MEMORY attributes
246 248
    // ------------------------------------------------------------------------
247 249

  
248
    get_template_attribute("MEMORY", value);
250
    if ( get_template_attribute("MEMORY", ivalue) == false || ivalue <= 0 )
251
    {
252
        goto error_memory;
253
    }
249 254

  
250
    if ( value.empty())
255
    replace_template_attribute("MEMORY", ivalue);
256

  
257
    if ( get_template_attribute("CPU", fvalue) == false || fvalue <= 0 )
251 258
    {
252
        goto error_no_memory;
259
        goto error_cpu;
253 260
    }
254 261

  
255
    get_template_attribute("CPU", value);
262
    get_template_attribute("VCPU", value);
256 263

  
257
    if ( value.empty())
264
    if ( value.empty() == false )
258 265
    {
259
        goto error_no_cpu;
266
        if ( get_template_attribute("VCPU", ivalue) == false || ivalue <= 0 )
267
        {
268
            goto error_vcpu;
269
        }
270

  
271
        replace_template_attribute("VCPU", ivalue);
260 272
    }
261 273

  
262 274
    // ------------------------------------------------------------------------
......
339 351
    release_network_leases();
340 352
    goto error_common;
341 353

  
342
error_no_cpu:
343
    error_str = "CPU attribute missing.";
354
error_cpu:
355
    error_str = "CPU attribute must be a positive float or integer value.";
356
    goto error_common;
357

  
358
error_vcpu:
359
    error_str = "VCPU attribute must be a positive integer value.";
344 360
    goto error_common;
345 361

  
346
error_no_memory:
347
    error_str = "MEMORY attribute missing.";
362
error_memory:
363
    error_str = "MEMORY attribute must be a positive integer value.";
348 364
    goto error_common;
349 365

  
350 366
error_name_length:

Also available in: Unified diff