Search in sources :

Example 21 with TrafficType

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

the class NetworkServiceImpl method listTrafficTypeImplementor.

@Override
public List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd) {
    String type = cmd.getTrafficType();
    List<Pair<TrafficType, String>> results = new ArrayList<Pair<TrafficType, String>>();
    if (type != null) {
        for (NetworkGuru guru : _networkGurus) {
            if (guru.isMyTrafficType(TrafficType.getTrafficType(type))) {
                results.add(new Pair<TrafficType, String>(TrafficType.getTrafficType(type), guru.getName()));
                break;
            }
        }
    } else {
        for (NetworkGuru guru : _networkGurus) {
            TrafficType[] allTypes = guru.getSupportedTrafficType();
            for (TrafficType t : allTypes) {
                results.add(new Pair<TrafficType, String>(t, guru.getName()));
            }
        }
    }
    return results;
}
Also used : NetworkGuru(com.cloud.network.guru.NetworkGuru) ArrayList(java.util.ArrayList) TrafficType(com.cloud.network.Networks.TrafficType) Pair(com.cloud.utils.Pair)

Example 22 with TrafficType

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

the class ContrailElementImpl method isReady.

@Override
public boolean isReady(PhysicalNetworkServiceProvider provider) {
    Map<String, String> serviceMap = ((ConfigurationServerImpl) _configServer).getServicesAndProvidersForNetwork(_manager.getRouterOffering().getId());
    List<TrafficType> types = new ArrayList<TrafficType>();
    types.add(TrafficType.Control);
    types.add(TrafficType.Management);
    types.add(TrafficType.Storage);
    List<NetworkVO> systemNets = _manager.findSystemNetworks(types);
    if (systemNets != null && !systemNets.isEmpty()) {
        for (NetworkVO net : systemNets) {
            s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
            _networksDao.update(net.getId(), net, serviceMap);
        }
    } else {
        s_logger.debug("no system networks created yet");
    }
    serviceMap = ((ConfigurationServerImpl) _configServer).getServicesAndProvidersForNetwork(_manager.getPublicRouterOffering().getId());
    types = new ArrayList<TrafficType>();
    types.add(TrafficType.Public);
    systemNets = _manager.findSystemNetworks(types);
    if (systemNets != null && !systemNets.isEmpty()) {
        for (NetworkVO net : systemNets) {
            s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
            _networksDao.update(net.getId(), net, serviceMap);
        }
    } else {
        s_logger.debug("no system networks created yet");
    }
    return true;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) ConfigurationServerImpl(com.cloud.server.ConfigurationServerImpl) ArrayList(java.util.ArrayList) TrafficType(com.cloud.network.Networks.TrafficType)

Example 23 with TrafficType

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

the class ContrailManagerImpl method findManagedNetworks.

/*
     * Returns list of networks managed by Juniper VRouter filtered by traffic types
     */
@Override
public List<NetworkVO> findManagedNetworks(List<TrafficType> types) {
    SearchBuilder<NetworkVO> searchBuilder = _networksDao.createSearchBuilder();
    searchBuilder.and("trafficType", searchBuilder.entity().getTrafficType(), Op.IN);
    searchBuilder.and("networkOfferingId", searchBuilder.entity().getNetworkOfferingId(), Op.IN);
    SearchCriteria<NetworkVO> sc = searchBuilder.create();
    List<Long> offerings = new ArrayList<Long>();
    offerings.add(getRouterOffering().getId());
    offerings.add(getVpcRouterOffering().getId());
    offerings.add(getPublicRouterOffering().getId());
    sc.setParameters("networkOfferingId", offerings.toArray());
    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);
        types.add(TrafficType.Guest);
    }
    sc.setParameters("trafficType", types.toArray());
    List<NetworkVO> dbNets = _networksDao.search(sc, null);
    if (dbNets == null) {
        s_logger.debug("no juniper managed networks for the given traffic types: " + types.toString());
        dbNets = new ArrayList<NetworkVO>();
    }
    List<PhysicalNetworkVO> phys_list = _physicalNetworkDao.listAll();
    final String provider = Network.Provider.JuniperContrailRouter.getName();
    final String vpcProvider = Provider.JuniperContrailVpcRouter.getName();
    for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext(); ) {
        PhysicalNetworkVO phys = iter.next();
        if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null || _physProviderDao.findByServiceProvider(phys.getId(), vpcProvider) != 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) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) TrafficType(com.cloud.network.Networks.TrafficType)

