You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2012/07/23 23:57:40 UTC

[12/13] git commit: cloudstack 3.0 API - listVpnConnections API - add gatewayIp, guestCidrList, ipsecPsk, ikePolicy, espPolicy, lifetime property (get it from customerGateway object).

cloudstack 3.0 API - listVpnConnections API - add gatewayIp, guestCidrList,ipsecPsk, ikePolicy, espPolicy, lifetime property (get it from customerGateway object).


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

Branch: refs/heads/vpc
Commit: 830901d7ccad0f53a637fe3c1912447e9db36478
Parents: 196885e
Author: Jessica Wang <je...@citrix.com>
Authored: Mon Jul 2 13:39:14 2012 -0700
Committer: Sheng Yang <sh...@citrix.com>
Committed: Mon Jul 23 14:21:10 2012 -0700

----------------------------------------------------------------------
 .../response/Site2SiteVpnConnectionResponse.java   |   46 ++++++++++++++-
 server/src/com/cloud/api/ApiDBUtils.java           |    8 +++
 server/src/com/cloud/api/ApiResponseHelper.java    |   16 +++++-
 3 files changed, 66 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/830901d7/api/src/com/cloud/api/response/Site2SiteVpnConnectionResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/Site2SiteVpnConnectionResponse.java b/api/src/com/cloud/api/response/Site2SiteVpnConnectionResponse.java
