cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthon...@apache.org
Subject git commit: updated refs/heads/4.4-forward to 8c5a9ec
Date Wed, 21 May 2014 21:45:35 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 7bbad0491 -> 8c5a9ec4d


if networkID is not specified, get one network with free ips.


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

Branch: refs/heads/4.4-forward
Commit: 8c5a9ec4de2745aae551938dbf37ca459ec0297f
Parents: 7bbad04
Author: Anthony Xu <anthony.xu@citrix.com>
Authored: Wed May 21 14:33:52 2014 -0700
Committer: Anthony Xu <anthony.xu@citrix.com>
Committed: Wed May 21 14:39:48 2014 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkModel.java     |  4 +++-
 .../src/com/cloud/network/NetworkModelImpl.java | 25 ++++++++++++++++++++
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  2 +-
 .../com/cloud/network/MockNetworkModelImpl.java |  9 +++++++
 .../com/cloud/vpc/MockNetworkModelImpl.java     |  9 +++++++
 5 files changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c5a9ec4/api/src/com/cloud/network/NetworkModel.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java
index f6555db..574160d 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -90,6 +90,8 @@ public interface NetworkModel {
 
     boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
 
+    Network getNetworkWithSGWithFreeIPs(Long zoneId);
+
     Network getNetworkWithSecurityGroupEnabled(Long zoneId);
 
     String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
@@ -273,4 +275,4 @@ public interface NetworkModel {
     boolean isNetworkReadyForGc(long networkId);
 
     boolean getNetworkEgressDefaultPolicy(Long networkId);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c5a9ec4/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 7b4b2be..3d2b133 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -737,6 +737,31 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
     }
 
     @Override
+    public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
+        List<NetworkVO> networks = _networksDao.listByZoneSecurityGroup(zoneId);
+        if (networks == null || networks.isEmpty()) {
+            return null;
+        }
+        NetworkVO ret_network = null;
+        for (NetworkVO nw : networks) {
+            List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(nw.getId());
+            for (VlanVO vlan : vlans) {
+                if (_ipAddressDao.countFreeIpsInVlan(vlan.getId()) > 0) {
+                    ret_network = nw;
+                    break;
+                }
+            }
+            if (ret_network != null) {
+                break;
+            }
+        }
+        if (ret_network == null) {
+            s_logger.debug("Can not find network with security group enabled with free IPs");
+        }
+        return ret_network;
+    }
+
+    @Override
     public NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId) {
         List<NetworkVO> networks = _networksDao.listByZoneSecurityGroup(zoneId);
         if (networks == null || networks.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c5a9ec4/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 58709ec..cf04270 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2356,7 +2356,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
         // If no network is specified, find system security group enabled network
         if (networkIdList == null || networkIdList.isEmpty()) {
-            Network networkWithSecurityGroup = _networkModel.getNetworkWithSecurityGroupEnabled(zone.getId());
+            Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId());
             if (networkWithSecurityGroup == null) {
                 throw new InvalidParameterValueException("No network with security enabled
is found in zone id=" + zone.getId());
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c5a9ec4/server/test/com/cloud/network/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkModelImpl.java b/server/test/com/cloud/network/MockNetworkModelImpl.java
index 6c9e597..14c42f3 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -228,6 +228,15 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
     }
 
     /* (non-Javadoc)
+     * @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long)
+     */
+    @Override
+    public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
      * @see com.cloud.network.NetworkModel#getNetworkWithSecurityGroupEnabled(java.lang.Long)
      */
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c5a9ec4/server/test/com/cloud/vpc/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkModelImpl.java b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
index 67ab8e8..1364644 100644
--- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
@@ -239,6 +239,15 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
     }
 
     /* (non-Javadoc)
+     * @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long)
+     */
+    @Override
+    public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
      * @see com.cloud.network.NetworkModel#getNetworkWithSecurityGroupEnabled(java.lang.Long)
      */
     @Override


Mime
View raw message