Skip to content

Commit

Permalink
B #3357: fix alias_id consecutive generation
Browse files Browse the repository at this point in the history
(cherry picked from commit 35eaf4b)
  • Loading branch information
Alejandro Huertas Herrero authored and rsmontero committed May 23, 2019
1 parent b495c34 commit 8dee71c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/vm/VirtualMachineNic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ int VirtualMachineNics::get_network_leases(int vm_id, int uid,
return 0;
}

int VirtualMachineNics::get_auto_network_leases(int vm_id, int uid,
VectorAttribute * nic_default, vector<VectorAttribute*>& sgs,
int VirtualMachineNics::get_auto_network_leases(int vm_id, int uid,
VectorAttribute * nic_default, vector<VectorAttribute*>& sgs,
std::string& error_str)
{
Nebula& nd = Nebula::instance();
Expand Down Expand Up @@ -510,9 +510,10 @@ int VirtualMachineNics::set_up_attach_nic(int vmid, int uid, int cluster_id,
SecurityGroupPool* sgpool = nd.get_secgrouppool();

// -------------------------------------------------------------------------
// Get the highest NIC_ID
// Get the highest NIC_ID and ALIAS_ID
// -------------------------------------------------------------------------
int max_nic_id = -1;
int max_nic_id = -1;
int max_alias_id = -1;

for(nic_iterator it = begin(); it != end() ; ++it)
{
Expand All @@ -522,6 +523,18 @@ int VirtualMachineNics::set_up_attach_nic(int vmid, int uid, int cluster_id,
{
max_nic_id = nic_id;
}

if ( (*it)->is_alias() )
{
int alias_id;

(*it)->vector_value("ALIAS_ID", alias_id);

if ( alias_id > max_alias_id )
{
max_alias_id = alias_id;
}
}
}

VirtualMachineNic * nic = new VirtualMachineNic(vnic, max_nic_id + 1);
Expand Down Expand Up @@ -551,9 +564,7 @@ int VirtualMachineNics::set_up_attach_nic(int vmid, int uid, int cluster_id,
}
else
{
one_util::split_unique(alias_ids, ',', a_ids);

alias_id = *(a_ids.rbegin()) + 1;
alias_id = max_alias_id + 1;

alias_ids += ",";
}
Expand Down

0 comments on commit 8dee71c

Please sign in to comment.