VPC: added forVpc parameter to listNetworks api call. If true, list networks not belonging to any vpc

This commit is contained in:
Alena Prokharchyk 2012-07-12 09:08:39 -07:00
parent 8db12e071f
commit 988831327a
2 changed files with 16 additions and 0 deletions

View File

@ -74,6 +74,9 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
@Parameter(name=ApiConstants.CAN_USE_FOR_DEPLOY, type=CommandType.BOOLEAN, description="list networks available for vm deployment")
private Boolean canUseForDeploy;
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="the network belongs to vpc")
private Boolean forVpc;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -126,6 +129,10 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd {
public Long getVpcId() {
return vpcId;
}
public Boolean getForVpc() {
return forVpc;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -3101,6 +3101,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Long vpcId = cmd.getVpcId();
Boolean canUseForDeploy = cmd.canUseForDeploy();
Map<String, String> tags = cmd.getTags();
Boolean forVpc = cmd.getForVpc();
// 1) default is system to false if not specified
// 2) reset parameter to false if it's specified by the regular user
@ -3171,6 +3172,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Filter searchFilter = new Filter(NetworkVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchBuilder<NetworkVO> sb = _networksDao.createSearchBuilder();
if (forVpc != null) {
if (forVpc) {
sb.and("vpc", sb.entity().getVpcId(), Op.NNULL);
} else {
sb.and("vpc", sb.entity().getVpcId(), Op.NULL);
}
}
// Don't display networks created of system network offerings
SearchBuilder<NetworkOfferingVO> networkOfferingSearch = _networkOfferingDao.createSearchBuilder();