Persist vpn connection state before restarting (#4635)

If the vpn connection is in pending state then we cant restart the
vpn connection. So manually set the state to disconnected and then
try to restart the vpn connection
This commit is contained in:
Rakesh 2021-09-16 05:44:01 +02:00 committed by GitHub
parent 95ef292860
commit 1bf686269f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -610,13 +610,12 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn
}
_accountMgr.checkAccess(caller, null, false, conn);
if (conn.getState() == State.Pending) {
conn.setState(State.Disconnected);
}
if (conn.getState() == State.Connected || conn.getState() == State.Error
|| conn.getState() == State.Disconnected || conn.getState() == State.Connecting) {
stopVpnConnection(id);
}
// Set vpn state to disconnected
conn.setState(State.Disconnected);
_vpnConnectionDao.persist(conn);
// Stop and start the connection again
stopVpnConnection(id);
startVpnConnection(id);
conn = _vpnConnectionDao.findById(id);
return conn;