Skip to content

Commit 1bf6862

Browse files
authored
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
1 parent 95ef292 commit 1bf6862

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,12 @@ public Site2SiteVpnConnection resetVpnConnection(ResetVpnConnectionCmd cmd) thro
610610
}
611611
_accountMgr.checkAccess(caller, null, false, conn);
612612

613-
if (conn.getState() == State.Pending) {
614-
conn.setState(State.Disconnected);
615-
}
616-
if (conn.getState() == State.Connected || conn.getState() == State.Error
617-
|| conn.getState() == State.Disconnected || conn.getState() == State.Connecting) {
618-
stopVpnConnection(id);
619-
}
613+
// Set vpn state to disconnected
614+
conn.setState(State.Disconnected);
615+
_vpnConnectionDao.persist(conn);
616+
617+
// Stop and start the connection again
618+
stopVpnConnection(id);
620619
startVpnConnection(id);
621620
conn = _vpnConnectionDao.findById(id);
622621
return conn;

0 commit comments

Comments
 (0)