Example 24 with TrafficType

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

the class ContrailManagerImpl method lookupPublicNetworkModel.

@Override
public VirtualNetworkModel lookupPublicNetworkModel() {
    List<TrafficType> types = new ArrayList<TrafficType>();
    types.add(TrafficType.Public);
    List<NetworkVO> dbNets = findManagedNetworks(types);
    if (dbNets == null) {
        return null;
    }
    NetworkVO net = dbNets.get(0);
    VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(net.getUuid(), getCanonicalName(net), TrafficType.Public);
    if (vnModel == null) {
        vnModel = new VirtualNetworkModel(net, net.getUuid(), getCanonicalName(net), net.getTrafficType());
        vnModel.setProperties(getModelController(), net);
    }
    try {
        if (!vnModel.verify(getModelController())) {
            vnModel.update(getModelController());
        }
        getDatabase().getVirtualNetworks().add(vnModel);
    } catch (Exception ex) {
        s_logger.warn("virtual-network update: ", ex);
    }
    return vnModel;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) ArrayList(java.util.ArrayList) ConfigurationException(javax.naming.ConfigurationException) IOException(java.io.IOException) TrafficType(com.cloud.network.Networks.TrafficType) VirtualNetworkModel(org.apache.cloudstack.network.contrail.model.VirtualNetworkModel)

Example 25 with TrafficType

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

the class VmwareResource method getTargetSwitch.

// return Ternary <switch name, switch tyep, vlan tagging>
private Ternary<String, String, String> getTargetSwitch(NicTO nicTo) throws CloudException {
    TrafficType[] supportedTrafficTypes = new TrafficType[] { TrafficType.Guest, TrafficType.Public, TrafficType.Control, TrafficType.Management, TrafficType.Storage };
    TrafficType trafficType = nicTo.getType();
    if (!Arrays.asList(supportedTrafficTypes).contains(trafficType)) {
        throw new CloudException("Traffic type " + trafficType.toString() + " for nic " + nicTo.toString() + " is not supported.");
    }
    String switchName = null;
    VirtualSwitchType switchType = VirtualSwitchType.StandardVirtualSwitch;
    String vlanId = Vlan.UNTAGGED;
    if (nicTo.getName() != null && !nicTo.getName().isEmpty()) {
        // Format of network traffic label is <VSWITCH>,<VLANID>,<VSWITCHTYPE>
        // If all 3 fields are mentioned then number of tokens would be 3.
        // If only <VSWITCH>,<VLANID> are mentioned then number of tokens would be 2.
        // Get switch details from the nicTO object
        String networkName = nicTo.getName();
        VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(networkName, trafficType);
        switchName = mgmtTrafficLabelObj.getVirtualSwitchName();
        vlanId = mgmtTrafficLabelObj.getVlanId();
        switchType = mgmtTrafficLabelObj.getVirtualSwitchType();
    } else {
        if (trafficType == TrafficType.Guest && _guestTrafficInfo != null) {
            switchType = _guestTrafficInfo.getVirtualSwitchType();
            switchName = _guestTrafficInfo.getVirtualSwitchName();
        } else if (trafficType == TrafficType.Public && _publicTrafficInfo != null) {
            switchType = _publicTrafficInfo.getVirtualSwitchType();
            switchName = _publicTrafficInfo.getVirtualSwitchName();
        }
    }
    if (switchName == null && (nicTo.getType() == Networks.TrafficType.Control || nicTo.getType() == Networks.TrafficType.Management || nicTo.getType() == Networks.TrafficType.Storage)) {
        switchName = _privateNetworkVSwitchName;
    }
    if (switchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
        if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
            throw new CloudException("Unable to configure NIC " + nicTo.toString() + " as traffic type " + trafficType.toString() + " is not supported over virtual switch type " + switchType + ". Please specify only supported type of virtual switches i.e. {vmwaresvs, vmwaredvs} in physical network traffic label.");
        }
    }
    return new Ternary<String, String, String>(switchName, switchType.toString(), vlanId);
}
Also used : VmwareTrafficLabel(com.cloud.network.VmwareTrafficLabel) Ternary(com.cloud.utils.Ternary) CloudException(com.cloud.exception.CloudException) VirtualSwitchType(com.cloud.hypervisor.vmware.mo.VirtualSwitchType) 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