cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaya...@apache.org
Subject [3/4] git commit: updated refs/heads/master to 59bf355
Date Tue, 06 May 2014 14:51:58 GMT
CLOUDSTACK-6578: Fixed issue in delete remote access vpn command


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

Branch: refs/heads/master
Commit: 40836344de54091d795817f41a4fa136ecdb0f5d
Parents: b9b623b
Author: Jayapal <jayapal@apache.org>
Authored: Mon May 5 13:56:59 2014 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Tue May 6 20:08:30 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/network/vpn/RemoteAccessVpnService.java   |  2 +-
 .../api/command/user/vpn/DeleteRemoteAccessVpnCmd.java  |  6 +++++-
 .../cloud/network/vpn/RemoteAccessVpnManagerImpl.java   | 12 ++++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40836344/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 acf007b..decf8c4 100644
--- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
+++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
@@ -33,7 +33,7 @@ public interface RemoteAccessVpnService {
 
     RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean
openFirewall, Boolean forDisplay) 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;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40836344/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 f894124..37b7b5a 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
@@ -20,6 +20,8 @@ import org.apache.log4j.Logger;
 
 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;
@@ -91,7 +93,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/40836344/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 0f734dd..9d9118c 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -285,15 +285,16 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
 
     @Override
     @DB
-    public void destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException
{
+    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, AccessType.OperateEntry, vpn);
 
+        RemoteAccessVpn.State prevState = vpn.getState();
         vpn.setState(RemoteAccessVpn.State.Removed);
         _remoteAccessVpnDao.update(vpn.getId(), vpn);
 
@@ -305,6 +306,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
@@ -366,6 +373,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
                 }
             }
         }
+        return success;
     }
 
     @Override


Mime
View raw message