Search in sources :

Example 1 with NetworkOfferingServiceMapVO

use of com.cloud.offerings.NetworkOfferingServiceMapVO in project cloudstack by apache.

the class NetworkOfferingDaoImpl method persistL2DefaultNetworkOffering.

/**
 * Persist L2 deafult Network offering
 */
private void persistL2DefaultNetworkOffering(String name, String displayText, boolean specifyVlan, boolean configDriveEnabled) {
    NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, TrafficType.Guest, false, specifyVlan, null, null, true, Availability.Optional, null, Network.GuestType.L2, true, false, false, false, false, false);
    offering.setState(NetworkOffering.State.Enabled);
    persistDefaultNetworkOffering(offering);
    if (configDriveEnabled) {
        NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), Network.Service.UserData, Network.Provider.ConfigDrive);
        networkOfferingServiceMapDao.persist(offService);
    }
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO)

Example 2 with NetworkOfferingServiceMapVO

use of com.cloud.offerings.NetworkOfferingServiceMapVO in project cloudstack by apache.

the class NetworkOfferingServiceMapDaoImpl method areServicesSupportedByNetworkOffering.

@Override
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
    SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
    sc.setParameters("networkOfferingId", networkOfferingId);
    if (services != null) {
        String[] servicesStr = new String[services.length];
        int i = 0;
        for (Service service : services) {
            servicesStr[i] = service.getName();
            i++;
        }
        sc.setParameters("service", (Object[]) servicesStr);
    }
    List<NetworkOfferingServiceMapVO> offeringServices = listBy(sc);
    if (services != null) {
        if (offeringServices.size() == services.length) {
            return true;
        }
    } else if (!offeringServices.isEmpty()) {
        return true;
    }
    return false;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) Service(com.cloud.network.Network.Service)

Example 3 with NetworkOfferingServiceMapVO

use of com.cloud.offerings.NetworkOfferingServiceMapVO in project cloudstack by apache.

the class NetworkOrchestrator method finalizeServicesAndProvidersForNetwork.

@Override
public Map<String, String> finalizeServicesAndProvidersForNetwork(final NetworkOffering offering, final Long physicalNetworkId) {
    final Map<String, String> svcProviders = new HashMap<String, String>();
    final Map<String, List<String>> providerSvcs = new HashMap<String, List<String>>();
    final List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingSrvcDao.listByNetworkOfferingId(offering.getId());
    final boolean checkPhysicalNetwork = physicalNetworkId != null ? true : false;
    for (final NetworkOfferingServiceMapVO serviceMap : servicesMap) {
        if (svcProviders.containsKey(serviceMap.getService())) {
            // provider load, etc
            continue;
        }
        final String service = serviceMap.getService();
        String provider = serviceMap.getProvider();
        if (provider == null) {
            provider = _networkModel.getDefaultUniqueProviderForService(service).getName();
        }
        // check that provider is supported
        if (checkPhysicalNetwork) {
            if (!_pNSPDao.isServiceProviderEnabled(physicalNetworkId, provider, service)) {
                throw new UnsupportedServiceException("Provider " + provider + " is either not enabled or doesn't " + "support service " + service + " in physical network id=" + physicalNetworkId);
            }
        }
        svcProviders.put(service, provider);
        List<String> l = providerSvcs.get(provider);
        if (l == null) {
            providerSvcs.put(provider, l = new ArrayList<String>());
        }
        l.add(service);
    }
    return svcProviders;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with NetworkOfferingServiceMapVO

use of com.cloud.offerings.NetworkOfferingServiceMapVO in project cloudstack by apache.

the class KubernetesClusterManagerImpl method start.

@Override
public boolean start() {
    final Map<Network.Service, Network.Provider> defaultKubernetesServiceNetworkOfferingProviders = new HashMap<Service, Network.Provider>();
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Dhcp, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Dns, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.UserData, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Firewall, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Gateway, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Lb, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.SourceNat, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.StaticNat, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.PortForwarding, Network.Provider.VirtualRouter);
    defaultKubernetesServiceNetworkOfferingProviders.put(Service.Vpn, Network.Provider.VirtualRouter);
    NetworkOfferingVO defaultKubernetesServiceNetworkOffering = new NetworkOfferingVO(DEFAULT_NETWORK_OFFERING_FOR_KUBERNETES_SERVICE_NAME, "Network Offering used for CloudStack Kubernetes service", Networks.TrafficType.Guest, false, false, null, null, true, NetworkOffering.Availability.Required, null, Network.GuestType.Isolated, true, true, false, false, false, false, false, false, false, true, true, false, false, true, false, false);
    defaultKubernetesServiceNetworkOffering.setState(NetworkOffering.State.Enabled);
    defaultKubernetesServiceNetworkOffering = networkOfferingDao.persistDefaultNetworkOffering(defaultKubernetesServiceNetworkOffering);
    for (Service service : defaultKubernetesServiceNetworkOfferingProviders.keySet()) {
        NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultKubernetesServiceNetworkOffering.getId(), service, defaultKubernetesServiceNetworkOfferingProviders.get(service));
        networkOfferingServiceMapDao.persist(offService);
        LOGGER.trace("Added service for the network offering: " + offService);
    }
    _gcExecutor.scheduleWithFixedDelay(new KubernetesClusterGarbageCollector(), 300, 300, TimeUnit.SECONDS);
    _stateScanner.scheduleWithFixedDelay(new KubernetesClusterStatusScanner(), 300, 30, TimeUnit.SECONDS);
    return true;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) AccountService(com.cloud.user.AccountService) NetworkOrchestrationService(org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService) Service(com.cloud.network.Network.Service) NetworkService(com.cloud.network.NetworkService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AnnotationService(org.apache.cloudstack.annotation.AnnotationService) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO)

Example 5 with NetworkOfferingServiceMapVO

use of com.cloud.offerings.NetworkOfferingServiceMapVO in project cloudstack by apache.

the class CreateNetworkOfferingTest method setUp.

@Override
@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    ConfigurationVO configVO = new ConfigurationVO("200", "200", "200", "200", "200", "200");
    Mockito.when(configDao.findByName(anyString())).thenReturn(configVO);
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class), nullable(Map.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(mapDao.persist(any(NetworkOfferingServiceMapVO.class))).thenReturn(new NetworkOfferingServiceMapVO());
    Mockito.when(accountMgr.getSystemUser()).thenReturn(new UserVO(1));
    Mockito.when(accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
    CallContext.register(accountMgr.getSystemUser(), accountMgr.getSystemAccount());
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO) UserVO(com.cloud.user.UserVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HashMap(java.util.HashMap) Map(java.util.Map) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Aggregations

NetworkOfferingServiceMapVO (com.cloud.offerings.NetworkOfferingServiceMapVO)21 Service (com.cloud.network.Network.Service)11 HashMap (java.util.HashMap)9 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)8 Network (com.cloud.network.Network)6 Provider (com.cloud.network.Network.Provider)6 NetworkService (com.cloud.network.NetworkService)6 DB (com.cloud.utils.db.DB)6 ResourceLimitService (com.cloud.user.ResourceLimitService)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Set (java.util.Set)5 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)5 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 PhysicalNetwork (com.cloud.network.PhysicalNetwork)4 TransactionStatus (com.cloud.utils.db.TransactionStatus)4 Capability (com.cloud.network.Network.Capability)3 NetworkOffering (com.cloud.offering.NetworkOffering)3 ManagementService (com.cloud.server.ManagementService)3