incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [18/32] git commit: CS-15999: added nics to domain router api response
Date Thu, 16 Aug 2012 23:49:03 GMT
CS-15999: added nics to domain router api response

Conflicts:

	server/src/com/cloud/api/ApiResponseHelper.java


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

Branch: refs/heads/4.0
Commit: 516cfb5300b594ebc72c8dfd861ef9702e34f8ee
Parents: a74df01
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Aug 16 10:31:49 2012 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Thu Aug 16 16:40:16 2012 -0700

----------------------------------------------------------------------
 .../cloud/api/response/DomainRouterResponse.java   |    9 +++++
 server/src/com/cloud/api/ApiResponseHelper.java    |   28 ++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/516cfb53/api/src/com/cloud/api/response/DomainRouterResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/DomainRouterResponse.java b/api/src/com/cloud/api/response/DomainRouterResponse.java
index 99885b1..d710aad 100644
--- a/api/src/com/cloud/api/response/DomainRouterResponse.java
+++ b/api/src/com/cloud/api/response/DomainRouterResponse.java
@@ -17,6 +17,7 @@
 package com.cloud.api.response;
 
 import java.util.Date;
+import java.util.List;
 
 import com.cloud.api.ApiConstants;
 import com.cloud.serializer.Param;
@@ -140,6 +141,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
     @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
     private IdentityProxy vpcId = new IdentityProxy("vpc");
     
+    @SerializedName("nic")  @Param(description="the list of nics associated with the router",

+            responseObject = NicResponse.class, since="4.0")
+    private List<NicResponse> nics;
+    
     @Override
     public Long getObjectId() {
     	return getId();
@@ -312,4 +317,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
     public void setVpcId(Long vpcId) {
         this.vpcId.setValue(vpcId);
     }
+    
+    public void setNics(List<NicResponse> nics) {
+        this.nics = nics;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/516cfb53/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 0340a94..a0a4c17 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1701,8 +1701,10 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
             routerResponse.setPodId(router.getPodIdToDeployIn());
             List<NicProfile> nicProfiles = ApiDBUtils.getNics(router);
+            List<NicResponse> nicResponses = new ArrayList<NicResponse>();
             for (NicProfile singleNicProfile : nicProfiles) {
                 Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
+                //legacy code, public/control/guest nic info is kept in nics response object
                 if (network != null) {
                     if (network.getTrafficType() == TrafficType.Public) {
                         routerResponse.setPublicIp(singleNicProfile.getIp4Address());
@@ -1722,8 +1724,32 @@ public class ApiResponseHelper implements ResponseGenerator {
                         routerResponse.setGuestNetworkId(singleNicProfile.getNetworkId());
                         routerResponse.setNetworkDomain(network.getNetworkDomain());
                     }
+
+                    NicResponse nicResponse = new NicResponse();
+                    nicResponse.setId(singleNicProfile.getId());
+                    nicResponse.setIpaddress(singleNicProfile.getIp4Address());
+                    nicResponse.setGateway(singleNicProfile.getGateway());
+                    nicResponse.setNetmask(singleNicProfile.getNetmask());
+                    nicResponse.setNetworkid(singleNicProfile.getNetworkId());
+                    nicResponse.setNetworkName(network.getName());
+                    
+                    if (singleNicProfile.getBroadCastUri() != null) {
+                        nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
+                    }
+                    if (singleNicProfile.getIsolationUri() != null) {
+                        nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
+                    }
+
+                    nicResponse.setTrafficType(network.getTrafficType().toString());
+                    if (network.getGuestType() != null) {
+                        nicResponse.setType(network.getGuestType().toString());  
+                    }
+                    nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
+                    nicResponse.setObjectName("nic");
+                    nicResponses.add(nicResponse);  
                 }
             }
+            routerResponse.setNics(nicResponses);
         }
 
         // Service Offering Info
@@ -3892,4 +3918,4 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setObjectName("vpnconnection");
         return response;
     }
-}
+}
\ No newline at end of file


Mime
View raw message