diff --git a/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java b/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java index e481813be97..fb950f45760 100644 --- a/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java +++ b/api/src/com/cloud/api/commands/ListIpForwardingRulesCmd.java @@ -26,7 +26,6 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.FirewallRuleResponse; import com.cloud.api.response.IpForwardingRuleResponse; import com.cloud.api.response.ListResponse; @@ -43,7 +42,7 @@ public class ListIpForwardingRulesCmd extends BaseListCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="list the rule belonging to this public ip address") + @Parameter(name=ApiConstants.IP_ADDRESS, required=true, type=CommandType.STRING, description="list the rule belonging to this public ip address") private String publicIpAddress; @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the ip forwarding rule. Must be used with the domainId parameter.") diff --git a/api/src/com/cloud/api/response/IpForwardingRuleResponse.java b/api/src/com/cloud/api/response/IpForwardingRuleResponse.java index feae3d89a99..36ea1c9ed03 100644 --- a/api/src/com/cloud/api/response/IpForwardingRuleResponse.java +++ b/api/src/com/cloud/api/response/IpForwardingRuleResponse.java @@ -40,6 +40,9 @@ public class IpForwardingRuleResponse extends BaseResponse { @SerializedName("ipaddress") @Param(description="the public ip address for the port forwarding rule") private String publicIpAddress; + @SerializedName("state") @Param(description="state of the ip forwarding rule") + private String state; + public Long getId() { return id; } @@ -87,4 +90,12 @@ public class IpForwardingRuleResponse extends BaseResponse { public void setPublicIpAddress(String publicIpAddress) { this.publicIpAddress = publicIpAddress; } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index f15704d46e8..088425efaea 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -1066,7 +1066,6 @@ public class ApiResponseHelper implements ResponseGenerator { response.setPublicPort(Integer.toString(fwRule.getSourcePortStart())); response.setPublicIpAddress(fwRule.getSourceIpAddress().toString()); if (fwRule.getSourceIpAddress() != null && fwRule.getDestinationIpAddress() != null) { - //UserVm vm = ApiDBUtils.findUserVmByPublicIpAndGuestIp(fwRule.getSourceIpAddress().toString(), fwRule.getDestinationIpAddress().toString()); UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId()); if(vm != null){ response.setVirtualMachineId(vm.getId()); @@ -1091,13 +1090,19 @@ public class ApiResponseHelper implements ResponseGenerator { response.setProtocol(fwRule.getProtocol()); response.setPublicIpAddress(fwRule.getSourceIpAddress().addr()); if (fwRule.getSourceIpAddress() != null && fwRule.getDestinationIpAddress() != null) { - UserVm vm = ApiDBUtils.findUserVmByPublicIpAndGuestIp(fwRule.getSourceIpAddress().addr(), fwRule.getDestinationIpAddress().addr()); + UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId()); if(vm != null){//vm might be destroyed response.setVirtualMachineId(vm.getId()); response.setVirtualMachineName(vm.getHostName()); response.setVirtualMachineDisplayName(vm.getDisplayName()); } } + FirewallRule.State state = fwRule.getState(); + String stateToSet = state.toString(); + if (state.equals(FirewallRule.State.Revoke)) { + stateToSet = "Deleting"; + } + response.setState(stateToSet); response.setObjectName("ipforwardingrule"); return response; } diff --git a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java index 2aaefecb3c2..998462480f7 100644 --- a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java +++ b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java @@ -44,7 +44,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase