submit-on-hold.patch
| opennebula-3.8.1.submit_on_hold/include/NebulaTemplate.h 2012-12-20 08:23:23.000000000 -0500 | ||
|---|---|---|
| 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 |
|
| opennebula-3.8.1.submit_on_hold/include/Template.h 2012-12-20 08:27:30.000000000 -0500 | ||
|---|---|---|
| 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 |
/** |
| opennebula-3.8.1.submit_on_hold/include/VirtualMachinePool.h 2012-12-20 08:47:05.000000000 -0500 | ||
|---|---|---|
| 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_*/ |
| opennebula-3.8.1.submit_on_hold/src/nebula/Nebula.cc 2012-12-20 08:01:16.000000000 -0500 | ||
|---|---|---|
| 274 | 274 |
time_t vm_expiration; |
| 275 | 275 |
time_t host_expiration; |
| 276 | 276 |
|
| 277 |
bool vm_submit_on_hold; |
|
| 278 |
|
|
| 277 | 279 |
vector<const Attribute *> vm_hooks; |
| 278 | 280 |
vector<const Attribute *> host_hooks; |
| 279 | 281 |
vector<const Attribute *> vnet_hooks; |
| ... | ... | |
| 300 | 302 |
nebula_configuration->get("VM_MONITORING_EXPIRATION_TIME",vm_expiration);
|
| 301 | 303 |
nebula_configuration->get("HOST_MONITORING_EXPIRATION_TIME",host_expiration);
|
| 302 | 304 |
|
| 305 |
nebula_configuration->get("VM_SUBMIT_ON_HOLD",vm_submit_on_hold);
|
|
| 306 |
|
|
| 303 | 307 |
vmpool = new VirtualMachinePool(db, |
| 304 | 308 |
vm_hooks, |
| 305 | 309 |
hook_location, |
| 306 | 310 |
remotes_location, |
| 307 | 311 |
vm_restricted_attrs, |
| 308 |
vm_expiration); |
|
| 312 |
vm_expiration, |
|
| 313 |
vm_submit_on_hold); |
|
| 309 | 314 |
hpool = new HostPool(db, |
| 310 | 315 |
host_hooks, |
| 311 | 316 |
hook_location, |
| opennebula-3.8.1.submit_on_hold/src/rm/RequestManagerAllocate.cc 2012-12-20 07:56:07.000000000 -0500 | ||
|---|---|---|
| 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 |
{
|
| opennebula-3.8.1.submit_on_hold/src/rm/RequestManagerVMTemplate.cc 2012-12-20 07:56:44.000000000 -0500 | ||
|---|---|---|
| 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 |
{
|
| opennebula-3.8.1.submit_on_hold/src/template/Template.cc 2012-12-20 08:35:13.000000000 -0500 | ||
|---|---|---|
| 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; |
| opennebula-3.8.1.submit_on_hold/src/vm/VirtualMachinePool.cc 2012-12-20 08:53:46.000000000 -0500 | ||
|---|---|---|
| 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 |
} |