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

@ -71,6 +71,9 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@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 ///////////////////////
/////////////////////////////////////////////////////
@ -107,6 +110,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
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>();
@ -1618,6 +1619,14 @@ public class ManagementServerImpl implements ManagementServer {
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();
nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);