mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed accountCleanup to release all public ip addresses and delete the corresponding networks.
This commit is contained in:
parent
51daa4c0e4
commit
21bb9df292
@ -1101,6 +1101,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain, domainId, zoneType);
|
||||
zone = _zoneDao.persist(zone);
|
||||
|
||||
@ -1902,17 +1902,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
//for regular user don't allow to remove network when it's in any other states but allocated
|
||||
if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||
if (network.getState() != Network.State.Allocated) {
|
||||
throw new InvalidParameterValueException("Non-admin user can delete network in " + Network.State.Allocated + " state only.");
|
||||
}
|
||||
} else {
|
||||
if (!(network.getState() == Network.State.Allocated || network.getState() == Network.State.Setup)) {
|
||||
throw new InvalidParameterValueException("Can delete network in " + Network.State.Allocated + " and " + Network.State.Setup + " states only.");
|
||||
}
|
||||
}
|
||||
|
||||
//remove all the vlans associated with the network
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
||||
@ -2079,13 +2079,20 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
public boolean associateIP (Network network, List<? extends PublicIpAddress> ipAddress) {
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(network.getId());
|
||||
if (router == null) {
|
||||
//Return true only when domR entry exists, has Destroyed state and not null Removed field
|
||||
//because it happens just in case when this method is called as a part of account cleanup.
|
||||
//In all other cases return false
|
||||
router = _routerDao.findByNetworkConfigurationIncludingRemoved(network.getId());
|
||||
if (router != null && router.getState() == State.Destroyed && router.isRemoved()) {
|
||||
return true;
|
||||
}
|
||||
s_logger.warn("Unable to associate ip addresses, virtual router doesn't exist in the network " + network.getId());
|
||||
throw new ResourceUnavailableException("Unable to assign ip addresses");
|
||||
}
|
||||
|
||||
if (router.getState() == State.Running || router.getState() == State.Starting) {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
//We have to resend all already associated ip addresses
|
||||
//Have to resend all already associated ip addresses
|
||||
cmds = getAssociateIPCommands(router, ipAddress, cmds, 0);
|
||||
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
|
||||
@ -855,7 +855,7 @@ public class AccountManagerImpl implements AccountManager, AccountService {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + ips.size() + " public IP addresses for account with ID " + accountId);
|
||||
}
|
||||
|
||||
|
||||
for (IPAddressVO ip : ips) {
|
||||
List<PodVlanMapVO> podVlanMaps = _podVlanMapDao.listPodVlanMapsByVlan(ip.getVlanId());
|
||||
if (podVlanMaps != null && podVlanMaps.size() != 0) {
|
||||
|
||||
@ -120,4 +120,6 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long>, State
|
||||
DomainRouterVO findBy(long accountId, long dcId, Role role);
|
||||
|
||||
DomainRouterVO findByNetworkConfiguration(long networkConfigurationId);
|
||||
|
||||
DomainRouterVO findByNetworkConfigurationIncludingRemoved(long networkConfigurationId);
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.UpdateBuilder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
@ -316,6 +315,14 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
sc.setParameters("network", networkConfigurationId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DomainRouterVO findByNetworkConfigurationIncludingRemoved(long networkConfigurationId) {
|
||||
SearchCriteria<DomainRouterVO> sc = NetworkConfigSearch.create();
|
||||
sc.setParameters("network", networkConfigurationId);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateState(State oldState, Event event,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user