1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

Feature #2858: Free leases even if the VM/NIC does not have AR_ID

This way VMs created in ONE < 4.8 will correctly free the IPs
This commit is contained in:
Carlos Martín 2014-07-08 16:36:22 +02:00
parent 0c4feac83d
commit c12cb2d6ba
2 changed files with 19 additions and 3 deletions

View File

@ -193,6 +193,16 @@ public:
ar_pool.free_addr(arid, PoolObjectSQL::VM, vid, mac);
}
/**
* Release previously given address lease
* @param vid the ID of the VM
* @param mac MAC address identifying the lease
*/
void free_addr(int vid, const string& mac)
{
ar_pool.free_addr(PoolObjectSQL::VM, vid, mac);
}
/**
* Release all previously given address leases to the given object
* @param ot the type of the object requesting the address (VM or NET)

View File

@ -2603,8 +2603,7 @@ int VirtualMachine::release_network_leases(VectorAttribute const * nic, int vmid
return -1;
}
if (nic->vector_value("NETWORK_ID", vnid) != 0 ||
nic->vector_value("AR_ID", ar_id) != 0)
if (nic->vector_value("NETWORK_ID", vnid) != 0)
{
return -1;
}
@ -2623,7 +2622,14 @@ int VirtualMachine::release_network_leases(VectorAttribute const * nic, int vmid
return -1;
}
vn->free_addr(ar_id, vmid, mac);
if (nic->vector_value("AR_ID", ar_id) == 0)
{
vn->free_addr(ar_id, vmid, mac);
}
else
{
vn->free_addr(vmid, mac);
}
vnpool->update(vn);