Search in sources :

Example 6 with NetworkOfferingServiceMapVO

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

the class NetworkModelImpl method getNetworkOfferingServiceProvidersMap.

@Override
public Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId) {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Service, Set<Provider>>();
    List<NetworkOfferingServiceMapVO> map = _ntwkOfferingSrvcDao.listByNetworkOfferingId(networkOfferingId);
    for (NetworkOfferingServiceMapVO instance : map) {
        String service = instance.getService();
        Set<Provider> providers;
        providers = serviceProviderMap.get(Service.getService(service));
        if (providers == null) {
            providers = new HashSet<Provider>();
        }
        providers.add(Provider.getProvider(instance.getProvider()));
        serviceProviderMap.put(Service.getService(service), providers);
    }
    return serviceProviderMap;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 7 with NetworkOfferingServiceMapVO

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

the class ConfigurationServerImpl method getServicesAndProvidersForNetwork.

public Map<String, String> getServicesAndProvidersForNetwork(long networkOfferingId) {
    Map<String, String> svcProviders = new HashMap<String, String>();
    List<NetworkOfferingServiceMapVO> servicesMap = _ntwkOfferingServiceMapDao.listByNetworkOfferingId(networkOfferingId);
    for (NetworkOfferingServiceMapVO serviceMap : servicesMap) {
        if (svcProviders.containsKey(serviceMap.getService())) {
            continue;
        }
        svcProviders.put(serviceMap.getService(), serviceMap.getProvider());
    }
    return svcProviders;
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) HashMap(java.util.HashMap)

Example 8 with NetworkOfferingServiceMapVO

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

the class ConfigurationServerImpl method createDefaultNetworkOfferings.

@DB
protected void createDefaultNetworkOfferings() {
    NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemPublicNetwork, TrafficType.Public, true);
    publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
    NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemManagementNetwork, TrafficType.Management, false);
    managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
    NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemControlNetwork, TrafficType.Control, false);
    controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
    NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemStorageNetwork, TrafficType.Storage, true);
    storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
    NetworkOfferingVO privateGatewayNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemPrivateGatewayNetworkOffering, GuestType.Isolated);
    privateGatewayNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(privateGatewayNetworkOffering);
    //populate providers
    final Map<Network.Service, Network.Provider> defaultSharedNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
    defaultSharedNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter);
    defaultSharedNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter);
    defaultSharedNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter);
    final Map<Network.Service, Network.Provider> defaultIsolatedNetworkOfferingProviders = defaultSharedNetworkOfferingProviders;
    final Map<Network.Service, Network.Provider> defaultSharedSGNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
    defaultSharedSGNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter);
    defaultSharedSGNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter);
    defaultSharedSGNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter);
    defaultSharedSGNetworkOfferingProviders.put(Service.SecurityGroup, Provider.SecurityGroupProvider);
    final Map<Network.Service, Network.Provider> defaultIsolatedSourceNatEnabledNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Firewall, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Gateway, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Lb, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.SourceNat, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.StaticNat, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.PortForwarding, Provider.VirtualRouter);
    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Vpn, Provider.VirtualRouter);
    final Map<Network.Service, Network.Provider> netscalerServiceProviders = new HashMap<Network.Service, Network.Provider>();
    netscalerServiceProviders.put(Service.Dhcp, Provider.VirtualRouter);
    netscalerServiceProviders.put(Service.Dns, Provider.VirtualRouter);
    netscalerServiceProviders.put(Service.UserData, Provider.VirtualRouter);
    netscalerServiceProviders.put(Service.SecurityGroup, Provider.SecurityGroupProvider);
    netscalerServiceProviders.put(Service.StaticNat, Provider.Netscaler);
    netscalerServiceProviders.put(Service.Lb, Provider.Netscaler);
    // The only one diff between 1 and 2 network offerings is that the first one has SG enabled. In Basic zone only
    // first network offering has to be enabled, in Advance zone - the second one
    Transaction.execute(new TransactionCallbackNoReturn() {

        @Override
        public void doInTransactionWithoutResult(TransactionStatus status) {
            // Offering #1
            NetworkOfferingVO defaultSharedSGNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
            defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled);
            defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering);
            for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #2
            NetworkOfferingVO defaultSharedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
            defaultSharedNetworkOffering.setState(NetworkOffering.State.Enabled);
            defaultSharedNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedNetworkOffering);
            for (Service service : defaultSharedNetworkOfferingProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #3
            NetworkOfferingVO defaultIsolatedSourceNatEnabledNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Required, null, Network.GuestType.Isolated, true, false, false, false, true);
            defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
            defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);
            for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #4
            NetworkOfferingVO defaultIsolatedEnabledNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false);
            defaultIsolatedEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
            defaultIsolatedEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedEnabledNetworkOffering);
            for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedEnabledNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #5
            NetworkOfferingVO defaultNetscalerNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedEIPandELBNetworkOffering, "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, false, false, false, true, true, true, false, false, true, true, false, false, false, false);
            defaultNetscalerNetworkOffering.setState(NetworkOffering.State.Enabled);
            defaultNetscalerNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetscalerNetworkOffering);
            for (Service service : netscalerServiceProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetscalerNetworkOffering.getId(), service, netscalerServiceProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #6
            NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, "Offering for Isolated Vpc networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, true);
            defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled);
            defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks);
            Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
            defaultVpcNetworkOfferingProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.Dns, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.UserData, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.NetworkACL, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.Gateway, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.Lb, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.SourceNat, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.StaticNat, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter);
            for (Map.Entry<Service, Provider> entry : defaultVpcNetworkOfferingProviders.entrySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(), entry.getKey(), entry.getValue());
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            // Offering #7
            NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB, "Offering for Isolated Vpc networks with Source Nat service enabled and LB service Disabled", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, false);
            defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled);
            defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB);
            Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProvidersNoLB = new HashMap<Network.Service, Network.Provider>();
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dhcp, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dns, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.UserData, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.NetworkACL, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.Gateway, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.SourceNat, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.StaticNat, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.PortForwarding, Provider.VPCVirtualRouter);
            defaultVpcNetworkOfferingProvidersNoLB.put(Service.Vpn, Provider.VPCVirtualRouter);
            for (Map.Entry<Service, Provider> entry : defaultVpcNetworkOfferingProvidersNoLB.entrySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), entry.getKey(), entry.getValue());
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
            //offering #8 - network offering with internal lb service
            NetworkOfferingVO internalLbOff = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB, "Offering for Isolated Vpc networks with Internal LB support", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, false, false, false, true, false);
            internalLbOff.setState(NetworkOffering.State.Enabled);
            internalLbOff = _networkOfferingDao.persistDefaultNetworkOffering(internalLbOff);
            Map<Network.Service, Network.Provider> internalLbOffProviders = new HashMap<Network.Service, Network.Provider>();
            internalLbOffProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
            internalLbOffProviders.put(Service.Dns, Provider.VPCVirtualRouter);
            internalLbOffProviders.put(Service.UserData, Provider.VPCVirtualRouter);
            internalLbOffProviders.put(Service.NetworkACL, Provider.VPCVirtualRouter);
            internalLbOffProviders.put(Service.Gateway, Provider.VPCVirtualRouter);
            internalLbOffProviders.put(Service.Lb, Provider.InternalLbVm);
            internalLbOffProviders.put(Service.SourceNat, Provider.VPCVirtualRouter);
            for (Service service : internalLbOffProviders.keySet()) {
                NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(internalLbOff.getId(), service, internalLbOffProviders.get(service));
                _ntwkOfferingServiceMapDao.persist(offService);
                s_logger.trace("Added service for the network offering: " + offService);
            }
        }
    });
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) HashMap(java.util.HashMap) Service(com.cloud.network.Network.Service) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) Provider(com.cloud.network.Network.Provider) Network(com.cloud.network.Network) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Map(java.util.Map) HashMap(java.util.HashMap) DB(com.cloud.utils.db.DB)