index 398c8b7..54daf95 100644
--- a/api/src/com/cloud/api/response/Site2SiteVpnConnectionResponse.java
+++ b/api/src/com/cloud/api/response/Site2SiteVpnConnectionResponse.java
@@ -31,12 +31,30 @@ public class Site2SiteVpnConnectionResponse extends BaseResponse {
     @SerializedName(ApiConstants.S2S_VPN_GATEWAY_ID) @Param(description="the vpn gateway ID")
     private IdentityProxy vpnGatewayId= new IdentityProxy("s2s_vpn_gateway");
     
-    @SerializedName(ApiConstants.PUBLIC_IP) @Param(description="the public IP address")
+    @SerializedName(ApiConstants.PUBLIC_IP) @Param(description="the public IP address") //from VpnGateway
     private String ip;
 
     @SerializedName(ApiConstants.S2S_CUSTOMER_GATEWAY_ID) @Param(description="the customer gateway ID")
     private IdentityProxy customerGatewayId = new IdentityProxy("s2s_customer_gateway");
+        
+    @SerializedName(ApiConstants.GATEWAY) @Param(description="public ip address id of the customer gateway") //from CustomerGateway
+    private String gatewayIp;
 
+    @SerializedName(ApiConstants.CIDR_LIST) @Param(description="guest cidr list of the customer gateway") //from CustomerGateway
+    private String guestCidrList;
+
+    @SerializedName(ApiConstants.IPSEC_PSK) @Param(description="IPsec Preshared-Key of the customer gateway") //from CustomerGateway
+    private String ipsecPsk;
+
+    @SerializedName(ApiConstants.IKE_POLICY) @Param(description="IKE policy of the customer gateway") //from CustomerGateway
+    private String ikePolicy;
+
+    @SerializedName(ApiConstants.ESP_POLICY) @Param(description="ESP policy of the customer gateway") //from CustomerGateway
+    private String espPolicy;
+
+    @SerializedName(ApiConstants.LIFETIME) @Param(description="Lifetime of vpn connection to the customer gateway, in seconds") //from CustomerGateway
+    private Long lifetime;
+    
     @SerializedName(ApiConstants.CREATED) @Param(description="the date and time the host was created")
     private Date created;
 
@@ -58,7 +76,31 @@ public class Site2SiteVpnConnectionResponse extends BaseResponse {
     public void setCustomerGatewayId(Long customerGatewayId) {
         this.customerGatewayId.setValue(customerGatewayId);
     }
-
+    
+    public void setGatewayIp(String gatewayIp) {
+    	this.gatewayIp = gatewayIp;
+    }
+    
+    public void setGuestCidrList(String guestCidrList) {
+    	this.guestCidrList = guestCidrList;
+    }
+    
+    public void setIpsecPsk(String ipsecPsk) {
+    	this.ipsecPsk = ipsecPsk;
+    }
+    
+    public void setIkePolicy(String ikePolicy) {
+    	this.ikePolicy = ikePolicy;
+    }
+    
+    public void setEspPolicy(String espPolicy) {
+    	this.espPolicy = espPolicy;
+    }
+    
+    public void setLifetime(Long lifetime) {
+    	this.lifetime = lifetime;
+    }     
+    
     public void setCreated(Date created) {
         this.created = created;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/830901d7/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 1102e62..e1e8865 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -63,6 +63,7 @@ import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkRuleConfigVO;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Site2SiteVpnGatewayVO;
+import com.cloud.network.Site2SiteCustomerGatewayVO;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.dao.FirewallRulesCidrsDao;
 import com.cloud.network.dao.IPAddressDao;
@@ -71,6 +72,7 @@ import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkDomainDao;
 import com.cloud.network.dao.NetworkRuleConfigDao;
 import com.cloud.network.dao.Site2SiteVpnGatewayDao;
+import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
 import com.cloud.network.security.SecurityGroup;
 import com.cloud.network.security.SecurityGroupManager;
 import com.cloud.network.security.SecurityGroupVO;
@@ -186,6 +188,7 @@ public class ApiDBUtils {
     private static VlanDao _vlanDao;
     private static VolumeDao _volumeDao;
     private static Site2SiteVpnGatewayDao _site2SiteVpnGatewayDao;
+    private static Site2SiteCustomerGatewayDao _site2SiteCustomerGatewayDao;
     private static VolumeHostDao _volumeHostDao;
     private static DataCenterDao _zoneDao;
     private static NetworkOfferingDao _networkOfferingDao;
@@ -242,6 +245,7 @@ public class ApiDBUtils {
         _vlanDao = locator.getDao(VlanDao.class);
         _volumeDao = locator.getDao(VolumeDao.class);
         _site2SiteVpnGatewayDao = locator.getDao(Site2SiteVpnGatewayDao.class);
+        _site2SiteCustomerGatewayDao = locator.getDao(Site2SiteCustomerGatewayDao.class);
         _volumeHostDao = locator.getDao(VolumeHostDao.class);
         _zoneDao = locator.getDao(DataCenterDao.class);
         _securityGroupDao = locator.getDao(SecurityGroupDao.class);
@@ -563,6 +567,10 @@ public class ApiDBUtils {
         return _site2SiteVpnGatewayDao.findById(vpnGatewayId);
     }
     
+    public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) {    	
+    	return _site2SiteCustomerGatewayDao.findById(customerGatewayId);
+    }
+    
     public static List<UserVO> listUsersByAccount(long accountId) {
         return _userDao.listByAccount(accountId);
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/830901d7/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 d0c52e4..e79ec58 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -144,6 +144,7 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PhysicalNetworkTrafficType;
 import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.Site2SiteCustomerGateway;
+import com.cloud.network.Site2SiteCustomerGatewayVO;
 import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.Site2SiteVpnGateway;
 import com.cloud.network.Site2SiteVpnGatewayVO;
@@ -3795,14 +3796,25 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setVpnGatewayId(result.getVpnGatewayId()); 
         Long vpnGatewayId = result.getVpnGatewayId();
         if(vpnGatewayId != null) {
-        	Site2SiteVpnGatewayVO vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);//???
+        	Site2SiteVpnGatewayVO vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);
         	
         	long ipId = vpnGateway.getAddrId();
         	IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId);
         	response.setIp(ipObj.getAddress().addr());  
         }
         
-        response.setCustomerGatewayId(result.getCustomerGatewayId());
+        response.setCustomerGatewayId(result.getCustomerGatewayId()); 
+        Long customerGatewayId = result.getCustomerGatewayId();
+        if(customerGatewayId != null) {
+        	Site2SiteCustomerGatewayVO customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId);
+        	response.setGatewayIp(customerGateway.getGatewayIp());
+        	response.setGuestCidrList(customerGateway.getGuestCidrList());
+        	response.setIpsecPsk(customerGateway.getIpsecPsk());
+        	response.setIkePolicy(customerGateway.getIkePolicy());
+        	response.setEspPolicy(customerGateway.getEspPolicy());
+        	response.setLifetime(customerGateway.getLifetime());
+        }      
+                
         response.setCreated(result.getCreated());
         response.setRemoved(result.getRemoved());
         response.setObjectName("vpnconnection");