VPC: added "forVpc" (boolean) parameter to listRouters call - filter by the fact if router belongs to VPC or not

This commit is contained in:
Alena Prokharchyk 2012-07-05 14:04:34 -07:00
parent d8cdb89721
commit a44843af69
2 changed files with 17 additions and 1 deletions

View File

@ -66,6 +66,9 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@IdentityMapper(entityTableName="vpc")
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
private Long vpcId;
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
private Boolean forVpc;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -102,6 +105,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
public Long getVpcId() {
return vpcId;
}
public Boolean getForVpc() {
return forVpc;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -1601,6 +1601,7 @@ public class ManagementServerImpl implements ManagementServer {
String keyword = cmd.getKeyword();
Long networkId = cmd.getNetworkId();
Long vpcId = cmd.getVpcId();
Boolean forVpc = cmd.getForVpc();
Account caller = UserContext.current().getCaller();
List<Long> permittedAccounts = new ArrayList<Long>();
@ -1622,6 +1623,14 @@ public class ManagementServerImpl implements ManagementServer {
sb.and("podId", sb.entity().getPodIdToDeployIn(), SearchCriteria.Op.EQ);
sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
if (forVpc != null) {
if (forVpc) {
sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NNULL);
} else {
sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NULL);
}
}
if (networkId != null) {
SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
@ -1632,7 +1641,7 @@ public class ManagementServerImpl implements ManagementServer {
sb.join("nicSearch", nicSearch, sb.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<DomainRouterVO> sc = sb.create();
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);