cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 3582c65
Date Tue, 21 Feb 2017 00:10:59 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 74036d01c -> 3582c653f


CLOUDSTACK-9711: Fixed error reporting while adding vpn user


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

Branch: refs/heads/master
Commit: 9805f0ed5aadd4496380f36535fd7a31440a32d0
Parents: 0db4471
Author: Jayapal <jayapal.uradi@accelerite.com>
Authored: Wed Dec 28 15:22:23 2016 +0530
Committer: Jayapal <jayapal.uradi@accelerite.com>
Committed: Wed Dec 28 15:22:23 2016 +0530

----------------------------------------------------------------------
 api/src/com/cloud/network/vpn/RemoteAccessVpnService.java |  2 +-
 .../cloudstack/api/command/user/vpn/AddVpnUserCmd.java    |  8 ++++++--
 .../cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java |  9 +++++++--
 .../com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java | 10 +++++++++-
 4 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9805f0ed/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 d089b85..5426d18 100644
--- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
+++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
@@ -43,7 +43,7 @@ public interface RemoteAccessVpnService {
 
     List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);
 
-    boolean applyVpnUsers(long vpnOwnerId, String userName);
+    boolean applyVpnUsers(long vpnOwnerId, String userName) throws ResourceUnavailableException;
 
     Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd
cmd);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9805f0ed/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
index 9993102..f6a30b3 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
@@ -119,8 +119,12 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
     public void execute() {
         VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
         Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
-        if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
-            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn
user");
+        try {
+            if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add
vpn user");
+            }
+        }catch (Exception ex) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn
user due to resource unavailable");
         }
 
         VpnUsersResponse vpnResponse = new VpnUsersResponse();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9805f0ed/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
index f552b14..140bdad 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
@@ -115,9 +115,14 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn
user");
         }
 
-        if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
-            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn
user removal");
+        try {
+            if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply
vpn user removal");
+            }
+        }catch (Exception ex) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn
user due to resource unavailable");
         }
+
         SuccessResponse response = new SuccessResponse(getCommandName());
         setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9805f0ed/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 065c097..2e23474 100644
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -501,13 +501,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
 
     @DB
     @Override
-    public boolean applyVpnUsers(long vpnOwnerId, String userName) {
+    public boolean applyVpnUsers(long vpnOwnerId, String userName) throws  ResourceUnavailableException
{
         Account caller = CallContext.current().getCallingAccount();
         Account owner = _accountDao.findById(vpnOwnerId);
         _accountMgr.checkAccess(caller, null, true, owner);
 
         s_logger.debug("Applying vpn users for " + owner);
         List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId);
+        RemoteAccessVpnVO vpnTemp  = null;
 
         List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId);
 
@@ -537,12 +538,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
                             } else {
                                 finals[i] = false;
                                 success = false;
+                                vpnTemp = vpn;
                             }
                         }
                     }
                 } catch (Exception e) {
                     s_logger.warn("Unable to apply vpn users ", e);
                     success = false;
+                    vpnTemp = vpn;
 
                     for (int i = 0; i < finals.length; i++) {
                         finals[i] = false;
@@ -575,6 +578,11 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements
RemoteAcc
             }
         }
 
+        if (!success) {
+            throw new  ResourceUnavailableException("Failed add vpn user due to Resource
unavailable ",
+                    RemoteAccessVPNServiceProvider.class, vpnTemp.getId());
+        }
+
         return success;
     }
 


Mime
View raw message