mirror of https://github.com/apache/cloudstack.git
bug 8479: remove direct account specific network as a part of account cleanup. Before public direct ip addresses weren't released as a part of nic cleanup - deallocate() method was missing in DirectNetworkGuru
status 8479: resolved fixed
This commit is contained in:
parent
49a4e5521f
commit
7f580edf35
|
|
@ -1771,14 +1771,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
boolean success = true;
|
||||
|
||||
// release ip addresses associated with the network if there are any
|
||||
// release ip addresses associated with the network if there are any - for Virtual case
|
||||
List<IPAddressVO> ipsToRelease = _ipAddressDao.listByAssociatedNetwork(networkId);
|
||||
if (ipsToRelease != null && !ipsToRelease.isEmpty()) {
|
||||
for (IPAddressVO ip : ipsToRelease) {
|
||||
unassignPublicIpAddress(ip);
|
||||
}
|
||||
|
||||
s_logger.debug("Ip addresses are unassigned successfully as a part of network id=" + networkId + " destroy");
|
||||
s_logger.debug("Ip addresses associated with network " + networkId + " are unassigned successfully as a part of network id=" + networkId + " destroy");
|
||||
}
|
||||
|
||||
for (NetworkElement element : _networkElements) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.State;
|
||||
|
|
@ -50,7 +51,6 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
|
@ -188,6 +188,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
@Override
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
|
||||
IPAddressVO ip = _ipAddressDao.findByAccountAndIp(vm.getVirtualMachine().getAccountId(), nic.getIp4Address());
|
||||
if (ip != null) {
|
||||
_networkMgr.unassignPublicIpAddress(ip);
|
||||
}
|
||||
nic.deallocate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue