mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Feature #3264: Move cpu/memory cost to obj template. Make them restricted
This commit is contained in:
parent
3b1ed0c48c
commit
7c515abc2b
@ -763,6 +763,8 @@ VM_RESTRICTED_ATTR = "DISK/WRITE_BYTES_SEC"
|
||||
VM_RESTRICTED_ATTR = "DISK/TOTAL_IOPS_SEC"
|
||||
VM_RESTRICTED_ATTR = "DISK/READ_IOPS_SEC"
|
||||
VM_RESTRICTED_ATTR = "DISK/WRITE_IOPS_SEC"
|
||||
VM_RESTRICTED_ATTR = "CPU_COST"
|
||||
VM_RESTRICTED_ATTR = "MEMORY_COST"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
@ -336,6 +336,32 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
obj_template->add("VCPU", ivalue);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Check the cost attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( user_obj_template->get("CPU_COST", fvalue) == true )
|
||||
{
|
||||
if ( fvalue < 0 )
|
||||
{
|
||||
goto error_cpu_cost;
|
||||
}
|
||||
|
||||
user_obj_template->erase("CPU_COST");
|
||||
obj_template->add("CPU_COST", fvalue);
|
||||
}
|
||||
|
||||
if ( user_obj_template->get("MEMORY_COST", fvalue) == true )
|
||||
{
|
||||
if ( fvalue < 0 )
|
||||
{
|
||||
goto error_memory_cost;
|
||||
}
|
||||
|
||||
user_obj_template->erase("MEMORY_COST");
|
||||
obj_template->add("MEMORY_COST", fvalue);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Check the OS attribute
|
||||
// ------------------------------------------------------------------------
|
||||
@ -458,6 +484,14 @@ error_memory:
|
||||
error_str = "MEMORY attribute must be a positive integer value.";
|
||||
goto error_common;
|
||||
|
||||
error_cpu_cost:
|
||||
error_str = "CPU_COST attribute must be a positive float or integer value.";
|
||||
goto error_common;
|
||||
|
||||
error_memory_cost:
|
||||
error_str = "MEMORY_COST attribute must be a positive float or integer value.";
|
||||
goto error_common;
|
||||
|
||||
error_os:
|
||||
error_defaults:
|
||||
error_name:
|
||||
|
@ -653,9 +653,8 @@ void VirtualMachinePool::calculate_showback(
|
||||
history.xpath(cpu, "/HISTORY/VM/TEMPLATE/CPU", 0);
|
||||
history.xpath(mem, "/HISTORY/VM/TEMPLATE/MEMORY", 0);
|
||||
|
||||
// TODO: cpu/mem cost should be moved to TEMPLATE
|
||||
history.xpath(cpu_cost, "/HISTORY/VM/USER_TEMPLATE/CPU_COST", 0);
|
||||
history.xpath(mem_cost, "/HISTORY/VM/USER_TEMPLATE/MEMORY_COST", 0);
|
||||
history.xpath(cpu_cost, "/HISTORY/VM/TEMPLATE/CPU_COST", 0);
|
||||
history.xpath(mem_cost, "/HISTORY/VM/TEMPLATE/MEMORY_COST", 0);
|
||||
|
||||
// TODO debug
|
||||
/*=====================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user