mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
bug #1178: Ownership of the VM is checked now before releasing the IP/MAC lease
This commit is contained in:
parent
9c4d753219
commit
aec7af2c75
@ -299,8 +299,21 @@ protected:
|
||||
*/
|
||||
bool check(const string& ip);
|
||||
|
||||
/**
|
||||
* Check if the passed ip corresponds with a given lease
|
||||
* @param ip of the lease to be checked
|
||||
* @return true if the ip was already assigned
|
||||
*/
|
||||
bool check(unsigned int ip);
|
||||
|
||||
/**
|
||||
* Check if a VM is the owner of the ip
|
||||
* @param ip of the lease to be checked
|
||||
* @param vid the ID of the VM
|
||||
* @return true if the ip was already assigned
|
||||
*/
|
||||
bool is_owner(const string& ip, int vid);
|
||||
|
||||
/**
|
||||
* Reads the leases from the DB, and updates the lease hash table
|
||||
* @param db pointer to the database.
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Release previously given lease
|
||||
* Release previously given lease
|
||||
* @param _ip IP identifying the lease
|
||||
* @return 0 if success
|
||||
*/
|
||||
@ -145,6 +145,17 @@ public:
|
||||
return leases->release(ip);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a VM is the owner of the ip
|
||||
* @param ip of the lease to be checked
|
||||
* @param vid the ID of the VM
|
||||
* @return true if the ip was already assigned
|
||||
*/
|
||||
bool is_owner (const string& ip, int vid)
|
||||
{
|
||||
return leases->is_owner(ip, vid);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets size of the network (used + free)
|
||||
* @return number of hosts that can be fitted in this network
|
||||
|
@ -1084,8 +1084,11 @@ void VirtualMachine::release_network_leases()
|
||||
continue;
|
||||
}
|
||||
|
||||
vn->release_lease(ip);
|
||||
vnpool->update(vn);
|
||||
if (vn->is_owner(ip,oid))
|
||||
{
|
||||
vn->release_lease(ip);
|
||||
vnpool->update(vn);
|
||||
}
|
||||
|
||||
vn->unlock();
|
||||
}
|
||||
|
@ -415,6 +415,28 @@ bool Leases::check(unsigned int ip)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool Leases::is_owner(const string& ip, int vid)
|
||||
{
|
||||
unsigned int _ip;
|
||||
map<unsigned int,Lease *>::iterator it;
|
||||
|
||||
Leases::Lease::ip_to_number(ip,_ip);
|
||||
|
||||
it = leases.find(_ip);
|
||||
|
||||
if (it!=leases.end())
|
||||
{
|
||||
return (it->second->vid == vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int Leases::hold_leases(vector<const Attribute*>& vector_leases,
|
||||
string& error_msg)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user