Search in sources :

Example 1 with TrafficType

use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.

the class ConfigurationServerImpl method createDefaultNetworks.

private void createDefaultNetworks() {
    final List<DataCenterVO> zones = _dataCenterDao.listAll();
    long id = 1;
    final HashMap<TrafficType, String> guruNames = new HashMap<>();
    guruNames.put(TrafficType.Public, PublicNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Management, PodBasedNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Control, ControlNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Storage, StorageNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Guest, DirectPodBasedNetworkGuru.class.getSimpleName());
    for (final DataCenterVO zone : zones) {
        final long zoneId = zone.getId();
        final long accountId = 1L;
        Long domainId = zone.getDomainId();
        if (domainId == null) {
            domainId = 1L;
        }
        // Create default networks - system only
        final List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
        for (final NetworkOfferingVO offering : ntwkOff) {
            if (offering.isSystemOnly()) {
                final long related = id;
                final long networkOfferingId = offering.getId();
                final DHCPMode mode = DHCPMode.Static;
                final String networkDomain = null;
                BroadcastDomainType broadcastDomainType = null;
                final TrafficType trafficType = offering.getTrafficType();
                boolean specifyIpRanges = false;
                if (trafficType == TrafficType.Management) {
                    broadcastDomainType = BroadcastDomainType.Native;
                } else if (trafficType == TrafficType.Storage) {
                    broadcastDomainType = BroadcastDomainType.Native;
                    specifyIpRanges = true;
                } else if (trafficType == TrafficType.Control) {
                    broadcastDomainType = BroadcastDomainType.LinkLocal;
                } else if (offering.getTrafficType() == TrafficType.Public) {
                    if (zone.getNetworkType() == NetworkType.Advanced || zone.getNetworkType() == NetworkType.Basic) {
                        specifyIpRanges = true;
                        broadcastDomainType = BroadcastDomainType.Vlan;
                    } else {
                        continue;
                    }
                }
                if (broadcastDomainType != null) {
                    final NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, GuestType.Shared, zoneId, null, null, specifyIpRanges, null, offering.getRedundantRouter(), zone.getDns1(), zone.getDns2(), null, null, null);
                    network.setGuruName(guruNames.get(network.getTrafficType()));
                    network.setState(State.Implemented);
                    _networkDao.persist(network, false, getServicesAndProvidersForNetwork(networkOfferingId));
                    id++;
                }
            }
        }
    }
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkVO(com.cloud.network.dao.NetworkVO) HashMap(java.util.HashMap) DHCPMode(com.cloud.model.enumeration.DHCPMode) StorageNetworkGuru(com.cloud.network.guru.StorageNetworkGuru) PublicNetworkGuru(com.cloud.network.guru.PublicNetworkGuru) ControlNetworkGuru(com.cloud.network.guru.ControlNetworkGuru) BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) PodBasedNetworkGuru(com.cloud.network.guru.PodBasedNetworkGuru) DirectPodBasedNetworkGuru(com.cloud.network.guru.DirectPodBasedNetworkGuru) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) DirectPodBasedNetworkGuru(com.cloud.network.guru.DirectPodBasedNetworkGuru) TrafficType(com.cloud.model.enumeration.TrafficType)

Example 2 with TrafficType

use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.

the class LibvirtVifDriverTest method testBadTrafficType.

@Test
public void testBadTrafficType() throws ConfigurationException {
    final Map<String, Object> params = new HashMap<>();
    params.put(this.LibVirtVifDriver + "." + "NonExistentTrafficType", this.FakeVifDriverClassName);
    this.res.setBridgeType(BridgeType.NATIVE);
    configure(params);
    // Set all traffic types to use default, because bad traffic type should be ignored
    for (final TrafficType trafficType : TrafficType.values()) {
        this.assertions.put(trafficType, this.bridgeVifDriver);
    }
    checkAssertions();
}
Also used : HashMap(java.util.HashMap) TrafficType(com.cloud.model.enumeration.TrafficType) Test(org.junit.Test)

Example 3 with TrafficType

use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.

the class NetworkModelImpl method getNetworkTag.

