Revision 64b4f0d5

View differences:

include/NebulaTemplate.h
102 102
        Template::get(_name,value);
103 103
    };
104 104

  
105
    void get(const char *name, bool& value) const
106
    {
107
        string _name(name);
108

  
109
        Template::get(_name,value);
110
    };
111

  
112
    // -----------------------------------------------------------------------
105 113
    // -----------------------------------------------------------------------
106 114
    // -----------------------------------------------------------------------
107 115

  
include/Template.h
265 265
        const string&   name,
266 266
        float&          value) const;
267 267

  
268
    /**
269
     *  Gets the value of a Single attributes (bool) with the given name.
270
     *    @param name the attribute name.
271
     *    @param value the attribute value, a bool, false if the attribute is not
272
     *    defined or not Single
273
     *
274
     *    @return True if the Single attribute was found and is a valid bool
275
     *    value
276
     */
277
    virtual bool get(
278
        const string&   name,
279
        bool&           value) const;
280

  
268 281
    friend ostream& operator<<(ostream& os, const Template& t);
269 282

  
270 283
    /**
include/VirtualMachinePool.h
37 37
                       const string&                hook_location,
38 38
                       const string&                remotes_location,
39 39
                       vector<const Attribute *>&   restricted_attrs,
40
                       time_t                       expire_time);
40
                       time_t                       expire_time,
41
                       bool                         on_hold);
41 42

  
42 43
    ~VirtualMachinePool(){};
43 44

  
......
48 49
     *    @param vm_template a VM Template object describing the VM
49 50
     *    @param oid the id assigned to the VM (output)
50 51
     *    @param error_str Returns the error reason, if any
51
     *    @param on_hold flag to submit on hold
52 52
     *    @return oid on success, -1 error inserting in DB or -2 error parsing
53 53
     *  the template
54 54
     */
......
59 59
        const string&            gname,
60 60
        VirtualMachineTemplate * vm_template,
61 61
        int *                    oid,
62
        string&                  error_str,
63
        bool                     on_hold = false);
62
        string&                  error_str);
64 63

  
65 64
    /**
66 65
     *  Function to get a VM from the pool, if the object is not in memory
......
255 254
     * Size, in seconds, of the historical monitoring information
256 255
     */
257 256
    static time_t _monitor_expiration;
257

  
258
    /**
259
     * True or false whether to submit new VM on HOLD or not
260
     */
261
    static bool _submit_on_hold;
258 262
};
259 263

  
260 264
#endif /*VIRTUAL_MACHINE_POOL_H_*/
src/nebula/Nebula.cc
517 517
        time_t  vm_expiration;
518 518
        time_t  host_expiration;
519 519

  
520
        bool    vm_submit_on_hold;
521

  
520 522
        vector<const Attribute *> vm_hooks;
521 523
        vector<const Attribute *> host_hooks;
522 524
        vector<const Attribute *> vnet_hooks;
......
543 545
        nebula_configuration->get("VM_MONITORING_EXPIRATION_TIME",vm_expiration);
544 546
        nebula_configuration->get("HOST_MONITORING_EXPIRATION_TIME",host_expiration);
545 547

  
548
        nebula_configuration->get("VM_SUBMIT_ON_HOLD",vm_submit_on_hold);
549

  
546 550
        vmpool = new VirtualMachinePool(db,
547 551
                                        vm_hooks,
548 552
                                        hook_location,
549 553
                                        remotes_location,
550 554
                                        vm_restricted_attrs,
551
                                        vm_expiration);
555
                                        vm_expiration,
556
                                        vm_submit_on_hold);
552 557
        hpool  = new HostPool(db,
553 558
                              host_hooks,
554 559
                              hook_location,
src/rm/RequestManagerAllocate.cc
244 244
    Template tmpl_back(*tmpl);
245 245

  
246 246
    int rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, ttmpl, &id,
247
                error_str, false);
247
                error_str);
248 248

  
249 249
    if ( rc < 0 )
250 250
    {
src/rm/RequestManagerVMTemplate.cc
109 109
    Template tmpl_back(*tmpl);
110 110

  
111 111
    rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, tmpl, &vid,
112
            error_str, false);
112
            error_str);
113 113

  
114 114
    if ( rc < 0 )
115 115
    {
src/template/Template.cc
473 473
/* -------------------------------------------------------------------------- */
474 474
/* -------------------------------------------------------------------------- */
475 475

  
476
bool Template::get(
477
        const string&   name,
478
        bool&           value) const
479
{
480
    string sval;
481

  
482
    get(name, sval);
483

  
484
    if ( sval == "" )
485
    {
486
        value = false;
487
        return false;
488
    }
489

  
490
    if ( sval == "1" || sval == "true" || sval == "YES" ) {
491
        value = true;
492
    }
493
    else
494
    {
495
        value = false;
496
    }
497

  
498
    return true;
499
}
500

  
501
/* -------------------------------------------------------------------------- */
502
/* -------------------------------------------------------------------------- */
503

  
476 504
string& Template::to_xml(string& xml) const
477 505
{
478 506
    multimap<string,Attribute *>::const_iterator  it;
src/vm/VirtualMachinePool.cc
25 25
/* -------------------------------------------------------------------------- */
26 26

  
27 27
time_t VirtualMachinePool::_monitor_expiration;
28
bool   VirtualMachinePool::_submit_on_hold;
28 29

  
29 30
/* -------------------------------------------------------------------------- */
30 31
/* -------------------------------------------------------------------------- */
......
35 36
        const string&               hook_location,
36 37
        const string&               remotes_location,
37 38
        vector<const Attribute *>&  restricted_attrs,
38
        time_t                      expire_time)
39
        time_t                      expire_time,
40
        bool                        on_hold)
39 41
    : PoolSQL(db, VirtualMachine::table, false)
40 42
{
41 43
    const VectorAttribute * vattr;
......
50 52
    bool state_hook = false;
51 53

  
52 54
    _monitor_expiration = expire_time;
55
    _submit_on_hold = on_hold;
53 56

  
54 57
    if ( _monitor_expiration == 0 )
55 58
    {
......
222 225
    const string&  gname,
223 226
    VirtualMachineTemplate * vm_template,
224 227
    int *          oid,
225
    string&        error_str,
226
    bool           on_hold)
228
    string&        error_str)
227 229
{
228 230
    VirtualMachine * vm;
229 231

  
......
232 234
    // ------------------------------------------------------------------------
233 235
    vm = new VirtualMachine(-1, uid, gid, uname, gname, vm_template);
234 236

  
235
    if (on_hold == true)
237
    if (_submit_on_hold == true)
236 238
    {
237 239
        vm->state = VirtualMachine::HOLD;
238 240
    }

Also available in: Unified diff