mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-3735. Domain deletion fails even when the networks within the domain have been destroyed.
When a network is destroyed remove the corresponding network entry from domain_network_ref and account_network_ref table
This commit is contained in:
parent
743d35cae4
commit
a71810f705
|
|
@ -19,4 +19,5 @@ package com.cloud.network.dao;
|
|||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NetworkAccountDao extends GenericDao<NetworkAccountVO, Long> {
|
||||
NetworkAccountVO getAccountNetworkMapByNetworkId(long networkId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,27 @@ package com.cloud.network.dao;
|
|||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Component
|
||||
public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements NetworkAccountDao {
|
||||
public NetworkAccountDaoImpl() {
|
||||
final SearchBuilder<NetworkAccountVO> AllFieldsSearch;
|
||||
|
||||
protected NetworkAccountDaoImpl() {
|
||||
super();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkAccountVO getAccountNetworkMapByNetworkId(long networkId) {
|
||||
SearchCriteria<NetworkAccountVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,8 +119,11 @@ import com.cloud.network.dao.FirewallRulesDao;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkAccountDao;
|
||||
import com.cloud.network.dao.NetworkAccountVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkDomainDao;
|
||||
import com.cloud.network.dao.NetworkDomainVO;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkServiceMapVO;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
|
|
@ -261,6 +264,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
AccountGuestVlanMapDao _accountGuestVlanMapDao;
|
||||
@Inject
|
||||
DataCenterVnetDao _datacenterVnetDao;
|
||||
@Inject
|
||||
NetworkAccountDao _networkAccountDao;
|
||||
|
||||
List<NetworkGuru> _networkGurus;
|
||||
public List<NetworkGuru> getNetworkGurus() {
|
||||
|
|
@ -2891,7 +2896,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
} catch (NoTransitionException e) {
|
||||
s_logger.debug(e.getMessage());
|
||||
}
|
||||
_networksDao.remove(network.getId());
|
||||
if (_networksDao.remove(network.getId())) {
|
||||
NetworkDomainVO networkDomain = _networkDomainDao.getDomainNetworkMapByNetworkId(network.getId());
|
||||
if (networkDomain != null)
|
||||
_networkDomainDao.remove(networkDomain.getId());
|
||||
|
||||
NetworkAccountVO networkAccount = _networkAccountDao.getAccountNetworkMapByNetworkId(network.getId());
|
||||
if (networkAccount != null)
|
||||
_networkAccountDao.remove(networkAccount.getId());
|
||||
}
|
||||
|
||||
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
|
||||
|
|
|
|||
Loading…
Reference in New Issue