mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
bug 8831: added 2 new parameters to create/listNetworks api: "isdedicatedtodomain" and "dedicateddomainid"
This commit is contained in:
parent
7103d30f57
commit
e9a10c53dc
@ -97,6 +97,12 @@ public class NetworkResponse extends BaseResponse{
|
||||
|
||||
@SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is enabled, false otherwise")
|
||||
private Boolean isSecurityGroupEnabled;
|
||||
|
||||
@SerializedName("isdedicatedtodomain") @Param(description="true if network is dedicated to specific domain")
|
||||
private Boolean isDedicatedToDomain;
|
||||
|
||||
@SerializedName("dedicateddomainid") @Param(description="the id of domain network dedicated to")
|
||||
private Long dedicatedDomainId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -337,5 +343,21 @@ public class NetworkResponse extends BaseResponse{
|
||||
public void setIsSecurityGroupEnabled(Boolean sgEnabled) {
|
||||
this.isSecurityGroupEnabled = sgEnabled;
|
||||
}
|
||||
|
||||
public Boolean getIsDedicatedToDomain() {
|
||||
return isDedicatedToDomain;
|
||||
}
|
||||
|
||||
public void setIsDedicatedToDomain(Boolean isDedicatedToDomain) {
|
||||
this.isDedicatedToDomain = isDedicatedToDomain;
|
||||
}
|
||||
|
||||
public Long getDedicatedDomainId() {
|
||||
return dedicatedDomainId;
|
||||
}
|
||||
|
||||
public void setDedicatedDomainId(Long dedicatedDomainId) {
|
||||
this.dedicatedDomainId = dedicatedDomainId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -72,4 +72,6 @@ public interface NetworkService {
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
boolean isNetworkAvailableInDomain(long networkId, long domainId);
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
}
|
||||
|
||||
@ -543,4 +543,8 @@ public class ApiDBUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Long getDedicatedNetworkDomain(long networkId) {
|
||||
return _networkMgr.getDedicatedNetworkDomain(networkId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2350,6 +2350,15 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setDomainId(domain.getId());
|
||||
response.setDomain(domain.getName());
|
||||
}
|
||||
|
||||
Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId());
|
||||
if (dedicatedDomainId != null) {
|
||||
response.setIsDedicatedToDomain(true);
|
||||
response.setDedicatedDomainId(dedicatedDomainId);
|
||||
} else {
|
||||
response.setIsDedicatedToDomain(false);
|
||||
}
|
||||
|
||||
response.setObjectName("network");
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ import com.cloud.network.dao.IPAddressDaoImpl;
|
||||
import com.cloud.network.dao.LoadBalancerDaoImpl;
|
||||
import com.cloud.network.dao.LoadBalancerVMMapDaoImpl;
|
||||
import com.cloud.network.dao.NetworkDaoImpl;
|
||||
import com.cloud.network.dao.NetworkDomainDaoImpl;
|
||||
import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
@ -258,6 +259,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
||||
addDao("OvsTunnelAccountDao", OvsTunnelAccountDaoImpl.class);
|
||||
addDao("StoragePoolWorkDao", StoragePoolWorkDaoImpl.class);
|
||||
addDao("HostTagsDao", HostTagsDaoImpl.class);
|
||||
addDao("NetworkDomainDao", NetworkDomainDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
public class NetworkDomainDaoImpl extends GenericDaoBase<NetworkDomainVO, Long> implements GenericDao<NetworkDomainVO, Long> {
|
||||
public NetworkDomainDaoImpl() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -89,6 +89,7 @@ import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkDomainDao;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
@ -198,6 +199,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Adapters<NetworkGuru> _networkGurus;
|
||||
@Inject(adapter = NetworkElement.class)
|
||||
Adapters<NetworkElement> _networkElements;
|
||||
@Inject
|
||||
NetworkDomainDao _networkDomainDao;
|
||||
|
||||
private HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
@ -2682,12 +2685,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
|
||||
List<NetworkVO> networks = _networksDao.listSharedDomainNetworksByNetworkId(networkId);
|
||||
if (networks.isEmpty()) {
|
||||
List<NetworkDomainVO> networkDomainMap = _networkDomainDao.listDomainNetworkMapByNetworkId(networkId);
|
||||
if (networkDomainMap.isEmpty()) {
|
||||
s_logger.trace("Network id=" + networkId + " is shared, but not domain specific");
|
||||
return true;
|
||||
} else {
|
||||
networkDomainId = networks.get(0).getDomainId();
|
||||
networkDomainId = networkDomainMap.get(0).getDomainId();
|
||||
}
|
||||
|
||||
if (domainId == networkDomainId.longValue()) {
|
||||
@ -2704,4 +2707,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDedicatedNetworkDomain(long networkId) {
|
||||
List<NetworkDomainVO> networkMaps = _networkDomainDao.listDomainNetworkMapByNetworkId(networkId);
|
||||
if (!networkMaps.isEmpty()) {
|
||||
return networkMaps.get(0).getDomainId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,8 +61,5 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> {
|
||||
List<NetworkVO> listByZoneSecurityGroup(Long zoneId);
|
||||
void addDomainToNetwork(long networkId, long domainId);
|
||||
|
||||
List<NetworkVO> listSharedDomainNetworksByDomain(long domainId);
|
||||
List<NetworkVO> listSharedDomainNetworksByNetworkId(long networkId);
|
||||
|
||||
List<NetworkVO> listNetworksBy(boolean isShared);
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import javax.persistence.TableGenerator;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkAccountDaoImpl;
|
||||
import com.cloud.network.NetworkAccountVO;
|
||||
import com.cloud.network.NetworkDomainDaoImpl;
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -52,7 +51,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
final SearchBuilder<NetworkVO> AccountNetworkSearch;
|
||||
final SearchBuilder<NetworkVO> ZoneBroadcastUriSearch;
|
||||
final SearchBuilder<NetworkVO> ZoneSecurityGroupSearch;
|
||||
final SearchBuilder<NetworkVO> DomainSearch;
|
||||
|
||||
NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
|
||||
NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class);
|
||||
@ -113,13 +111,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
|
||||
_tgMacAddress = _tgs.get("macAddress");
|
||||
|
||||
DomainSearch = createSearchBuilder();
|
||||
SearchBuilder<NetworkDomainVO> domainJoin = _domainsDao.createSearchBuilder();
|
||||
domainJoin.and("domainId", domainJoin.entity().getDomainId(), Op.EQ);
|
||||
domainJoin.and("networkId", domainJoin.entity().getNetworkId(), Op.EQ);
|
||||
DomainSearch.join("domains", domainJoin, DomainSearch.entity().getId(), domainJoin.entity().getNetworkId(), JoinBuilder.JoinType.INNER);
|
||||
DomainSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -295,22 +286,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
_domainsDao.persist(domain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listSharedDomainNetworksByDomain(long domainId) {
|
||||
SearchCriteria<NetworkVO> sc = DomainSearch.create();
|
||||
sc.setJoinParameters("domains", "domainId", domainId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listSharedDomainNetworksByNetworkId(long networkId) {
|
||||
SearchCriteria<NetworkVO> sc = DomainSearch.create();
|
||||
sc.setJoinParameters("domains", "networkId", networkId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listNetworksBy(boolean isShared) {
|
||||
SearchCriteria<NetworkVO> sc = AllFieldsSearch.create();
|
||||
|
||||
29
server/src/com/cloud/network/dao/NetworkDomainDao.java
Normal file
29
server/src/com/cloud/network/dao/NetworkDomainDao.java
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NetworkDomainDao extends GenericDao<NetworkDomainVO, Long>{
|
||||
List<NetworkDomainVO> listDomainNetworkMapByDomain(long domainId);
|
||||
List<NetworkDomainVO> listDomainNetworkMapByNetworkId(long networkId);
|
||||
}
|
||||
61
server/src/com/cloud/network/dao/NetworkDomainDaoImpl.java
Normal file
61
server/src/com/cloud/network/dao/NetworkDomainDaoImpl.java
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value=NetworkDomainDao.class) @DB(txn=false)
|
||||
public class NetworkDomainDaoImpl extends GenericDaoBase<NetworkDomainVO, Long> implements NetworkDomainDao {
|
||||
final SearchBuilder<NetworkDomainVO> AllFieldsSearch;
|
||||
|
||||
|
||||
protected NetworkDomainDaoImpl() {
|
||||
super();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), Op.EQ);
|
||||
AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkDomainVO> listDomainNetworkMapByDomain(long domainId) {
|
||||
SearchCriteria<NetworkDomainVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("domainId", domainId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkDomainVO> listDomainNetworkMapByNetworkId(long networkId) {
|
||||
SearchCriteria<NetworkDomainVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user