mirror of https://github.com/apache/cloudstack.git
Cloudstack-4015 No error logged when deleteing all the valns when there are allocateed vnets. Alos not updating the vnet range in physicalnetworks table in the above case.
Signed-off-by: Jayapal <jayapal@apache.org>
This commit is contained in:
parent
c1e78809b2
commit
1a89bc06c8
|
|
@ -48,4 +48,6 @@ public interface DataCenterVnetDao extends GenericDao<DataCenterVnetVO, Long> {
|
|||
public int countVnetsDedicatedToAccount(long dcId, long accountId);
|
||||
|
||||
List<String> listVnetsByPhysicalNetworkAndDataCenter(long dcId, long physicalNetworkId);
|
||||
|
||||
int countAllocatedVnets(long physicalNetworkId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countAllocatedVnets(long physicalNetworkId){
|
||||
SearchCriteria<DataCenterVnetVO> sc = DcSearchAllocated.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
return listBy(sc).size();
|
||||
}
|
||||
public List<DataCenterVnetVO> listAllocatedVnetsInRange(long dcId, long physicalNetworkId, Integer start, Integer end) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = DcSearchAllocatedInRange.create();
|
||||
sc.setParameters("dc",dcId);
|
||||
|
|
|
|||
|
|
@ -2713,6 +2713,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
if (vnetRanges.size() == 0) {
|
||||
//this implies remove all vlans.
|
||||
removeVnets.addAll(vnetsInDb);
|
||||
int allocated_vnets = _datacneter_vnet.countAllocatedVnets(network.getId());
|
||||
if (allocated_vnets > 0) {
|
||||
throw new InvalidParameterValueException("physicalnetwork "+ network.getId() + " has "+ allocated_vnets + " vnets in use");
|
||||
}
|
||||
return removeVnets;
|
||||
}
|
||||
for (Pair<Integer, Integer>vlan : vnetRanges) {
|
||||
|
|
@ -2735,7 +2739,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
_datacneter_vnet.lockRange(network.getDataCenterId(), network.getId(), start, end);
|
||||
List<DataCenterVnetVO> result = _datacneter_vnet.listAllocatedVnetsInRange(network.getDataCenterId(), network.getId(), start, end);
|
||||
if (!result.isEmpty()){
|
||||
throw new InvalidParameterValueException("Some of the vnets from this range are allocated, can only remove a range which has no allocated vnets");
|
||||
throw new InvalidParameterValueException("physicalnetwork "+ network.getId() + " has allocated vnets in the range "+ start+"-"+end);
|
||||
|
||||
}
|
||||
// If the range is partially dedicated to an account fail the request
|
||||
List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(network.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue