You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2014/03/20 11:55:41 UTC

[2/2] git commit: updated refs/heads/4.4 to e0c1bf7

persist fact that network can span multiple zones, if network offering
has strechedL2Subnet capability and return the zones in which network
spans in the networkreponse object


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

Branch: refs/heads/4.4
Commit: e0c1bf710728a87acad07519e8ff3f3139a9e543
Parents: e35d729
Author: Murali Reddy <mu...@gmail.com>
Authored: Thu Mar 20 16:21:00 2014 +0530
Committer: Murali Reddy <mu...@gmail.com>
Committed: Thu Mar 20 16:25:15 2014 +0530

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/ApiConstants.java    |  3 ++-
 .../cloudstack/api/response/NetworkResponse.java   | 17 +++++++++++++++++
 .../engine/orchestration/NetworkOrchestrator.java  |  1 +
 server/src/com/cloud/api/ApiDBUtils.java           | 10 ++++++++++
 server/src/com/cloud/api/ApiResponseHelper.java    | 12 ++++++++++++
 5 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0c1bf71/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index cc2c93b..0cfc9b8 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -595,7 +595,8 @@ public class ApiConstants {
     public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet";
     public static final String REGION_LEVEL_VPC = "regionlevelvpc";
     public static final String READ_ONLY = "readonly";
-
+    public static final String STRECHED_L2_SUBNET = "strechedl2subnet";
+    public static final String NETWORK_SPANNED_ZONES = "zonesnetworkspans";
 
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0c1bf71/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
index bf92aa4..beeeb57 100644
--- a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
 
 import java.util.List;
 
+import java.util.Set;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
@@ -216,6 +217,14 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
     @Param(description = "ACL Id associated with the VPC network")
     private String aclId;
 
+    @SerializedName(ApiConstants.STRECHED_L2_SUBNET)
+    @Param(description = "true if network can span multiple zones")
+    private Boolean strechedL2Subnet;
+
+    @SerializedName(ApiConstants.NETWORK_SPANNED_ZONES)
+    @Param(description = "If a network is enabled for 'streched l2 subnet' then represents zones on which network currently spans")
+    private Set<String> networkSpannedZones;
+
     public Boolean getDisplayNetwork() {
         return displayNetwork;
     }
@@ -412,4 +421,12 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
     public void setAclId(String aclId) {
         this.aclId = aclId;
     }
+
+    public void setStrechedL2Subnet(Boolean strechedL2Subnet) {
+        this.strechedL2Subnet = strechedL2Subnet;
+    }
+
+    public void setNetworkSpannedZones(Set<String> networkSpannedZones) {
+        this.networkSpannedZones = networkSpannedZones;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0c1bf71/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 00c2d1a..96dafe9 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -667,6 +667,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                         NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), relatedFile, name, displayText, predefined
                                 .getNetworkDomain(), offering.getGuestType(), plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(), vpcId);
                         vo.setDisplayNetwork(isDisplayNetworkEnabled == null ? true : isDisplayNetworkEnabled);
+                        vo.setStrechedL2Network(offering.getSupportsStrechedL2());
                         networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
                                 finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0c1bf71/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 432eb94..67e47f7 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1091,6 +1091,16 @@ public class ApiDBUtils {
         return s_userVmDao.listByHostId(hostId);
     }
 
+    public static List<UserVmVO> listUserVMsByNetworkId(long networkId) {
+        return s_userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Running,
+                VirtualMachine.State.Starting, VirtualMachine.State.Stopping, VirtualMachine.State.Unknown,
+                VirtualMachine.State.Migrating);
+    }
+
+    public static List<DomainRouterVO> listDomainRoutersByNetworkId(long networkId) {
+        return s_domainRouterDao.findByNetwork(networkId);
+    }
+
     public static List<DataCenterVO> listZones() {
         return s_zoneDao.listAll();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0c1bf71/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index bc496a3..ed04ec9 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2205,6 +2205,18 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
         }
 
+        response.setStrechedL2Subnet(network.isStrechedL2Network());
+        if (network.isStrechedL2Network()) {
+            Set<String> networkSpannedZones = new  HashSet<String>();
+            List<VMInstanceVO> vmInstances = new ArrayList<VMInstanceVO>();
+            vmInstances.addAll(ApiDBUtils.listUserVMsByNetworkId(network.getId()));
+            vmInstances.addAll(ApiDBUtils.listDomainRoutersByNetworkId(network.getId()));
+            for (VirtualMachine vm : vmInstances) {
+                DataCenter vmZone = ApiDBUtils.findZoneById(vm.getDataCenterId());
+                networkSpannedZones.add(vmZone.getUuid());
+            }
+            response.setNetworkSpannedZones(networkSpannedZones);
+        }
         response.setObjectName("network");
         return response;
     }