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++;
}
}
}
}
}
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();
}
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);
}
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;
}
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));
}
}
}
}
}
Aggregations