mirror of https://github.com/apache/cloudstack.git
Fixed listIpForwardingRules command: made ipAddress required, added vm and rule state info to the response.
This commit is contained in:
parent
1f7d74dbec
commit
829d6fe8a0
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
|
|||
AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
|
||||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||
AllFieldsSearch.and("ip", AllFieldsSearch.entity().getSourceIpAddress(), Op.EQ);
|
||||
AllFieldsSearch.and("proto", AllFieldsSearch.entity().getProtocol(), Op.EQ);
|
||||
AllFieldsSearch.and("protocol", AllFieldsSearch.entity().getProtocol(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
ApplicationSearch = createSearchBuilder();
|
||||
|
|
|
|||
Loading…
Reference in New Issue