bug 7118: fixed deletePod command - 1)remove Pod's resources (private ip adresses) before removing the pod itself. 2) Verify that private ip address pool is not empty before removing it.

status 7118: resolved fixed
This commit is contained in:
alena 2010-11-11 16:33:42 -08:00
parent 709fc3686f
commit 0ad492cc74
2 changed files with 26 additions and 6 deletions

View File

@ -26,6 +26,7 @@ public interface DataCenterIpAddressDao extends GenericDao<DataCenterIpAddressVO
boolean mark(long dcId, long podId, String ip);
List<DataCenterIpAddressVO> listByPodIdDcIdIpAddress(long podId, long dcId, String ipAddress);
List<DataCenterIpAddressVO> listByPodIdDcId(long podId, long dcId);
int countIPs(long podId, long dcId, boolean onlyCountAllocated);
boolean deleteIpAddressByPod(long podId);

View File

@ -52,6 +52,7 @@ import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.AccountVlanMapVO;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterIpAddressVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.Pod;
@ -62,6 +63,7 @@ import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.PodVlanMapDao;
import com.cloud.dc.dao.VlanDao;
@ -97,6 +99,7 @@ import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.Adapters;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
@ -140,6 +143,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
@Inject NetworkManager _networkMgr;
@Inject(adapter=SecurityChecker.class)
Adapters<SecurityChecker> _secChecker;
//FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao?
protected static final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class);
private int _maxVolumeSizeInGb;
@ -437,14 +443,27 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
HostPodVO pod = _podDao.findById(podId);
DataCenterVO zone = _zoneDao.findById(pod.getDataCenterId());
//Delete private ip addresses for the pod if there are any
List<DataCenterIpAddressVO> privateIps = _privateIpAddressDao.listByPodIdDcId(Long.valueOf(podId), pod.getDataCenterId());
if (privateIps != null && privateIps.size() != 0) {
if (!(_privateIpAddressDao.deleteIpAddressByPod(podId))) {
throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
}
}
//Delete link local ip addresses for the pod
if (!(_LinkLocalIpAllocDao.deleteIpAddressByPod(podId))) {
throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
}
//Delete the pod and private IP addresses in the pod
if (_podDao.expunge(podId) && _privateIpAddressDao.deleteIpAddressByPod(podId)) {
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_DELETE, "Successfully deleted pod with name: " + pod.getName() + " in zone: " + zone.getName() + ".", "podId=" + podId, "dcId=" + zone.getId());
return true;
} else {
return false;
//Delete the pod
if (!(_podDao.expunge(podId))) {
throw new CloudRuntimeException("Failed to delete pod " + podId);
}
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_DELETE, "Successfully deleted pod with name: " + pod.getName() + " in zone: " + zone.getName() + ".", "podId=" + podId, "dcId=" + zone.getId());
return true;
}
@Override