mirror of https://github.com/apache/cloudstack.git
ListPortFowardingRules: added networkId to the list of optional parameters to list by
This commit is contained in:
parent
437f49cf8f
commit
f5c29c0f1a
|
|
@ -26,6 +26,7 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
|
|
@ -48,6 +49,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.UUID, entityType = IPAddressResponse.class,
|
||||
description="the id of IP address of the port forwarding services")
|
||||
private Long ipAddressId;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="list port forwarding rules for ceratin network", since="4.3")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -60,6 +65,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ public class FirewallRuleResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.VM_GUEST_IP) @Param(description="the vm ip address for the port forwarding rule")
|
||||
private String destNatVmIp;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the id of the guest network the port forwarding rule belongs to")
|
||||
private String networkId;
|
||||
|
||||
|
||||
public String getDestNatVmIp() {
|
||||
|
|
@ -196,4 +199,8 @@ public class FirewallRuleResponse extends BaseResponse {
|
|||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setNetworkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1024,6 +1024,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setPublicEndPort(Integer.toString(fwRule.getSourcePortEnd()));
|
||||
List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(fwRule.getId());
|
||||
response.setCidrList(StringUtils.join(cidrs, ","));
|
||||
|
||||
Network guestNtwk = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
|
||||
response.setNetworkId(guestNtwk.getUuid());
|
||||
|
||||
IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
|
||||
response.setPublicIpAddressId(ip.getUuid());
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import java.util.Set;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -75,10 +75,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.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -783,6 +783,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
Long ipId = cmd.getIpAddressId();
|
||||
Long id = cmd.getId();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
Long networkId = cmd.getNetworkId();
|
||||
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
|
@ -808,6 +809,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
sb.and("id", sb.entity().getId(), Op.EQ);
|
||||
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
|
||||
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
|
||||
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
|
|
@ -842,6 +844,10 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
if (ipId != null) {
|
||||
sc.setParameters("ip", ipId);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
|
||||
sc.setParameters("purpose", Purpose.PortForwarding);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue