Search in sources :

Example 1 with TrafficType

use of com.cloud.network.Networks.TrafficType in project CloudStack-archive by CloudStack-extras.

the class ListTrafficTypeImplementorsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<Pair<TrafficType, String>> results = _networkService.listTrafficTypeImplementor(this);
    ListResponse<TrafficTypeImplementorResponse> response = new ListResponse<TrafficTypeImplementorResponse>();
    List<TrafficTypeImplementorResponse> responses = new ArrayList<TrafficTypeImplementorResponse>();
    for (Pair<TrafficType, String> r : results) {
        TrafficTypeImplementorResponse p = new TrafficTypeImplementorResponse();
        p.setTrafficType(r.first().toString());
        p.setImplementor(r.second());
        p.setObjectName("traffictypeimplementorresponse");
        responses.add(p);
    }
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) TrafficTypeImplementorResponse(com.cloud.api.response.TrafficTypeImplementorResponse) ArrayList(java.util.ArrayList) Pair(com.cloud.utils.Pair) TrafficType(com.cloud.network.Networks.TrafficType)

Example 2 with TrafficType

use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.

the class LibvirtVifDriverTest method testBadTrafficType.

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

Example 3 with TrafficType

use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.

the class ConfigurationServerImpl method createDefaultNetworks.

private void createDefaultNetworks() {
    List<DataCenterVO> zones = _dataCenterDao.listAll();
    long id = 1;
    HashMap<TrafficType, String> guruNames = new HashMap<TrafficType, String>();
    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 (DataCenterVO zone : zones) {
        long zoneId = zone.getId();
        long accountId = 1L;
        Long domainId = zone.getDomainId();
        if (domainId == null) {
            domainId = 1L;
        }
        // Create default networks - system only
        List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
        for (NetworkOfferingVO offering : ntwkOff) {
            if (offering.isSystemOnly()) {
                long related = id;
                long networkOfferingId = offering.getId();
                Mode mode = Mode.Static;
                String networkDomain = null;
                BroadcastDomainType broadcastDomainType = null;
                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.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) {
                        specifyIpRanges = true;
                        broadcastDomainType = BroadcastDomainType.Vlan;
                    } else {
                        continue;
                    }
                }
                if (broadcastDomainType != null) {
                    NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, Network.GuestType.Shared, zoneId, null, null, specifyIpRanges, null, offering.getRedundantRouter());
                    network.setGuruName(guruNames.get(network.getTrafficType()));
                    network.setDns1(zone.getDns1());
                    network.setDns2(zone.getDns2());
                    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) Mode(com.cloud.network.Networks.Mode) StorageNetworkGuru(com.cloud.network.guru.StorageNetworkGuru) PublicNetworkGuru(com.cloud.network.guru.PublicNetworkGuru) ControlNetworkGuru(com.cloud.network.guru.ControlNetworkGuru) BroadcastDomainType(com.cloud.network.Networks.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.network.Networks.TrafficType)

Example 4 with TrafficType

use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.

the class ServerDBSyncImpl method syncVirtualNetwork.

/*
     *  Virtual Network Synchronization methods
     */
@SuppressWarnings({ "unchecked" })
public boolean syncVirtualNetwork() throws Exception {
    final ApiConnector api = _manager.getApiConnector();
    try {
        List<TrafficType> types = new ArrayList<TrafficType>();
        types.add(TrafficType.Public);
        types.add(TrafficType.Guest);
        List<NetworkVO> dbNets = _manager.findManagedNetworks(types);
        List<VirtualNetwork> vList = (List<VirtualNetwork>) api.list(VirtualNetwork.class, null);
        List<VirtualNetwork> vncList = new ArrayList<VirtualNetwork>();
        for (VirtualNetwork vn : vList) {
            if (!_manager.isSystemDefaultNetwork(vn)) {
                vncList.add(vn);
            }
        }
        s_logger.debug("sync VN - DB size: " + dbNets.size() + " VNC Size: " + vncList.size());
        return _dbSync.syncGeneric(VirtualNetwork.class, dbNets, vncList);
    } catch (Exception ex) {
        s_logger.warn("sync virtual-networks", ex);
        throw ex;
    }
}
Also used : VirtualNetwork(net.juniper.contrail.api.types.VirtualNetwork) NetworkVO(com.cloud.network.dao.NetworkVO) ApiConnector(net.juniper.contrail.api.ApiConnector) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) InternalErrorException(com.cloud.exception.InternalErrorException) IOException(java.io.IOException) TrafficType(com.cloud.network.Networks.TrafficType)

Example 5 with TrafficType

use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.

the class ContrailManagerImpl method findSystemNetworks.

@Override
public List<NetworkVO> findSystemNetworks(List<TrafficType> types) {
    SearchBuilder<NetworkVO> searchBuilder = _networksDao.createSearchBuilder();
    searchBuilder.and("trafficType", searchBuilder.entity().getTrafficType(), Op.IN);
    SearchCriteria<NetworkVO> sc = searchBuilder.create();
    if (types == null || types.isEmpty()) {
        types = new ArrayList<TrafficType>();
        types.add(TrafficType.Control);
        types.add(TrafficType.Management);
        types.add(TrafficType.Public);
        types.add(TrafficType.Storage);
    }
    sc.setParameters("trafficType", types.toArray());
    List<NetworkVO> dbNets = _networksDao.search(sc, null);
    if (dbNets == null) {
        s_logger.debug("no system networks for the given traffic types: " + types.toString());
        dbNets = new ArrayList<NetworkVO>();
    }
    List<PhysicalNetworkVO> phys_list = _physicalNetworkDao.listAll();
    final String provider = Provider.JuniperContrailRouter.getName();
    for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext(); ) {
        PhysicalNetworkVO phys = iter.next();
        if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null) {
            List<NetworkVO> infraNets = new ArrayList<NetworkVO>();
            findInfrastructureNetworks(phys, infraNets);
            for (NetworkVO net : infraNets) {
                if (types == null || types.isEmpty()) {
                    if (!dbNets.contains(net)) {
                        dbNets.add(net);
                    }
                    continue;
                }
                for (TrafficType type : types) {
                    if (net.getTrafficType() == type) {
                        if (!dbNets.contains(net)) {
                            dbNets.add(net);
                        }
                        break;
                    }
                }
            }
        }
    }
    return dbNets;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList) TrafficType(com.cloud.network.Networks.TrafficType)

Aggregations

TrafficType (com.cloud.network.Networks.TrafficType)26 NetworkVO (com.cloud.network.dao.NetworkVO)13 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)6 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 Pair (com.cloud.utils.Pair)3 ConfigurationException (javax.naming.ConfigurationException)3 Test (org.junit.Test)3 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 NetworkOffering (com.cloud.offering.NetworkOffering)2 DB (com.cloud.utils.db.DB)2 IOException (java.io.IOException)2 Map (java.util.Map)2 NicResponse (org.apache.cloudstack.api.response.NicResponse)2 ListResponse (com.cloud.api.response.ListResponse)1 TrafficTypeImplementorResponse (com.cloud.api.response.TrafficTypeImplementorResponse)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 CloudException (com.cloud.exception.CloudException)1