mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix Tungsten Fabric errors on adding a new zone due to duplicated entries on ntwk_service_map (#7455)
* Fix Tungsten Fabric errors on adding a new zone due to duplicated entries on ntwk_service_map * Address review comments
This commit is contained in:
parent
22871ad2da
commit
5e71cea2c5
@ -107,7 +107,10 @@ public class ConfigTungstenFabricServiceCmd extends BaseCmd {
|
||||
Network managementNetwork = networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, Networks.TrafficType.Management);
|
||||
NetworkServiceMapVO managementNetworkServiceMapVO = new NetworkServiceMapVO(managementNetwork.getId(),
|
||||
Network.Service.Connectivity, Network.Provider.Tungsten);
|
||||
networkServiceMapDao.persist(managementNetworkServiceMapVO);
|
||||
if (!networkServiceMapDao.canProviderSupportServiceInNetwork(managementNetwork.getId(),
|
||||
Network.Service.Connectivity, Network.Provider.Tungsten)) {
|
||||
networkServiceMapDao.persist(managementNetworkServiceMapVO);
|
||||
}
|
||||
|
||||
List<NetworkOfferingVO> systemNetworkOffering = networkOfferingDao.listSystemNetworkOfferings();
|
||||
for (NetworkOfferingVO networkOffering : systemNetworkOffering) {
|
||||
@ -132,6 +135,30 @@ public class ConfigTungstenFabricServiceCmd extends BaseCmd {
|
||||
|
||||
private void persistDefaultSystemNetwork() {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
|
||||
private void persistNetworkServiceMapAvoidingDuplicates(Network network,
|
||||
NetworkServiceMapVO mapVO) {
|
||||
if (mapVO == null) {
|
||||
s_logger.error("Expected a network-service-provider mapping entity to be persisted");
|
||||
return;
|
||||
}
|
||||
Network.Service service = Network.Service.getService(mapVO.getService());
|
||||
Network.Provider provider = Network.Provider.getProvider(mapVO.getProvider());
|
||||
if (service == null || provider == null) {
|
||||
s_logger.error(String.format("Could not obtain the service or the provider " +
|
||||
"from the network-service-provider map with ID = %s", mapVO.getId()));
|
||||
return;
|
||||
}
|
||||
if (networkServiceMapDao.canProviderSupportServiceInNetwork(network.getId(), service, provider)) {
|
||||
s_logger.debug(String.format("A mapping between the network, service and provider (%s, %s, %s) " +
|
||||
"already exists, skipping duplicated entry",
|
||||
network.getId(), service.getName(), provider.getName()));
|
||||
return;
|
||||
|
||||
}
|
||||
networkServiceMapDao.persist(mapVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
NetworkOfferingVO networkOfferingVO = networkOfferingDao.findByUniqueName(NETWORKOFFERING);
|
||||
@ -169,12 +196,12 @@ public class ConfigTungstenFabricServiceCmd extends BaseCmd {
|
||||
Network publicNetwork = networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, Networks.TrafficType.Public);
|
||||
NetworkServiceMapVO publicNetworkServiceMapVO = new NetworkServiceMapVO(publicNetwork.getId(),
|
||||
Network.Service.Connectivity, Network.Provider.Tungsten);
|
||||
networkServiceMapDao.persist(publicNetworkServiceMapVO);
|
||||
persistNetworkServiceMapAvoidingDuplicates(publicNetwork, publicNetworkServiceMapVO);
|
||||
|
||||
Network managementNetwork = networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, Networks.TrafficType.Management);
|
||||
NetworkServiceMapVO managementNetworkServiceMapVO = new NetworkServiceMapVO(managementNetwork.getId(),
|
||||
Network.Service.Connectivity, Network.Provider.Tungsten);
|
||||
networkServiceMapDao.persist(managementNetworkServiceMapVO);
|
||||
persistNetworkServiceMapAvoidingDuplicates(managementNetwork, managementNetworkServiceMapVO);
|
||||
|
||||
List<NetworkOfferingVO> systemNetworkOffering = networkOfferingDao.listSystemNetworkOfferings();
|
||||
for (NetworkOfferingVO networkOffering : systemNetworkOffering) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user