use of com.cloud.model.enumeration.DHCPMode 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++;
}
}
}
}
}
Aggregations