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/master to df6ce24
Date Wed, 21 May 2014 21:34:29 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 96f092a0a -> df6ce24f4


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/df6ce24f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/df6ce24f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/df6ce24f

Branch: refs/heads/master
Commit: df6ce24f43572418ea8dccdc924ea22e232c0906
Parents: 96f092a
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:33:52 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/df6ce24f/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 f48bc9a..468feb3 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -92,6 +92,8 @@ public interface NetworkModel {
 
     boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
 
+    Network getNetworkWithSGWithFreeIPs(Long zoneId);
+
     Network getNetworkWithSecurityGroupEnabled(Long zoneId);
 
     String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
@@ -277,4 +279,4 @@ public interface NetworkModel {
     boolean getNetworkEgressDefaultPolicy(Long networkId);
 
     void checkNetworkPermissions(Account owner, Network network, AccessType accessType);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df6ce24f/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 918ebf8..3aa797b 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -741,6 +741,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/df6ce24f/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 a563fad..11cea13 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2350,7 +2350,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/df6ce24f/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 1740040..f4f04da 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -230,6 +230,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/df6ce24f/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 c9e975a..4903090 100644
--- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
@@ -241,6 +241,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