Skip to content

Commit 9f11f52

Browse files
committed
listNetworks - don't return Networks created from systemOnly network offerings
1 parent 1c4c95f commit 9f11f52

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

‎server/src/com/cloud/api/ApiDispatcher.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params
6868
cmd.callCreate();
6969
} catch (Throwable t) {
7070
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
71-
s_logger.info("Exception: ", t);
71+
s_logger.info(t.getMessage());
7272
throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage());
7373
}else if (t instanceof PermissionDeniedException) {
74-
s_logger.info("Exception: ", t);
74+
s_logger.info(t.getMessage());
7575
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage());
7676
}else if (t instanceof AccountLimitException) {
77-
s_logger.info("Exception: ", t);
77+
s_logger.info(t.getMessage());
7878
throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage());
7979
}else if (t instanceof InsufficientCapacityException) {
80-
s_logger.info("Exception: ", t);
80+
s_logger.info(t.getMessage());
8181
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage());
8282
}else if (t instanceof ResourceAllocationException) {
83-
s_logger.info("Exception: ", t);
83+
s_logger.info(t.getMessage());
8484
throw new ServerApiException(BaseCmd.RESOURCE_ALLOCATION_ERROR, t.getMessage());
8585
}else if (t instanceof ResourceUnavailableException) {
8686
s_logger.warn("Exception: ", t);
@@ -106,16 +106,16 @@ public void dispatch(BaseCmd cmd, Map<String, String> params) {
106106
cmd.execute();
107107
} catch (Throwable t) {
108108
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
109-
s_logger.info("Exception: ", t);
109+
s_logger.info(t.getMessage());
110110
throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage());
111111
}else if (t instanceof PermissionDeniedException) {
112-
s_logger.info("Exception: ", t);
112+
s_logger.info(t.getMessage());
113113
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage());
114114
}else if (t instanceof AccountLimitException) {
115-
s_logger.info("Exception: ", t);
115+
s_logger.info(t.getMessage());
116116
throw new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage());
117117
}else if (t instanceof InsufficientCapacityException) {
118-
s_logger.info("Exception: ", t);
118+
s_logger.info(t.getMessage());
119119
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage());
120120
}else if (t instanceof ResourceAllocationException) {
121121
s_logger.warn("Exception: ", t);

‎server/src/com/cloud/network/NetworkManagerImpl.java‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import com.cloud.deploy.DataCenterDeployment;
7272
import com.cloud.deploy.DeployDestination;
7373
import com.cloud.deploy.DeploymentPlan;
74+
import com.cloud.domain.DomainVO;
7475
import com.cloud.domain.dao.DomainDao;
7576
import com.cloud.event.EventTypes;
7677
import com.cloud.event.EventUtils;
@@ -2016,9 +2017,17 @@ public List<? extends Network> searchForNetworks(ListNetworksCmd cmd) {
20162017
accountId = account.getId();
20172018
}
20182019

2019-
20202020
Filter searchFilter = new Filter(NetworkVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
2021-
SearchCriteria<NetworkVO> sc = _networkConfigDao.createSearchCriteria();
2021+
SearchBuilder<NetworkVO> sb = _networkConfigDao.createSearchBuilder();
2022+
2023+
//Don't display networks created of system network offerings
2024+
SearchBuilder<NetworkOfferingVO> networkOfferingSearch = _networkOfferingDao.createSearchBuilder();
2025+
networkOfferingSearch.and("systemOnly", networkOfferingSearch.entity().isSystemOnly(), SearchCriteria.Op.EQ);
2026+
sb.join("networkOfferingSearch", networkOfferingSearch, sb.entity().getNetworkOfferingId(), networkOfferingSearch.entity().getId(), JoinBuilder.JoinType.INNER);
2027+
2028+
2029+
SearchCriteria<NetworkVO> sc = sb.create();
2030+
sc.setJoinParameters("networkOfferingSearch", "systemOnly", false);
20222031

20232032
if (keyword != null) {
20242033
SearchCriteria<NetworkVO> ssc = _networkConfigDao.createSearchCriteria();
@@ -2033,6 +2042,7 @@ public List<? extends Network> searchForNetworks(ListNetworksCmd cmd) {
20332042
if (accountId != null) {
20342043
sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
20352044
}
2045+
20362046
return _networkConfigDao.search(sc, searchFilter);
20372047
}
20382048

0 commit comments

Comments
 (0)