Skip to content

Commit 6540ff8

Browse files
author
Kishan Kavala
committed
bug CLOUDSTACK-198: VPN user add, on failure remove user currently being added only, other users will remain in Add state
1 parent 2da5b44 commit 6540ff8

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

api/src/com/cloud/api/commands/AddVpnUserCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public String getEventType() {
120120
public void execute(){
121121
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
122122
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
123-
if (!_ravService.applyVpnUsers(vpnUser.getAccountId())) {
123+
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
124124
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
125125
}
126126

api/src/com/cloud/api/commands/RemoveVpnUserCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void execute(){
113113
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");
114114
}
115115

116-
if (!_ravService.applyVpnUsers(owner.getId())) {
116+
if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
117117
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply vpn user removal");
118118
}
119119
SuccessResponse response = new SuccessResponse(getCommandName());

api/src/com/cloud/network/vpn/RemoteAccessVpnService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, b
3535
VpnUser addVpnUser(long vpnOwnerId, String userName, String password);
3636
boolean removeVpnUser(long vpnOwnerId, String userName);
3737
List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);
38-
boolean applyVpnUsers(long vpnOwnerId);
38+
boolean applyVpnUsers(long vpnOwnerId, String userName);
3939

4040
List<? extends RemoteAccessVpn> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);
4141
List<? extends VpnUser> searchForVpnUsers(ListVpnUsersCmd cmd);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public RemoteAccessVpnVO startRemoteAccessVpn(long vpnId, boolean openFirewall)
418418

419419
@DB
420420
@Override
421-
public boolean applyVpnUsers(long vpnOwnerId) {
421+
public boolean applyVpnUsers(long vpnOwnerId, String userName) {
422422
Account caller = UserContext.current().getCaller();
423423
Account owner = _accountDao.findById(vpnOwnerId);
424424
_accountMgr.checkAccess(caller, null, true, owner);
@@ -481,7 +481,7 @@ public boolean applyVpnUsers(long vpnOwnerId) {
481481
_vpnUsersDao.remove(user.getId());
482482
}
483483
} else {
484-
if (user.getState() == State.Add) {
484+
if (user.getState() == State.Add && (user.getUsername()).equals(userName)) {
485485
Transaction txn = Transaction.currentTxn();
486486
txn.start();
487487
_vpnUsersDao.remove(user.getId());

0 commit comments

Comments
 (0)