Skip to content

Commit 5d989f3

Browse files
committed
CLOUDSTACK-9162: Handled vpn user add when vpn is not enabled on the account
1 parent 8b3cadb commit 5d989f3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void execute() {
124124
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
125125
}
126126
}catch (Exception ex) {
127-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user due to resource unavailable");
127+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
128128
}
129129

130130
VpnUsersResponse vpnResponse = new VpnUsersResponse();

server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
import com.cloud.utils.db.TransactionCallbackWithException;
9191
import com.cloud.utils.db.TransactionStatus;
9292
import com.cloud.utils.net.NetUtils;
93+
import org.apache.commons.collections.CollectionUtils;
9394

9495
public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService, Configurable {
9596
private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnManagerImpl.class);
@@ -508,6 +509,12 @@ public boolean applyVpnUsers(long vpnOwnerId, String userName) throws ResourceU
508509

509510
s_logger.debug("Applying vpn users for " + owner);
510511
List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId);
512+
513+
if (CollectionUtils.isEmpty(vpns)) {
514+
s_logger.debug("There are no remote access vpns configured on this account " + owner +" to apply vpn user, failing add vpn user ");
515+
return false;
516+
}
517+
511518
RemoteAccessVpnVO vpnTemp = null;
512519

513520
List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId);

0 commit comments

Comments
 (0)