cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [09/20] git commit: updated refs/heads/4.3 to 67df5b9
Date Tue, 25 Nov 2014 19:05:05 GMT
CLOUDSTACK-6578: Fixed issue in delete remote access vpn command

(cherry picked from commit 40836344de54091d795817f41a4fa136ecdb0f5d)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
	server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java


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

Branch: refs/heads/4.3
Commit: dddc6488d45e1faca958326c252b36ece412bc84
Parents: 6ad3ae7
Author: Jayapal <jayapal@apache.org>
Authored: Mon May 5 13:56:59 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Nov 25 23:08:44 2014 +0530

----------------------------------------------------------------------
 .../cloud/network/vpn/RemoteAccessVpnService.java    |  4 +++-
 .../command/user/vpn/DeleteRemoteAccessVpnCmd.java   |  6 +++++-
 .../network/vpn/RemoteAccessVpnManagerImpl.java      | 15 ++++++++++++---
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dddc6488/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
index de7692d..ef5bd2b 100644
--- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
+++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
@@ -33,7 +33,9 @@ public interface RemoteAccessVpnService {
 
     RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean
openFirewall)
             throws NetworkRuleConflictException;
-    void destroyRemoteAccessVpnForIp(long vpnServerAddressId, Account caller) throws ResourceUnavailableException;
+
+    boolean destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException;
+
     RemoteAccessVpn startRemoteAccessVpn(long vpnServerAddressId, boolean openFirewall) throws
ResourceUnavailableException;
 
     VpnUser addVpnUser(long vpnOwnerId, String userName, String password);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dddc6488/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java
b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java
index 640a89a..fdd3c10 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java
@@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vpn;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.response.AccountResponse;
@@ -85,7 +87,9 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException {
-        _ravService.destroyRemoteAccessVpnForIp(publicIpId, CallContext.current().getCallingAccount());
+        if (! _ravService.destroyRemoteAccessVpnForIp(publicIpId, CallContext.current().getCallingAccount()))
{
+                       throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed
to delete remote access vpn");
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dddc6488/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 c7e67c1..0acb0a2 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -261,16 +261,18 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
         }
     }
 
-    @Override @DB
-    public void destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException
{
+    @Override
+    @DB
+    public boolean destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException
{
         final RemoteAccessVpnVO vpn = _remoteAccessVpnDao.findByPublicIpAddress(ipId);
         if (vpn == null) {
             s_logger.debug("there are no Remote access vpns for public ip address id=" +
ipId);
-            return;
+            return true;
         }
 
         _accountMgr.checkAccess(caller, null, true, vpn);
 
+        RemoteAccessVpn.State prevState = vpn.getState();
         vpn.setState(RemoteAccessVpn.State.Removed);
         _remoteAccessVpnDao.update(vpn.getId(), vpn);
 
@@ -282,6 +284,12 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
                     break;
                 }
             }
+        }catch (ResourceUnavailableException ex) {
+            vpn.setState(prevState);
+            _remoteAccessVpnDao.update(vpn.getId(), vpn);
+            s_logger.debug("Failed to stop the vpn " + vpn.getId() + " , so reverted state
to "+
+                    RemoteAccessVpn.State.Running);
+            success = false;
         } finally {
             if (success) {
                 //Cleanup corresponding ports
@@ -342,6 +350,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
                 }
             }
         }
+        return success;
     }
 
     @Override


Mime
View raw message