mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Added isSystem parameter for listNetworks command, default value is false. If it's set to true, only system networks with trafficType=Public and and zone=Advanced are gonna be returned
This commit is contained in:
parent
c8bd857db6
commit
2ffcbb8815
@ -173,5 +173,6 @@ public class ApiConstants {
|
||||
public static final String NETWORK_ID = "networkid";
|
||||
public static final String SPECIFY_VLAN = "specifyvlan";
|
||||
public static final String IS_DEFAULT = "isdefault";
|
||||
public static final String IS_SYSTEM = "issystem";
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,9 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the type of the network")
|
||||
private String type;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SYSTEM, type=CommandType.BOOLEAN, description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -79,6 +82,10 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Boolean getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -57,6 +57,10 @@ public class NetworkResponse extends BaseResponse{
|
||||
@SerializedName("isshared")
|
||||
private Boolean isShared;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("issystem")
|
||||
private Boolean isSystem;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("state")
|
||||
private String state;
|
||||
@ -276,4 +280,12 @@ public class NetworkResponse extends BaseResponse{
|
||||
public void setVlan(String vlan) {
|
||||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public Boolean getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
public void setIsSystem(Boolean isSystem) {
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,4 +75,6 @@ public interface NetworkOffering {
|
||||
String getTags();
|
||||
|
||||
boolean isDefault();
|
||||
|
||||
boolean isSystemOnly();
|
||||
}
|
||||
|
||||
@ -2387,6 +2387,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setNetworkOfferingId(networkOffering.getId());
|
||||
response.setNetworkOfferingName(networkOffering.getName());
|
||||
response.setNetworkOfferingDisplayText(networkOffering.getDisplayText());
|
||||
response.setIsSystem(networkOffering.isSystemOnly());
|
||||
}
|
||||
|
||||
response.setIsShared(network.isShared());
|
||||
|
||||
@ -60,7 +60,9 @@ import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
@ -1775,8 +1777,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
String type = cmd.getType();
|
||||
Boolean isSystem = cmd.getIsSystem();
|
||||
Long accountId = null;
|
||||
|
||||
if (isSystem == null) {
|
||||
isSystem = false;
|
||||
}
|
||||
|
||||
if (isAdmin(account.getType())) {
|
||||
if (domainId != null) {
|
||||
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||
@ -1801,13 +1808,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
SearchBuilder<NetworkVO> sb = _networkConfigDao.createSearchBuilder();
|
||||
|
||||
//Don't display networks created of system network offerings
|
||||
SearchBuilder<NetworkOfferingVO> networkOfferingSearch = _networkOfferingDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkOfferingVO> networkOfferingSearch = _networkOfferingDao.createSearchBuilder();
|
||||
networkOfferingSearch.and("systemOnly", networkOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ);
|
||||
sb.join("networkOfferingSearch", networkOfferingSearch, sb.entity().getNetworkOfferingId(), networkOfferingSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
|
||||
if (isSystem) {
|
||||
networkOfferingSearch.and("trafficType", networkOfferingSearch.entity().getTrafficType(), SearchCriteria.Op.EQ);
|
||||
}
|
||||
sb.join("networkOfferingSearch", networkOfferingSearch, sb.entity().getNetworkOfferingId(), networkOfferingSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
|
||||
SearchBuilder<DataCenterVO> zoneSearch = _dcDao.createSearchBuilder();
|
||||
zoneSearch.and("networkType", zoneSearch.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSearch", zoneSearch, sb.entity().getDataCenterId(), zoneSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
|
||||
SearchCriteria<NetworkVO> sc = sb.create();
|
||||
sc.setJoinParameters("networkOfferingSearch", "systemOnly", false);
|
||||
|
||||
if (!isSystem) {
|
||||
sc.setJoinParameters("networkOfferingSearch", "systemOnly", false);
|
||||
} else {
|
||||
sc.setJoinParameters("networkOfferingSearch", "systemOnly", true);
|
||||
sc.setJoinParameters("networkOfferingSearch", "trafficType", TrafficType.Public);
|
||||
sc.setJoinParameters("zoneSearch", "networkType", NetworkType.Advanced.toString());
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
SearchCriteria<NetworkVO> ssc = _networkConfigDao.createSearchCriteria();
|
||||
|
||||
@ -129,6 +129,7 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
return created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSystemOnly() {
|
||||
return systemOnly;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user