CLOUDSTACK-6601: added "forDisplay" parameter to listLoadBalancerRules API

This commit is contained in:
Alena Prokharchyk 2014-05-07 16:57:10 -07:00
parent 66d5ebc657
commit b7b89b1297
2 changed files with 19 additions and 2 deletions

View File

@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
@ -32,6 +31,7 @@ import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.utils.Pair;
@ -71,6 +71,9 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list by network id the rule belongs to")
private Long networkId;
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin})
private Boolean display;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@ -99,6 +102,14 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
return networkId;
}
@Override
public Boolean getDisplay() {
if (display != null) {
return display;
}
return super.getDisplay();
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////

View File

@ -2252,6 +2252,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
Long instanceId = cmd.getVirtualMachineId();
Long networkId = cmd.getNetworkId();
Map<String, String> tags = cmd.getTags();
Boolean forDisplay = cmd.getDisplay();
Account caller = CallContext.current().getCallingAccount();
List<Long> permittedDomains = new ArrayList<Long>();
@ -2275,6 +2276,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
sb.and("sourceIpAddress", sb.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
sb.and("scheme", sb.entity().getScheme(), SearchCriteria.Op.EQ);
sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
if (instanceId != null) {
SearchBuilder<LoadBalancerVMMapVO> lbVMSearch = _lb2VmMapDao.createSearchBuilder();
@ -2344,6 +2346,10 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
}
if (forDisplay != null) {
sc.setParameters("display", forDisplay);
}
//list only Public load balancers using this command
sc.setParameters("scheme", Scheme.Public);