cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [24/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 2a99064
Date Tue, 09 Apr 2013 13:21:01 GMT
CLOUDSTACK-240: added id/uuid fields to remote_access_vpn table and corresponding VO/Dao objects.
The DB upgrade is covered as well. Now tags can be created for the VPN object


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

Branch: refs/heads/marvin_refactor
Commit: 8821bfb7cfe7107cbd738d793222a9d1edcf45cc
Parents: b7b8fdc
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Mar 29 10:36:55 2013 -0700
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Sun Mar 31 22:06:28 2013 +0530

----------------------------------------------------------------------
 .../api/response/RemoteAccessVpnResponse.java      |    7 +++
 .../com/cloud/network/dao/RemoteAccessVpnVO.java   |    6 +-
 .../router/VirtualNetworkApplianceManagerImpl.java |    4 +-
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |    6 +-
 .../src/com/cloud/upgrade/dao/Upgrade410to420.java |   41 +++++++++++++-
 setup/db/db/schema-410to420-cleanup.sql            |    2 -
 6 files changed, 52 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java b/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java
index 5e08bca..e8d7eb4 100644
--- a/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java
@@ -61,6 +61,9 @@ public class RemoteAccessVpnResponse extends BaseResponse implements ControlledE
     @SerializedName(ApiConstants.ID) @Param(description="the id of the remote access vpn")
     private String id;
 
+    @SerializedName(ApiConstants.ID) @Param(description="the id of the remote access vpn")
+    private String id;
+
     public void setPublicIp(String publicIp) {
         this.publicIp = publicIp;
     }
@@ -108,4 +111,8 @@ public class RemoteAccessVpnResponse extends BaseResponse implements ControlledE
         this.id = id;
     }
 
+    public void setId(String id) {
+        this.id = id;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/server/src/com/cloud/network/dao/RemoteAccessVpnVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/RemoteAccessVpnVO.java b/server/src/com/cloud/network/dao/RemoteAccessVpnVO.java
index 2e8ee91..a518ba1 100644
--- a/server/src/com/cloud/network/dao/RemoteAccessVpnVO.java
+++ b/server/src/com/cloud/network/dao/RemoteAccessVpnVO.java
@@ -53,16 +53,16 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
     
     @Column(name="state")
     private State state;
-    
+
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     @Column(name="id")
     private long id;
-    
+
     @Column(name="uuid")
     private String uuid;
 
-    public RemoteAccessVpnVO() { 
+    public RemoteAccessVpnVO() {
         this.uuid = UUID.randomUUID().toString();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 50188e7..d551d37 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -303,8 +303,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements
V
     @Inject
     VpnUserDao _vpnUsersDao;
     @Inject
-    RemoteAccessVpnDao _remoteAccessVpnDao;
-    @Inject
     RulesManager _rulesMgr;
     @Inject
     NetworkDao _networkDao;
@@ -2337,7 +2335,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                 }
       
                 if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn,
provider)) {
-                    RemoteAccessVpn vpn = _vpnDao.findById(ip.getId());
+                    RemoteAccessVpn vpn = _vpnDao.findByPublicIpAddress(ip.getId());
                     if (vpn != null) {
                         vpns.add(vpn);
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index 673535a..4b4a04b 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -184,15 +184,15 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
         long startIp = NetUtils.ip2Long(range[0]);
         String newIpRange = NetUtils.long2Ip(++startIp) + "-" + range[1];
         String sharedSecret = PasswordGenerator.generatePresharedKey(_pskLength);
-        
+
         Transaction txn = Transaction.currentTxn();
         txn.start();
-        
+
         _rulesMgr.reservePorts(ipAddr, NetUtils.UDP_PROTO, Purpose.Vpn, openFirewall, caller,
NetUtils.VPN_PORT, NetUtils.VPN_L2TP_PORT, NetUtils.VPN_NATT_PORT);
         vpnVO = new RemoteAccessVpnVO(ipAddr.getAccountId(), ipAddr.getDomainId(), ipAddr.getAssociatedWithNetworkId(),
                 publicIpId, range[0], newIpRange, sharedSecret);
         RemoteAccessVpn vpn = _remoteAccessVpnDao.persist(vpnVO);
-        
+
         txn.commit();
         return vpn;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
index dd0aa3e..5144ab6 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -17,9 +17,6 @@
 
 package com.cloud.upgrade.dao;
 
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
-
 import java.io.File;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -29,6 +26,9 @@ import java.util.UUID;
 
 import org.apache.log4j.Logger;
 
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
 public class Upgrade410to420 implements DbUpgrade {
 	final static Logger s_logger = Logger.getLogger(Upgrade410to420.class);
 
@@ -61,6 +61,7 @@ public class Upgrade410to420 implements DbUpgrade {
 	public void performDataMigration(Connection conn) {
         upgradeVmwareLabels(conn);
         createPlaceHolderNics(conn);
+        updateRemoteAccessVpn(conn);
         PreparedStatement sql = null;
         try {
             sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where
type = 'SYSTEM' or type = 'BUILTIN'");
@@ -196,4 +197,38 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
     }
+
+
+    private void updateRemoteAccessVpn(Connection conn) {
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
+
+        try {
+            pstmt = conn.prepareStatement("SELECT vpn_server_addr_id FROM `cloud`.`remote_access_vpn`");
+            rs = pstmt.executeQuery();
+            long id=1;
+            while (rs.next()) {
+                    String uuid = UUID.randomUUID().toString();
+                    Long ipId = rs.getLong(1);
+                    pstmt = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` set
uuid=?, id=? where vpn_server_addr_id=?");
+                    pstmt.setString(1, uuid);
+                    pstmt.setLong(2, id);
+                    pstmt.setLong(3, ipId);
+                    pstmt.executeUpdate();
+                    id++;
+            }
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn
table", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8821bfb7/setup/db/db/schema-410to420-cleanup.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420-cleanup.sql b/setup/db/db/schema-410to420-cleanup.sql
index 187076f..d3d5ca3 100644
--- a/setup/db/db/schema-410to420-cleanup.sql
+++ b/setup/db/db/schema-410to420-cleanup.sql
@@ -24,5 +24,3 @@ ALTER TABLE remote_access_vpn DROP foreign key `fk_remote_access_vpn__vpn_server
 ALTER TABLE remote_access_vpn DROP primary key;
 ALTER TABLE remote_access_vpn ADD primary key (`id`);
 ALTER TABLE remote_access_vpn ADD CONSTRAINT `fk_remote_access_vpn__vpn_server_addr_id` FOREIGN
KEY (`vpn_server_addr_id`) REFERENCES `user_ip_address` (`id`);
-
-


Mime
View raw message