mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +03:00
Feature #1483 #1556: Leave SCHED_REQUIREMENTS and SCHED_RANK in the USER_TEMPLATE, so they can be edited
This commit is contained in:
parent
c483e7bba0
commit
92ccbd83fb
@ -1177,7 +1177,7 @@ private:
|
|||||||
int parse_context(string& error_str);
|
int parse_context(string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the "REQUIREMENTS" attribute of the template by substituting
|
* Parse the "SCHED_REQUIREMENTS" attribute of the template by substituting
|
||||||
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
|
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
|
||||||
* @param error_str Returns the error reason, if any
|
* @param error_str Returns the error reason, if any
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
|
@ -491,6 +491,10 @@ DEFAULT_UMASK = 177
|
|||||||
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
|
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
|
||||||
VM_RESTRICTED_ATTR = "NIC/MAC"
|
VM_RESTRICTED_ATTR = "NIC/MAC"
|
||||||
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
|
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
|
||||||
|
|
||||||
VM_RESTRICTED_ATTR = "RANK"
|
VM_RESTRICTED_ATTR = "RANK"
|
||||||
|
VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||||
|
VM_RESTRICTED_ATTR = "REQUIREMENTS"
|
||||||
|
VM_RESTRICTED_ATTR = "SCHED_REQUIREMENTS"
|
||||||
|
|
||||||
IMAGE_RESTRICTED_ATTR = "SOURCE"
|
IMAGE_RESTRICTED_ATTR = "SOURCE"
|
||||||
|
@ -51,7 +51,7 @@ void VirtualMachineXML::init_attributes()
|
|||||||
cpu = 0;
|
cpu = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ((*this)["/VM/TEMPLATE/RANK"]);
|
result = ((*this)["/VM/USER_TEMPLATE/SCHED_RANK"]);
|
||||||
|
|
||||||
if (result.size() > 0)
|
if (result.size() > 0)
|
||||||
{
|
{
|
||||||
@ -59,10 +59,20 @@ void VirtualMachineXML::init_attributes()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rank = "";
|
// Compatibility with previous versions
|
||||||
|
result = ((*this)["/VM/USER_TEMPLATE/RANK"]);
|
||||||
|
|
||||||
|
if (result.size() > 0)
|
||||||
|
{
|
||||||
|
rank = result[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rank = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ((*this)["/VM/TEMPLATE/REQUIREMENTS"]);
|
result = ((*this)["/VM/USER_TEMPLATE/SCHED_REQUIREMENTS"]);
|
||||||
|
|
||||||
if (result.size() > 0)
|
if (result.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -431,7 +431,7 @@ void Scheduler::match()
|
|||||||
matched = false;
|
matched = false;
|
||||||
n_error++;
|
n_error++;
|
||||||
|
|
||||||
error_msg << "Error evaluating REQUIREMENTS expression: '"
|
error_msg << "Error evaluating SCHED_REQUIREMENTS expression: '"
|
||||||
<< reqs << "', error: " << error;
|
<< reqs << "', error: " << error;
|
||||||
|
|
||||||
oss << "VM " << oid << ": " << error_msg.str();
|
oss << "VM " << oid << ": " << error_msg.str();
|
||||||
@ -454,7 +454,7 @@ void Scheduler::match()
|
|||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
|
|
||||||
oss << "VM " << oid << ": Host " << host->get_hid() <<
|
oss << "VM " << oid << ": Host " << host->get_hid() <<
|
||||||
" filtered out. It does not fulfill REQUIREMENTS.";
|
" filtered out. It does not fulfill SCHED_REQUIREMENTS.";
|
||||||
|
|
||||||
NebulaLog::log("SCHED",Log::DEBUG,oss);
|
NebulaLog::log("SCHED",Log::DEBUG,oss);
|
||||||
continue;
|
continue;
|
||||||
@ -503,7 +503,7 @@ void Scheduler::match()
|
|||||||
}
|
}
|
||||||
else if (n_matched == 0)
|
else if (n_matched == 0)
|
||||||
{
|
{
|
||||||
vm->log("No host meets the REQUIREMENTS expression");
|
vm->log("No host meets the SCHED_REQUIREMENTS expression");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -785,7 +785,30 @@ int VirtualMachine::parse_requirements(string& error_str)
|
|||||||
|
|
||||||
string parsed;
|
string parsed;
|
||||||
|
|
||||||
num = user_obj_template->remove("REQUIREMENTS", array_reqs);
|
num = user_obj_template->remove("SCHED_REQUIREMENTS", array_reqs);
|
||||||
|
|
||||||
|
if ( num == 0 ) // Compatibility with old REQUIREMENTS attribute
|
||||||
|
{
|
||||||
|
vector<Attribute *> array_reqs_aux;
|
||||||
|
vector<Attribute*>::iterator it;
|
||||||
|
|
||||||
|
num = user_obj_template->remove("REQUIREMENTS", array_reqs_aux);
|
||||||
|
|
||||||
|
// Rename att to SCHED_REQUIREMENTS
|
||||||
|
for (it = array_reqs_aux.begin(); it != array_reqs_aux.end(); it++)
|
||||||
|
{
|
||||||
|
reqs = dynamic_cast<SingleAttribute *>(*it);
|
||||||
|
|
||||||
|
if (reqs != 0)
|
||||||
|
{
|
||||||
|
array_reqs.push_back( new SingleAttribute(
|
||||||
|
"SCHED_REQUIREMENTS",
|
||||||
|
reqs->value()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( num == 0 )
|
if ( num == 0 )
|
||||||
{
|
{
|
||||||
@ -793,7 +816,7 @@ int VirtualMachine::parse_requirements(string& error_str)
|
|||||||
}
|
}
|
||||||
else if ( num > 1 )
|
else if ( num > 1 )
|
||||||
{
|
{
|
||||||
error_str = "Only one REQUIREMENTS attribute can be defined.";
|
error_str = "Only one SCHED_REQUIREMENTS attribute can be defined.";
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,7 +824,7 @@ int VirtualMachine::parse_requirements(string& error_str)
|
|||||||
|
|
||||||
if ( reqs == 0 )
|
if ( reqs == 0 )
|
||||||
{
|
{
|
||||||
error_str = "Wrong format for REQUIREMENTS attribute.";
|
error_str = "Wrong format for SCHED_REQUIREMENTS attribute.";
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,8 +834,8 @@ int VirtualMachine::parse_requirements(string& error_str)
|
|||||||
{
|
{
|
||||||
SingleAttribute * reqs_parsed;
|
SingleAttribute * reqs_parsed;
|
||||||
|
|
||||||
reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed);
|
reqs_parsed = new SingleAttribute("SCHED_REQUIREMENTS",parsed);
|
||||||
obj_template->set(reqs_parsed);
|
user_obj_template->set(reqs_parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Delete old requirements attributes --- */
|
/* --- Delete old requirements attributes --- */
|
||||||
@ -974,15 +997,15 @@ int VirtualMachine::automatic_requirements(string& error_str)
|
|||||||
oss.str("");
|
oss.str("");
|
||||||
oss << "CLUSTER_ID = " << cluster_id;
|
oss << "CLUSTER_ID = " << cluster_id;
|
||||||
|
|
||||||
user_obj_template->get("REQUIREMENTS", requirements);
|
user_obj_template->get("SCHED_REQUIREMENTS", requirements);
|
||||||
user_obj_template->erase("REQUIREMENTS");
|
user_obj_template->erase("SCHED_REQUIREMENTS");
|
||||||
|
|
||||||
if ( !requirements.empty() )
|
if ( !requirements.empty() )
|
||||||
{
|
{
|
||||||
oss << " & ( " << requirements << " )";
|
oss << " & ( " << requirements << " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_template->add("REQUIREMENTS", oss.str());
|
user_obj_template->add("SCHED_REQUIREMENTS", oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user