cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [20/35] git commit: updated refs/heads/marvin_refactor to 4abd929
Date Fri, 19 Apr 2013 11:28:34 GMT
CLOUDSTACK-2088. Dedicated Public IP Addresses per tenant. Guest Network in a project acquires
IPs at random even from the IP ranges which are dedicated to other accounts.
Modified search to return only IP's belonging to system pool


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

Branch: refs/heads/marvin_refactor
Commit: f8d4a23343d963ec9d2b9eec8e29f965c2e2198d
Parents: 977162b
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Fri Apr 19 07:00:26 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Fri Apr 19 07:02:46 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/dc/dao/VlanDao.java           |    2 +
 server/src/com/cloud/dc/dao/VlanDaoImpl.java       |   19 +++++++++++++++
 .../src/com/cloud/network/NetworkManagerImpl.java  |   16 ++++++++----
 3 files changed, 31 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8d4a233/server/src/com/cloud/dc/dao/VlanDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/VlanDao.java b/server/src/com/cloud/dc/dao/VlanDao.java
old mode 100644
new mode 100755
index 6423688..cc82632
--- a/server/src/com/cloud/dc/dao/VlanDao.java
+++ b/server/src/com/cloud/dc/dao/VlanDao.java
@@ -50,4 +50,6 @@ public interface VlanDao extends GenericDao<VlanVO, Long> {
 	List<VlanVO> listVlansByNetworkId(long networkId);
 	
 	List<VlanVO> listVlansByPhysicalNetworkId(long physicalNetworkId);
+
+        List<VlanVO> listZoneWideNonDedicatedVlans(long zoneId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8d4a233/server/src/com/cloud/dc/dao/VlanDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/VlanDaoImpl.java b/server/src/com/cloud/dc/dao/VlanDaoImpl.java
old mode 100644
new mode 100755
index c5a635f..100295b
--- a/server/src/com/cloud/dc/dao/VlanDaoImpl.java
+++ b/server/src/com/cloud/dc/dao/VlanDaoImpl.java
@@ -58,6 +58,9 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements
VlanDao
     protected SearchBuilder<VlanVO> ZoneVlanSearch;
     protected SearchBuilder<VlanVO> NetworkVlanSearch;
     protected SearchBuilder<VlanVO> PhysicalNetworkVlanSearch;
+    protected SearchBuilder<VlanVO> ZoneWideNonDedicatedVlanSearch;
+
+    protected SearchBuilder<AccountVlanMapVO> AccountVlanMapSearch;
 
     @Inject protected PodVlanMapDao _podVlanMapDao;
     @Inject protected AccountVlanMapDao _accountVlanMapDao;
@@ -198,6 +201,14 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements
VlanDao
         PodVlanSearch2.done();
         ZoneTypePodSearch.done();
 
+        ZoneWideNonDedicatedVlanSearch = createSearchBuilder();
+        ZoneWideNonDedicatedVlanSearch.and("zoneId", ZoneWideNonDedicatedVlanSearch.entity().getDataCenterId(),
SearchCriteria.Op.EQ);
+        AccountVlanMapSearch = _accountVlanMapDao.createSearchBuilder();
+        AccountVlanMapSearch.and("accountId", AccountVlanMapSearch.entity().getAccountId(),
SearchCriteria.Op.NULL);
+        ZoneWideNonDedicatedVlanSearch.join("AccountVlanMapSearch", AccountVlanMapSearch,
ZoneWideNonDedicatedVlanSearch.entity().getId(), AccountVlanMapSearch.entity().getVlanDbId(),
JoinBuilder.JoinType.LEFTOUTER);
+        ZoneWideNonDedicatedVlanSearch.done();
+        AccountVlanMapSearch.done();
+
         return result;
     }
 
@@ -312,4 +323,12 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements
VlanDao
         sc.setParameters("physicalNetworkId", physicalNetworkId);
         return listBy(sc);
     }	
+
+    @Override
+    public List<VlanVO> listZoneWideNonDedicatedVlans(long zoneId) {
+        SearchCriteria<VlanVO> sc = ZoneWideNonDedicatedVlanSearch.create();
+        sc.setParameters("ZoneWideNonDedicatedVlanSearch", "zoneId", zoneId);
+        return listBy(sc);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8d4a233/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 7332ef3..114402b 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -581,6 +581,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         VlanType vlanType = VlanType.VirtualNetwork;
         boolean assign = false;
         boolean allocateFromDedicatedRange = false;
+        List<Long> dedicatedVlanDbIds = new ArrayList<Long>();
+        List<Long> nonDedicatedVlanDbIds = new ArrayList<Long>();
 
         if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType()))
{
             // zone is of type DataCenter. See DataCenterVO.java.
@@ -615,18 +617,17 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             txn.start();
 
             // If account has dedicated Public IP ranges, allocate IP from the dedicated
range
-            List<Long> vlanDbIds = new ArrayList<Long>();
             List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByAccount(ipOwner.getId());
             for (AccountVlanMapVO map : maps) {
-                vlanDbIds.add(map.getVlanDbId());
+                dedicatedVlanDbIds.add(map.getVlanDbId());
             }
-            if (vlanDbIds != null && !vlanDbIds.isEmpty()) {
+            if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) {
                 allocateFromDedicatedRange = true;
             }
 
             try {
                 if (allocateFromDedicatedRange) {
-                    ip = fetchNewPublicIp(zone.getId(), null, vlanDbIds, ipOwner, vlanType,
null,
+                    ip = fetchNewPublicIp(zone.getId(), null, dedicatedVlanDbIds, ipOwner,
vlanType, null,
                             false, assign, null, isSystem, null);
                 }
             } catch(InsufficientAddressCapacityException e) {
@@ -637,12 +638,15 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             }
 
             if (!allocateFromDedicatedRange) {
-                ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null,
false, assign, null,
+                List<VlanVO> nonDedicatedVlans = _vlanDao.listZoneWideNonDedicatedVlans(zone.getId());
+                for (VlanVO nonDedicatedVlan : nonDedicatedVlans) {
+                    nonDedicatedVlanDbIds.add(nonDedicatedVlan.getId());
+                }
+                ip = fetchNewPublicIp(zone.getId(), null, nonDedicatedVlanDbIds, ipOwner,
vlanType, null, false, assign, null,
                        isSystem, null);
             }
 
             if (ip == null) {
-
                 InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException
                         ("Unable to find available public IP addresses", DataCenter.class,
zone.getId());
                 ex.addProxyObject(ApiDBUtils.findZoneById(zone.getId()).getUuid());


Mime
View raw message