mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6578: Fixed issue in delete remote access vpn command
(cherry picked from commit 40836344de)
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
This commit is contained in:
parent
6ad3ae78e4
commit
dddc6488d4
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue