bug 7929: remove security groups when account is deleted.

status 7929: resolved fixed
This commit is contained in:
Chiradeep Vittal 2011-01-13 15:40:21 -08:00
parent 2e018d46be
commit 2b66b8a924
3 changed files with 13 additions and 2 deletions

View File

@ -27,5 +27,6 @@ public interface SecurityGroupDao extends GenericDao<SecurityGroupVO, Long> {
List<SecurityGroupVO> listByAccountId(long accountId);
boolean isNameInUse(Long accountId, Long domainId, String name);
SecurityGroupVO findByAccountAndName(Long accountId, String name);
List<SecurityGroupVO> findByAccountAndNames(Long accountId, String... names);
List<SecurityGroupVO> findByAccountAndNames(Long accountId, String... names);
int removeByAccountId(long accountId);
}

View File

@ -87,5 +87,11 @@ public class SecurityGroupDaoImpl extends GenericDaoBase<SecurityGroupVO, Long>
sc.setParameters("groupNames", (Object [])names);
return listBy(sc);
}
}
@Override
public int removeByAccountId(long accountId) {
SearchCriteria sc = AccountIdSearch.create();
sc.setParameters("accountId", accountId);
return expunge(sc);
}
}

View File

@ -78,6 +78,7 @@ import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.router.VirtualNetworkApplianceManager;
import com.cloud.network.security.SecurityGroupManager;
import com.cloud.network.security.dao.SecurityGroupDao;
import com.cloud.server.Criteria;
import com.cloud.storage.StorageManager;
import com.cloud.storage.VMTemplateVO;
@ -131,6 +132,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
@Inject private VMTemplateDao _templateDao;
@Inject private PodVlanMapDao _podVlanMapDao;
@Inject private NetworkDao _networkDao;
@Inject private SecurityGroupDao _securityGroupDao;
@Inject private SecurityGroupManager _networkGroupMgr;
@ -898,6 +900,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
accountCleanupNeeded = true;
}
int numRemoved = _securityGroupDao.removeByAccountId(accountId);
s_logger.info("deleteAccount: Deleted " + numRemoved + " network groups for account " + accountId);
// Delete the account's VLANs
List<VlanVO> accountVlans = _vlanDao.listVlansForAccountByType(null, accountId, VlanType.DirectAttached);