listRemoteAccessVpns: implemented search by networkId and id
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/96b9ebaf Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/96b9ebaf Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/96b9ebaf Branch: refs/heads/ui-restyle Commit: 96b9ebafc0a9107d75462b37fa8ee270c91d4a95 Parents: 5a12165 Author: Alena Prokharchyk <[email protected]> Authored: Wed Nov 13 13:34:36 2013 -0800 Committer: Alena Prokharchyk <[email protected]> Committed: Wed Nov 13 14:26:15 2013 -0800 ---------------------------------------------------------------------- .../user/firewall/ListFirewallRulesCmd.java | 1 - .../user/vpn/ListRemoteAccessVpnsCmd.java | 19 ++++++++++++++++++- .../network/vpn/RemoteAccessVpnManagerImpl.java | 18 +++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96b9ebaf/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java index 38c8e62..ae1a2dd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java @@ -23,7 +23,6 @@ import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.BaseCmd.CommandType; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.IPAddressResponse; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96b9ebaf/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java index 12ee95b..3b4d6cd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java @@ -25,6 +25,7 @@ import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.RemoteAccessVpnResponse; import org.apache.log4j.Logger; @@ -41,8 +42,16 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.UUID, entityType=IPAddressResponse.class, - required=true, description="public ip address id of the vpn server") + description="public ip address id of the vpn server") private Long publicIpId; + + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = RemoteAccessVpnResponse.class, + description="Lists remote access vpn rule with the specified ID", since="4.3") + private Long id; + + @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, + description="list remote access VPNs for ceratin network", since="4.3") + private Long networkId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -52,6 +61,14 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC public Long getPublicIpId() { return publicIpId; } + + public Long getId() { + return id; + } + + public Long getNetworkId() { + return networkId; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96b9ebaf/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 504e5e8..9483465 100755 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -25,13 +25,13 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd; import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.log4j.Logger; import com.cloud.configuration.Config; import com.cloud.domain.DomainVO; @@ -81,10 +81,10 @@ import com.cloud.utils.db.Filter; import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.TransactionCallback; -import com.cloud.utils.db.TransactionCallbackNoReturn; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; +import com.cloud.utils.db.TransactionCallback; +import com.cloud.utils.db.TransactionCallbackNoReturn; import com.cloud.utils.db.TransactionCallbackWithException; import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.net.NetUtils; @@ -592,6 +592,8 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc // do some parameter validation Account caller = CallContext.current().getCallingAccount(); Long ipAddressId = cmd.getPublicIpId(); + Long vpnId = cmd.getId(); + Long networkId = cmd.getNetworkId(); List<Long> permittedAccounts = new ArrayList<Long>(); if (ipAddressId != null) { @@ -619,6 +621,8 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); sb.and("serverAddressId", sb.entity().getServerAddressId(), Op.EQ); + sb.and("id", sb.entity().getId(), Op.EQ); + sb.and("networkId", sb.entity().getNetworkId(), Op.EQ); sb.and("state", sb.entity().getState(), Op.EQ); SearchCriteria<RemoteAccessVpnVO> sc = sb.create(); @@ -630,6 +634,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc if (ipAddressId != null) { sc.setParameters("serverAddressId", ipAddressId); } + + if (vpnId != null) { + sc.setParameters("id", vpnId); + } + + if (networkId != null) { + sc.setParameters("networkId", networkId); + } Pair<List<RemoteAccessVpnVO>, Integer> result = _remoteAccessVpnDao.searchAndCount(sc, filter); return new Pair<List<? extends RemoteAccessVpn>, Integer> (result.first(), result.second());
