mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9559 Why allow deleting zone without deleting the secondary storage under the zone
This commit is contained in:
parent
3f7fca02d4
commit
a2a1f25131
@ -46,6 +46,7 @@
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<module>orchestration</module>
|
||||
<module>schema</module>
|
||||
<module>storage</module>
|
||||
<module>storage/volume</module>
|
||||
<module>storage/image</module>
|
||||
@ -53,7 +54,6 @@
|
||||
<module>storage/cache</module>
|
||||
<module>storage/snapshot</module>
|
||||
<module>components-api</module>
|
||||
<module>schema</module>
|
||||
<module>network</module>
|
||||
<module>service</module>
|
||||
</modules>
|
||||
|
||||
@ -37,6 +37,8 @@ import javax.naming.ConfigurationException;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
@ -84,7 +86,6 @@ import org.apache.cloudstack.region.PortableIpVO;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.region.RegionVO;
|
||||
import org.apache.cloudstack.region.dao.RegionDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
@ -346,6 +347,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
ImageStoreDetailsDao _imageStoreDetailsDao;
|
||||
|
||||
|
||||
// FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao?
|
||||
@Inject
|
||||
protected DataCenterLinkLocalIpAddressDao _linkLocalIpAllocDao;
|
||||
@ -1332,7 +1334,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final String errorMsg = "The zone cannot be deleted because ";
|
||||
|
||||
|
||||
|
||||
// Check if there are any non-removed hosts in the zone.
|
||||
if (!_hostDao.listByDataCenterId(zoneId).isEmpty()) {
|
||||
throw new CloudRuntimeException(errorMsg + "there are servers in this zone.");
|
||||
@ -1368,6 +1369,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new CloudRuntimeException(errorMsg + "there are physical networks in this zone.");
|
||||
}
|
||||
|
||||
//check if there are any secondary stores attached to the zone
|
||||
if(!_imageStoreDao.findByScope(new ZoneScope(zoneId)).isEmpty()) {
|
||||
throw new CloudRuntimeException(errorMsg + "there are Secondary storages in this zone");
|
||||
}
|
||||
|
||||
// Check if there are any non-removed VMware datacenters in the zone.
|
||||
//if (_vmwareDatacenterZoneMapDao.findByZoneId(zoneId) != null) {
|
||||
// throw new CloudRuntimeException(errorMsg + "there are VMware datacenters in this zone.");
|
||||
|
||||
@ -36,6 +36,9 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.cloud.user.User;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
@ -143,6 +146,8 @@ public class ConfigurationManagerTest {
|
||||
HostPodDao _podDao;
|
||||
@Mock
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Mock
|
||||
ImageStoreDao _imageStoreDao;
|
||||
|
||||
VlanVO vlan = new VlanVO(Vlan.VlanType.VirtualNetwork, "vlantag", "vlangateway", "vlannetmask", 1L, "iprange", 1L, 1L, null, null, null);
|
||||
|
||||
@ -174,6 +179,7 @@ public class ConfigurationManagerTest {
|
||||
configurationMgr._clusterDao = _clusterDao;
|
||||
configurationMgr._podDao = _podDao;
|
||||
configurationMgr._physicalNetworkDao = _physicalNetworkDao;
|
||||
configurationMgr._imageStoreDao = _imageStoreDao;
|
||||
|
||||
|
||||
Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
|
||||
@ -679,6 +685,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -696,6 +703,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -713,6 +721,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -726,6 +735,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -739,6 +749,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -756,6 +767,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(arrayList);
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -773,6 +785,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(arrayList);
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<PhysicalNetworkVO>());
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
@ -790,6 +803,7 @@ public class ConfigurationManagerTest {
|
||||
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
|
||||
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(new ArrayList<VolumeVO>());
|
||||
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(arrayList);
|
||||
Mockito.when(_imageStoreDao.findByScope(any(ZoneScope.class))).thenReturn(new ArrayList<ImageStoreVO>());
|
||||
|
||||
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
|
||||
}
|
||||
|
||||
@ -53,5 +53,5 @@
|
||||
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
<bean id="userIpAddressDetailsDao" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
|
||||
<bean id="loadBalancerVMMapDaoImpl" class="com.cloud.network.dao.LoadBalancerVMMapDaoImpl" />
|
||||
|
||||
<bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.ImageStoreDaoImpl" />
|
||||
</beans>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user