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 234ae447ee
commit 83f566cfe7
2 changed files with 17 additions and 1 deletions

View File

@ -70,6 +70,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 ///////////////////////
@ -106,6 +109,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
public Long getVpcId() {
return vpcId;
}
public Boolean getForVpc() {
return forVpc;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -1596,6 +1596,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>();
@ -1617,6 +1618,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();
@ -1627,7 +1636,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);