1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #2427: Added AUTOMATIC_NIC_REQUIREMENTS to speed_up NIC filtering

This commit is contained in:
juanmont 2018-10-25 11:33:55 +02:00 committed by Ruben S. Montero
parent 04e8135a7b
commit 19bf8ab8c8
2 changed files with 24 additions and 1 deletions

View File

@ -33,6 +33,7 @@ void VirtualMachineXML::init_attributes()
string automatic_requirements;
string automatic_ds_requirements;
string automatic_nic_requirements;
xpath(oid, "/VM/ID", -1);
xpath(uid, "/VM/UID", -1);
@ -101,6 +102,8 @@ void VirtualMachineXML::init_attributes()
// ------------------- NIC REQUIREMENTS -------------------------------------
xpath(automatic_nic_requirements, "/VM/TEMPLATE/AUTOMATIC_NIC_REQUIREMENTS", "");
if (get_nodes("/VM/TEMPLATE/NIC", nodes) > 0)
{
std::string net_mode;
@ -131,6 +134,15 @@ void VirtualMachineXML::init_attributes()
if ( nic_template->get("SCHED_REQUIREMENTS", requirements) )
{
if ( !automatic_nic_requirements.empty() )
{
ostringstream oss;
oss << automatic_nic_requirements << " & ( " << requirements << " )";
requirements = oss.str();
}
the_nic->set_requirements(requirements);
}

View File

@ -1553,6 +1553,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
obj_template->erase("AUTOMATIC_REQUIREMENTS");
obj_template->erase("AUTOMATIC_DS_REQUIREMENTS");
obj_template->erase("AUTOMATIC_NIC_REQUIREMENTS");
int rc = get_cluster_requirements(obj_template, cluster_ids, error_str);
@ -1625,6 +1626,8 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
oss << ")";
obj_template->add("AUTOMATIC_NIC_REQUIREMENTS", oss.str());
if ( !datastore_ids.empty() )
{
oss << " & ";
@ -2216,12 +2219,13 @@ string& VirtualMachine::to_xml_short(string& xml)
{
string disks_xml, monitoring_xml, user_template_xml, history_xml, nics_xml;
ostringstream oss;
string cpu_tmpl, mem_tmpl, auto_reqs, auto_ds_reqs;
string cpu_tmpl, mem_tmpl, auto_reqs, auto_ds_reqs, auto_nic_reqs;
obj_template->get("CPU", cpu_tmpl);
obj_template->get("MEMORY", mem_tmpl);
obj_template->get("AUTOMATIC_REQUIREMENTS", auto_reqs);
obj_template->get("AUTOMATIC_DS_REQUIREMENTS", auto_ds_reqs);
obj_template->get("AUTOMATIC_NIC_REQUIREMENTS", auto_nic_reqs);
oss << "<VM>"
<< "<ID>" << oid << "</ID>"
@ -2265,6 +2269,13 @@ string& VirtualMachine::to_xml_short(string& xml)
oss << "</AUTOMATIC_DS_REQUIREMENTS>";
}
if (!auto_nic_reqs.empty())
{
oss << "<AUTOMATIC_NIC_REQUIREMENTS>";
oss << one_util::escape_xml(auto_nic_reqs);
oss << "</AUTOMATIC_NIC_REQUIREMENTS>";
}
oss << "</TEMPLATE>"
<< monitoring.to_xml_short(monitoring_xml)
<< user_obj_template->to_xml_short(user_template_xml);