mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Re-create serviceProvider map when network is updated
This commit is contained in:
		
							parent
							
								
									9c09c35fa5
								
							
						
					
					
						commit
						3aff7f00ff
					
				@ -1108,7 +1108,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
                
 | 
					                
 | 
				
			||||||
                NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isDefault,
 | 
					                NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isDefault,
 | 
				
			||||||
                        (domainId != null), predefined.getNetworkDomain(), offering.getGuestType(), isShared, plan.getDataCenterId(), plan.getPhysicalNetworkId());
 | 
					                        (domainId != null), predefined.getNetworkDomain(), offering.getGuestType(), isShared, plan.getDataCenterId(), plan.getPhysicalNetworkId());
 | 
				
			||||||
                networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, getServicesAndProvidersForNetwork(offering)));
 | 
					                networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (domainId != null) {
 | 
					                if (domainId != null) {
 | 
				
			||||||
                    _networksDao.addDomainToNetwork(id, domainId);
 | 
					                    _networksDao.addDomainToNetwork(id, domainId);
 | 
				
			||||||
@ -1737,9 +1737,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
                isDomainSpecific = true;
 | 
					                isDomainSpecific = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        //FIXME - need to check if all providers are supported by the physical network
 | 
					 | 
				
			||||||
        //FIXME - need to check that the traffic type is supported
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Account owner = null;
 | 
					        Account owner = null;
 | 
				
			||||||
        if (cmd.getAccountName() != null && cmd.getDomainId() != null) {
 | 
					        if (cmd.getAccountName() != null && cmd.getDomainId() != null) {
 | 
				
			||||||
@ -1865,7 +1862,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
 | 
					        NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
 | 
				
			||||||
        DataCenterVO zone = _dcDao.findById(zoneId);
 | 
					        DataCenterVO zone = _dcDao.findById(zoneId);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        // allow isDefault to be set only for Shared network
 | 
					        // allow isDefault to be set only for Shared network
 | 
				
			||||||
        if (networkOffering.getGuestType() == Network.GuestType.Isolated) {
 | 
					        if (networkOffering.getGuestType() == Network.GuestType.Isolated) {
 | 
				
			||||||
            if (isDefault != null && !isDefault) {
 | 
					            if (isDefault != null && !isDefault) {
 | 
				
			||||||
@ -2630,7 +2627,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
        if (newNetworkOfferingId != null) {
 | 
					        if (newNetworkOfferingId != null) {
 | 
				
			||||||
            s_logger.debug("Updating network " + network + " with the new network offering id=" + newNetworkOfferingId + " as a part of network restart");
 | 
					            s_logger.debug("Updating network " + network + " with the new network offering id=" + newNetworkOfferingId + " as a part of network restart");
 | 
				
			||||||
            network.setNetworkOfferingId(newNetworkOfferingId);
 | 
					            network.setNetworkOfferingId(newNetworkOfferingId);
 | 
				
			||||||
            _networksDao.update(networkId, network);
 | 
					            _networksDao.update(networkId, network, finalizeServicesAndProvidersForNetwork(_configMgr.getNetworkOffering(newNetworkOfferingId), network.getPhysicalNetworkId()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        //implement the network elements and rules again
 | 
					        //implement the network elements and rules again
 | 
				
			||||||
@ -3324,10 +3321,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
            //have to restart the network
 | 
					            //have to restart the network
 | 
				
			||||||
            restartNetwork = true;
 | 
					            restartNetwork = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        _networksDao.update(networkId, network); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _networksDao.update(networkId, network);
 | 
					 | 
				
			||||||
        boolean success = true;
 | 
					        boolean success = true;
 | 
				
			||||||
        if (restartNetwork && (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup)) {
 | 
					        if (restartNetwork && (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup)) {
 | 
				
			||||||
 | 
					        	//network offering id will be updated in the restartNetowrk call aftet the network elements are shutdown properly
 | 
				
			||||||
            s_logger.info("Restarting network " + network + " as a part of update network call");
 | 
					            s_logger.info("Restarting network " + network + " as a part of update network call");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
@ -3341,6 +3340,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                s_logger.warn("Failed to restart the network " + network + " as a part of updateNetwork call");
 | 
					                s_logger.warn("Failed to restart the network " + network + " as a part of updateNetwork call");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        } else if (networkOfferingId != null) {
 | 
				
			||||||
 | 
					        	network.setNetworkOfferingId(networkOfferingId);
 | 
				
			||||||
 | 
					        	_networksDao.update(networkId, network, finalizeServicesAndProvidersForNetwork(_configMgr.getNetworkOffering(networkOfferingId), network.getPhysicalNetworkId()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return network;
 | 
					        return network;
 | 
				
			||||||
@ -4851,16 +4853,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public Map<String, String> getServicesAndProvidersForNetwork(NetworkOffering offering) {
 | 
					    public Map<String, String> finalizeServicesAndProvidersForNetwork(NetworkOffering offering, Long physicalNetworkId) {
 | 
				
			||||||
        Map<String, String> svcProviders = new HashMap<String, String>();
 | 
					        Map<String, String> svcProviders = new HashMap<String, String>();
 | 
				
			||||||
        List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingSrvcDao.listByNetworkOfferingId(offering.getId());
 | 
					        List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingSrvcDao.listByNetworkOfferingId(offering.getId());
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        boolean checkPhysicalNetwork = (physicalNetworkId != null) ? true : false;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        for (NetworkOfferingServiceMapVO serviceMap : servicesMap) {
 | 
					        for (NetworkOfferingServiceMapVO serviceMap : servicesMap) {
 | 
				
			||||||
            if (svcProviders.containsKey(serviceMap.getService())) {
 | 
					            if (svcProviders.containsKey(serviceMap.getService())) {
 | 
				
			||||||
                //FIXME - right now we pick up the first provider from the list, need to add more logic based on provider load, etc
 | 
					                //FIXME - right now we pick up the first provider from the list, need to add more logic based on provider load, etc
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            } 
 | 
					            }
 | 
				
			||||||
            svcProviders.put(serviceMap.getService(), serviceMap.getProvider());  
 | 
					            
 | 
				
			||||||
 | 
					            String service = serviceMap.getService();
 | 
				
			||||||
 | 
					            String provider = serviceMap.getProvider();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            //check that provider is supported
 | 
				
			||||||
 | 
					            if (checkPhysicalNetwork) {
 | 
				
			||||||
 | 
					            	 if (!_pNSPDao.isServiceProviderEnabled(physicalNetworkId, provider, service)) {
 | 
				
			||||||
 | 
					                 	throw new UnsupportedServiceException("Provider " + provider + " doesn't support service " + service + " in physical network id=" + physicalNetworkId);
 | 
				
			||||||
 | 
					                 }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					            svcProviders.put(service, provider);  
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return svcProviders;
 | 
					        return svcProviders;
 | 
				
			||||||
 | 
				
			|||||||
@ -46,7 +46,7 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Deprecated
 | 
					    @Deprecated
 | 
				
			||||||
    NetworkVO persist(NetworkVO vo);
 | 
					    NetworkVO persist(NetworkVO vo);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Retrieves the next available mac address in this network configuration.
 | 
					     * Retrieves the next available mac address in this network configuration.
 | 
				
			||||||
     * 
 | 
					     * 
 | 
				
			||||||
@ -85,4 +85,8 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> {
 | 
				
			|||||||
    List<NetworkVO> listBy(long accountId, long dataCenterId, Network.GuestType type, TrafficType trafficType);
 | 
					    List<NetworkVO> listBy(long accountId, long dataCenterId, Network.GuestType type, TrafficType trafficType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    List<NetworkVO> listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName);
 | 
					    List<NetworkVO> listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void persistNetworkServiceProviders(long networkId, Map<String, String> serviceProviderMap);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						boolean update(Long networkId, NetworkVO network, Map<String, String> serviceProviderMap);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -198,14 +198,39 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
 | 
				
			|||||||
        NetworkOpVO op = new NetworkOpVO(network.getId(), gc);
 | 
					        NetworkOpVO op = new NetworkOpVO(network.getId(), gc);
 | 
				
			||||||
        _opDao.persist(op);
 | 
					        _opDao.persist(op);
 | 
				
			||||||
        //4) add services/providers for the network
 | 
					        //4) add services/providers for the network
 | 
				
			||||||
        for (String service : serviceProviderMap.keySet()) {
 | 
					        persistNetworkServiceProviders(newNetwork.getId(), serviceProviderMap);
 | 
				
			||||||
            NetworkServiceMapVO serviceMap = new NetworkServiceMapVO(newNetwork.getId(), Service.getService(service), Provider.getProvider(serviceProviderMap.get(service)));
 | 
					 | 
				
			||||||
            _ntwkSvcMap.persist(serviceMap);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        txn.commit();
 | 
					        txn.commit();
 | 
				
			||||||
        return newNetwork;
 | 
					        return newNetwork;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override @DB
 | 
				
			||||||
 | 
					    public boolean update(Long networkId, NetworkVO network, Map<String, String> serviceProviderMap) {
 | 
				
			||||||
 | 
					    	Transaction txn = Transaction.currentTxn();
 | 
				
			||||||
 | 
					        txn.start();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        super.update(networkId, network);
 | 
				
			||||||
 | 
					        if (serviceProviderMap != null) {
 | 
				
			||||||
 | 
					            _ntwkSvcMap.deleteByNetworkId(networkId);
 | 
				
			||||||
 | 
					            persistNetworkServiceProviders(networkId, serviceProviderMap);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        txn.commit();
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    @DB
 | 
				
			||||||
 | 
					    public void persistNetworkServiceProviders(long networkId, Map<String, String> serviceProviderMap) {
 | 
				
			||||||
 | 
					        Transaction txn = Transaction.currentTxn();
 | 
				
			||||||
 | 
					        txn.start();
 | 
				
			||||||
 | 
					    	for (String service : serviceProviderMap.keySet()) {
 | 
				
			||||||
 | 
					            NetworkServiceMapVO serviceMap = new NetworkServiceMapVO(networkId, Service.getService(service), Provider.getProvider(serviceProviderMap.get(service)));
 | 
				
			||||||
 | 
					            _ntwkSvcMap.persist(serviceMap);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    	txn.commit();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected void addAccountToNetwork(long networkId, long accountId, boolean isOwner) {
 | 
					    protected void addAccountToNetwork(long networkId, long accountId, boolean isOwner) {
 | 
				
			||||||
        NetworkAccountVO account = new NetworkAccountVO(networkId, accountId, isOwner);
 | 
					        NetworkAccountVO account = new NetworkAccountVO(networkId, accountId, isOwner);
 | 
				
			||||||
 | 
				
			|||||||
@ -17,4 +17,5 @@ public interface NetworkServiceMapDao extends GenericDao<NetworkServiceMapVO, Lo
 | 
				
			|||||||
    boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider);
 | 
					    boolean isProviderSupportedInNetwork(long networkId, Service service, Provider provider);
 | 
				
			||||||
    List<NetworkServiceMapVO> getServicesInNetwork(long networkId);
 | 
					    List<NetworkServiceMapVO> getServicesInNetwork(long networkId);
 | 
				
			||||||
    String getProviderForServiceInNetwork(long networkid, Service service);
 | 
					    String getProviderForServiceInNetwork(long networkid, Service service);
 | 
				
			||||||
 | 
						void deleteByNetworkId(long networkId);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -128,8 +128,8 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
 | 
				
			|||||||
        return listBy(sc);
 | 
					        return listBy(sc);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    
 | 
					    @Override
 | 
				
			||||||
    protected void deleteByNetworkId(long networkId) {
 | 
					    public void deleteByNetworkId(long networkId) {
 | 
				
			||||||
        SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create();
 | 
					        SearchCriteria<NetworkServiceMapVO> sc = AllFieldsSearch.create();
 | 
				
			||||||
        sc.setParameters("networkId", networkId);
 | 
					        sc.setParameters("networkId", networkId);
 | 
				
			||||||
        remove(sc);
 | 
					        remove(sc);
 | 
				
			||||||
 | 
				
			|||||||
@ -25,4 +25,5 @@ public interface PhysicalNetworkServiceProviderDao extends GenericDao<PhysicalNe
 | 
				
			|||||||
    List<PhysicalNetworkServiceProviderVO> listBy(long physicalNetworkId);
 | 
					    List<PhysicalNetworkServiceProviderVO> listBy(long physicalNetworkId);
 | 
				
			||||||
    PhysicalNetworkServiceProviderVO findByServiceProvider(long physicalNetworkId, String providerType);
 | 
					    PhysicalNetworkServiceProviderVO findByServiceProvider(long physicalNetworkId, String providerType);
 | 
				
			||||||
    void deleteProviders(long physicalNetworkId);
 | 
					    void deleteProviders(long physicalNetworkId);
 | 
				
			||||||
 | 
					    boolean isServiceProviderEnabled(long physicalNetworkId, String providerType, String serviceType);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,8 @@ import java.util.List;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import javax.ejb.Local;
 | 
					import javax.ejb.Local;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.cloud.network.Network.Service;
 | 
				
			||||||
 | 
					import com.cloud.network.PhysicalNetworkServiceProvider;
 | 
				
			||||||
import com.cloud.utils.db.DB;
 | 
					import com.cloud.utils.db.DB;
 | 
				
			||||||
import com.cloud.utils.db.GenericDaoBase;
 | 
					import com.cloud.utils.db.GenericDaoBase;
 | 
				
			||||||
import com.cloud.utils.db.SearchBuilder;
 | 
					import com.cloud.utils.db.SearchBuilder;
 | 
				
			||||||
@ -31,6 +33,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 | 
				
			|||||||
public class PhysicalNetworkServiceProviderDaoImpl extends GenericDaoBase<PhysicalNetworkServiceProviderVO, Long> implements PhysicalNetworkServiceProviderDao {
 | 
					public class PhysicalNetworkServiceProviderDaoImpl extends GenericDaoBase<PhysicalNetworkServiceProviderVO, Long> implements PhysicalNetworkServiceProviderDao {
 | 
				
			||||||
    final SearchBuilder<PhysicalNetworkServiceProviderVO> physicalNetworkSearch;
 | 
					    final SearchBuilder<PhysicalNetworkServiceProviderVO> physicalNetworkSearch;
 | 
				
			||||||
    final SearchBuilder<PhysicalNetworkServiceProviderVO> physicalNetworkServiceProviderSearch;
 | 
					    final SearchBuilder<PhysicalNetworkServiceProviderVO> physicalNetworkServiceProviderSearch;
 | 
				
			||||||
 | 
					    final SearchBuilder<PhysicalNetworkServiceProviderVO> AllFieldsSearch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected PhysicalNetworkServiceProviderDaoImpl() {
 | 
					    protected PhysicalNetworkServiceProviderDaoImpl() {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
@ -42,6 +45,23 @@ public class PhysicalNetworkServiceProviderDaoImpl extends GenericDaoBase<Physic
 | 
				
			|||||||
        physicalNetworkServiceProviderSearch.and("physicalNetworkId", physicalNetworkServiceProviderSearch.entity().getPhysicalNetworkId(), Op.EQ);
 | 
					        physicalNetworkServiceProviderSearch.and("physicalNetworkId", physicalNetworkServiceProviderSearch.entity().getPhysicalNetworkId(), Op.EQ);
 | 
				
			||||||
        physicalNetworkServiceProviderSearch.and("serviceProvderType", physicalNetworkServiceProviderSearch.entity().getProviderName(), Op.EQ);
 | 
					        physicalNetworkServiceProviderSearch.and("serviceProvderType", physicalNetworkServiceProviderSearch.entity().getProviderName(), Op.EQ);
 | 
				
			||||||
        physicalNetworkServiceProviderSearch.done();
 | 
					        physicalNetworkServiceProviderSearch.done();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        AllFieldsSearch = createSearchBuilder();
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("serviceProvderType", AllFieldsSearch.entity().getProviderName(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("vpnService", AllFieldsSearch.entity().isVpnServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("dhcpService", AllFieldsSearch.entity().isDhcpServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("dnsService", AllFieldsSearch.entity().isDnsServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("gatewayService", AllFieldsSearch.entity().isGatewayServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("firewallService", AllFieldsSearch.entity().isFirewallServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("sourceNatService", AllFieldsSearch.entity().isSourcenatServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("lbService", AllFieldsSearch.entity().isLbServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("staticNatService", AllFieldsSearch.entity().isStaticnatServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("pfService", AllFieldsSearch.entity().isPortForwardingServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("userDataService", AllFieldsSearch.entity().isUserdataServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.and("securityGroupService", AllFieldsSearch.entity().isSecuritygroupServiceProvided(), Op.EQ);
 | 
				
			||||||
 | 
					        AllFieldsSearch.done();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@ -66,4 +86,44 @@ public class PhysicalNetworkServiceProviderDaoImpl extends GenericDaoBase<Physic
 | 
				
			|||||||
        remove(sc);
 | 
					        remove(sc);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean isServiceProviderEnabled(long physicalNetworkId, String providerType, String serviceType) {
 | 
				
			||||||
 | 
					    	 SearchCriteria<PhysicalNetworkServiceProviderVO> sc = AllFieldsSearch.create();
 | 
				
			||||||
 | 
					         sc.setParameters("physicalNetworkId", physicalNetworkId);
 | 
				
			||||||
 | 
					         sc.setParameters("serviceProvderType", providerType);
 | 
				
			||||||
 | 
					         sc.setParameters("state", PhysicalNetworkServiceProvider.State.Enabled.toString());
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					         if (serviceType.equalsIgnoreCase(Service.Dhcp.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("dhcpService", true);
 | 
				
			||||||
 | 
					         } else if (serviceType.equalsIgnoreCase(Service.Dns.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("dnsService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.Firewall.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("firewallService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.Gateway.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("gatewayService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.Lb.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("lbService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.PortForwarding.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("pfService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.SecurityGroup.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("securityGroupService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.SourceNat.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("sourceNatService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.StaticNat.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("staticNatService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.UserData.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("userDataService", true);
 | 
				
			||||||
 | 
					         }else if (serviceType.equalsIgnoreCase(Service.Vpn.getName())) {
 | 
				
			||||||
 | 
					             sc.setParameters("vpnService", true);
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					         PhysicalNetworkServiceProviderVO map = findOneBy(sc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         if (map != null) {
 | 
				
			||||||
 | 
					        	 return true;
 | 
				
			||||||
 | 
					         } else {
 | 
				
			||||||
 | 
					        	 return false;
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user