@Override
public String getNetworkTag(final HypervisorType hType, final Network network) {
    // no network tag for control traffic type
    final TrafficType effectiveTrafficType = network.getTrafficType();
    if (effectiveTrafficType == TrafficType.Control) {
        return null;
    }
    Long physicalNetworkId;
    if (effectiveTrafficType != TrafficType.Guest) {
        physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network, effectiveTrafficType);
    } else {
        final NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
        physicalNetworkId = network.getPhysicalNetworkId();
        if (physicalNetworkId == null) {
            physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
        }
    }
    if (physicalNetworkId == null) {
        assert false : "Can't get the physical network";
        s_logger.warn("Can't get the physical network");
        return null;
    }
    return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, effectiveTrafficType, hType);
}
Also used : NetworkOffering(com.cloud.offering.NetworkOffering) TrafficType(com.cloud.model.enumeration.TrafficType)

Example 4 with TrafficType

use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.

the class PodBasedNetworkGuru method design.

@Override
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) {
    final TrafficType type = offering.getTrafficType();
    if (!isMyTrafficType(type)) {
        return null;
    }
    final NetworkVO config = new NetworkVO(type, DHCPMode.Static, BroadcastDomainType.Native, offering.getId(), Network.State.Setup, plan.getDataCenterId(), plan.getPhysicalNetworkId(), offering.getRedundantRouter());
    return config;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) TrafficType(com.cloud.model.enumeration.TrafficType)

Example 5 with TrafficType

use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResource method configureVifDrivers.

protected void configureVifDrivers(final Map<String, Object> params) throws ConfigurationException {
    final String libvirtVifDriver = "libvirt.vif.driver";
    this.trafficTypeVifDrivers = new HashMap<>();
    // Load the default vif driver
    String defaultVifDriverName = (String) params.get(libvirtVifDriver);
    if (defaultVifDriverName == null) {
        if (getBridgeType() == OPENVSWITCH) {
            logger.info("No libvirt.vif.driver specified. Defaults to OvsVifDriver.");
            defaultVifDriverName = DEFAULT_OVS_VIF_DRIVER_CLASS;
        } else {
            logger.info("No libvirt.vif.driver specified. Defaults to BridgeVifDriver.");
            defaultVifDriverName = DEFAULT_BRIDGE_VIF_DRIVER_CLASS;
        }
    }
    this.defaultVifDriver = getVifDriverClass(defaultVifDriverName, params);
    // Load any per-traffic-type vif drivers
    for (final Map.Entry<String, Object> entry : params.entrySet()) {
        final String k = entry.getKey();
        final String vifDriverPrefix = libvirtVifDriver + ".";
        if (k.startsWith(vifDriverPrefix)) {
            // Get trafficType
            final String trafficTypeSuffix = k.substring(vifDriverPrefix.length());
            // Does this suffix match a real traffic type?
            final TrafficType trafficType = TrafficType.getTrafficType(trafficTypeSuffix);
            if (!trafficType.equals(TrafficType.None)) {
                // Get vif driver class name
                final String vifDriverClassName = (String) entry.getValue();
                // if value is null, ignore
                if (vifDriverClassName != null) {
                    // add traffic type to vif driver mapping to Map
                    this.trafficTypeVifDrivers.put(trafficType, getVifDriverClass(vifDriverClassName, params));
                }
            }
        }
    }
}
Also used : Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TrafficType(com.cloud.model.enumeration.TrafficType)

Aggregations

TrafficType (com.cloud.model.enumeration.TrafficType)14 HashMap (java.util.HashMap)7 NetworkVO (com.cloud.network.dao.NetworkVO)6 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)3 NetworkOffering (com.cloud.offering.NetworkOffering)3 NicResponse (com.cloud.api.response.NicResponse)2 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)2 Network (com.cloud.legacymodel.network.Network)2 BroadcastDomainType (com.cloud.model.enumeration.BroadcastDomainType)2 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)2 Map (java.util.Map)2 Test (org.junit.Test)2 AffinityGroupService (com.cloud.affinity.AffinityGroupService)1 Commands (com.cloud.agent.manager.Commands)1 DomainRouterResponse (com.cloud.api.response.DomainRouterResponse)1 Config (com.cloud.configuration.Config)1 Zone (com.cloud.db.model.Zone)1 ZoneRepository (com.cloud.db.repository.ZoneRepository)1 DataCenterVO (com.cloud.dc.DataCenterVO)1