Skip to content

Commit

Permalink
F #2427: Fixed problem with mix modes
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmont committed Oct 8, 2018
1 parent aefc580 commit 2caa580
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/scheduler/src/pool/VirtualMachineXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,44 @@ void VirtualMachineXML::init_attributes()

// ------------------- NIC REQUIREMENTS -------------------------------------

vector<string> nics_ids;
vector<string> nics_requirement;
vector<string> nics_rank;
if (get_nodes("/VM/TEMPLATE/NIC", nodes) > 0)
{
int nic_id;
string requirements, rank, net_mode;

xpaths(nics_ids,"/VM/TEMPLATE/NIC[NETWORK_MODE=\"auto\"]/NIC_ID");
xpaths(nics_requirement,"/VM/TEMPLATE/NIC[NETWORK_MODE=\"auto\"]/SCHED_REQUIREMENTS");
xpaths(nics_rank,"/VM/TEMPLATE/NIC[NETWORK_MODE=\"auto\"]/SCHED_RANK");
for ( vector<xmlNodePtr>::iterator it_nodes = nodes.begin(); it_nodes != nodes.end(); it_nodes++)
{
VirtualMachineTemplate * nic_template = new VirtualMachineTemplate;

int nic_id;
string requirements;
string rank;
nic_template->from_xml_node(*it_nodes);

for (size_t i = 0; i < nics_ids.size(); i++)
{
nic_id = atoi(nics_ids[i].c_str());
if ( nic_template->get("NETWORK_MODE", net_mode) && net_mode == "auto" )
{
nic_template->get("NIC_ID", nic_id);

nics_ids_auto.insert(nic_id);
nics_ids_auto.insert(nic_id);

nics[nic_id] = new VirtualMachineNicXML();
}
nics[nic_id] = new VirtualMachineNicXML();

for (size_t i = 0; i < nics_ids.size() && i < nics_requirement.size(); i++)
{
nic_id = atoi(nics_ids[i].c_str());
requirements = nics_requirement[i];
if ( nic_template->get("SCHED_REQUIREMENTS", requirements) )
{
nic_requirements[nic_id] = requirements;
}

nic_requirements[nic_id] = requirements;
}
if ( nic_template->get("SCHED_RANK", rank) )
{
nics[nic_id]->add_nic_rank(rank);
}
}

for (size_t i = 0; i < nics_ids.size() && i < nics_rank.size(); i++)
{
nic_id = atoi(nics_ids[i].c_str());
rank = nics_rank[i];
delete nic_template;
}

nics[nic_id]->add_nic_rank(rank);
free_nodes(nodes);
}

nodes.clear();

// ---------------- HISTORY HID, DSID, RESCHED & TEMPLATE ------------------

xpath(hid, "/VM/HISTORY_RECORDS/HISTORY/HID", -1);
Expand Down

0 comments on commit 2caa580

Please sign in to comment.