Search in sources :

Example 1 with DHCPMode

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

Aggregations

DataCenterVO (com.cloud.dc.DataCenterVO)1 BroadcastDomainType (com.cloud.model.enumeration.BroadcastDomainType)1 DHCPMode (com.cloud.model.enumeration.DHCPMode)1 TrafficType (com.cloud.model.enumeration.TrafficType)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 ControlNetworkGuru (com.cloud.network.guru.ControlNetworkGuru)1 DirectPodBasedNetworkGuru (com.cloud.network.guru.DirectPodBasedNetworkGuru)1 PodBasedNetworkGuru (com.cloud.network.guru.PodBasedNetworkGuru)1 PublicNetworkGuru (com.cloud.network.guru.PublicNetworkGuru)1 StorageNetworkGuru (com.cloud.network.guru.StorageNetworkGuru)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 HashMap (java.util.HashMap)1