CLOUDSTACK-9162: Handled vpn user add when vpn is not enabled on the account

This commit is contained in:
Jayapal 2017-05-29 15:32:04 +05:30
parent 8b3cadb55e
commit 5d989f322c
2 changed files with 8 additions and 1 deletions

View File

@ -124,7 +124,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user"); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
} }
}catch (Exception ex) { }catch (Exception ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user due to resource unavailable"); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} }
VpnUsersResponse vpnResponse = new VpnUsersResponse(); VpnUsersResponse vpnResponse = new VpnUsersResponse();

View File

@ -90,6 +90,7 @@ import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionCallbackWithException; import com.cloud.utils.db.TransactionCallbackWithException;
import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import org.apache.commons.collections.CollectionUtils;
public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService, Configurable { public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService, Configurable {
private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnManagerImpl.class); private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnManagerImpl.class);
@ -508,6 +509,12 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
s_logger.debug("Applying vpn users for " + owner); s_logger.debug("Applying vpn users for " + owner);
List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId); List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId);
if (CollectionUtils.isEmpty(vpns)) {
s_logger.debug("There are no remote access vpns configured on this account " + owner +" to apply vpn user, failing add vpn user ");
return false;
}
RemoteAccessVpnVO vpnTemp = null; RemoteAccessVpnVO vpnTemp = null;
List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId); List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId);