Skip to content

Commit 2b6ca5a

Browse files
author
Alena Prokharchyk
committed
listRemoteAccessVpns: implemented search by networkId and id
1 parent b12904b commit 2b6ca5a

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.cloudstack.api.ApiConstants;
2424
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
2525
import org.apache.cloudstack.api.Parameter;
26-
import org.apache.cloudstack.api.BaseCmd.CommandType;
2726
import org.apache.cloudstack.api.response.FirewallResponse;
2827
import org.apache.cloudstack.api.response.FirewallRuleResponse;
2928
import org.apache.cloudstack.api.response.IPAddressResponse;

‎api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.Parameter;
2626
import org.apache.cloudstack.api.response.IPAddressResponse;
2727
import org.apache.cloudstack.api.response.ListResponse;
28+
import org.apache.cloudstack.api.response.NetworkResponse;
2829
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
2930
import org.apache.log4j.Logger;
3031

@@ -41,8 +42,16 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC
4142
//////////////// API parameters /////////////////////
4243
/////////////////////////////////////////////////////
4344
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.UUID, entityType=IPAddressResponse.class,
44-
required=true, description="public ip address id of the vpn server")
45+
description="public ip address id of the vpn server")
4546
private Long publicIpId;
47+
48+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = RemoteAccessVpnResponse.class,
49+
description="Lists remote access vpn rule with the specified ID", since="4.3")
50+
private Long id;
51+
52+
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
53+
description="list remote access VPNs for ceratin network", since="4.3")
54+
private Long networkId;
4655

4756
/////////////////////////////////////////////////////
4857
/////////////////// Accessors ///////////////////////
@@ -52,6 +61,14 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC
5261
public Long getPublicIpId() {
5362
return publicIpId;
5463
}
64+
65+
public Long getId() {
66+
return id;
67+
}
68+
69+
public Long getNetworkId() {
70+
return networkId;
71+
}
5572

5673
/////////////////////////////////////////////////////
5774
/////////////// API Implementation///////////////////

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
import javax.inject.Inject;
2626
import javax.naming.ConfigurationException;
2727

28-
import org.apache.log4j.Logger;
2928
import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
3029
import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
3130
import org.apache.cloudstack.context.CallContext;
3231
import org.apache.cloudstack.framework.config.ConfigKey;
3332
import org.apache.cloudstack.framework.config.Configurable;
3433
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
34+
import org.apache.log4j.Logger;
3535

3636
import com.cloud.configuration.Config;
3737
import com.cloud.domain.DomainVO;
@@ -81,10 +81,10 @@
8181
import com.cloud.utils.db.JoinBuilder;
8282
import com.cloud.utils.db.SearchBuilder;
8383
import com.cloud.utils.db.SearchCriteria;
84-
import com.cloud.utils.db.TransactionCallback;
85-
import com.cloud.utils.db.TransactionCallbackNoReturn;
8684
import com.cloud.utils.db.SearchCriteria.Op;
8785
import com.cloud.utils.db.Transaction;
86+
import com.cloud.utils.db.TransactionCallback;
87+
import com.cloud.utils.db.TransactionCallbackNoReturn;
8888
import com.cloud.utils.db.TransactionCallbackWithException;
8989
import com.cloud.utils.db.TransactionStatus;
9090
import com.cloud.utils.net.NetUtils;
@@ -592,6 +592,8 @@ public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(
592592
// do some parameter validation
593593
Account caller = CallContext.current().getCallingAccount();
594594
Long ipAddressId = cmd.getPublicIpId();
595+
Long vpnId = cmd.getId();
596+
Long networkId = cmd.getNetworkId();
595597
List<Long> permittedAccounts = new ArrayList<Long>();
596598

597599
if (ipAddressId != null) {
@@ -619,6 +621,8 @@ public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(
619621
_accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
620622

621623
sb.and("serverAddressId", sb.entity().getServerAddressId(), Op.EQ);
624+
sb.and("id", sb.entity().getId(), Op.EQ);
625+
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
622626
sb.and("state", sb.entity().getState(), Op.EQ);
623627

624628
SearchCriteria<RemoteAccessVpnVO> sc = sb.create();
@@ -630,6 +634,14 @@ public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(
630634
if (ipAddressId != null) {
631635
sc.setParameters("serverAddressId", ipAddressId);
632636
}
637+
638+
if (vpnId != null) {
639+
sc.setParameters("id", vpnId);
640+
}
641+
642+
if (networkId != null) {
643+
sc.setParameters("networkId", networkId);
644+
}
633645

634646
Pair<List<RemoteAccessVpnVO>, Integer> result = _remoteAccessVpnDao.searchAndCount(sc, filter);
635647
return new Pair<List<? extends RemoteAccessVpn>, Integer> (result.first(), result.second());

0 commit comments

Comments
 (0)