mirror of https://github.com/apache/cloudstack.git
VPC: added forVpc parameter to listNetworks api call. If true, list networks not belonging to any vpc
This commit is contained in:
parent
8db12e071f
commit
988831327a
|
|
@ -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///////////////////
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue