cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaya...@apache.org
Subject git commit: updated refs/heads/master to 1a89bc0
Date Tue, 06 Aug 2013 11:58:48 GMT
Updated Branches:
  refs/heads/master c1e78809b -> 1a89bc06c


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>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1a89bc06
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1a89bc06
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1a89bc06

Branch: refs/heads/master
Commit: 1a89bc06c83703fa690d37a0cce055d5b0f3b27d
Parents: c1e7880
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Tue Aug 6 16:09:22 2013 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Tue Aug 6 17:28:22 2013 +0530

----------------------------------------------------------------------
 engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java     | 2 ++
 engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java | 6 ++++++
 server/src/com/cloud/network/NetworkServiceImpl.java          | 7 ++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a89bc06/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java b/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java
index de68e1e..28cd027 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDao.java
@@ -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);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a89bc06/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java
index 3ac2729..d3a2409 100755
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterVnetDaoImpl.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a89bc06/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 39663e1..f8bdb4e 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -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());


Mime
View raw message