Example 9 with NetworkOfferingServiceMapVO

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

the class NetworkOfferingServiceMapDaoImpl method persist.

@Override
public NetworkOfferingServiceMapVO persist(NetworkOfferingServiceMapVO entity) {
    SearchCriteria<NetworkOfferingServiceMapVO> sc = AllFieldsSearch.create();
    sc.setParameters("networkOfferingId", entity.getNetworkOfferingId());
    sc.setParameters("service", entity.getService());
    sc.setParameters("provider", entity.getProvider());
    NetworkOfferingServiceMapVO mappingInDb = findOneBy(sc);
    return mappingInDb != null ? mappingInDb : super.persist(entity);
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO)

Aggregations

NetworkOfferingServiceMapVO (com.cloud.offerings.NetworkOfferingServiceMapVO)9 Service (com.cloud.network.Network.Service)5 HashMap (java.util.HashMap)4 Provider (com.cloud.network.Network.Provider)3 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)3 DB (com.cloud.utils.db.DB)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 Network (com.cloud.network.Network)2 NetworkService (com.cloud.network.NetworkService)2 ResourceLimitService (com.cloud.user.ResourceLimitService)2 TransactionStatus (com.cloud.utils.db.TransactionStatus)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)2 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)1 Capability (com.cloud.network.Network.Capability)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)1