Search in sources :

Example 11 with DeviceId

use of org.onosproject.net.DeviceId in project trellis-control by opennetworkinglab.

the class EcmpShortestPathGraph method getAllLearnedSwitchesAndVia.

/**
 * Returns the complete info of the computed ECMP paths for each target device
 * learned in multiple iterations from the root Device. The computed info
 * returned is per iteration (Integer key of outer HashMap). In each
 * iteration, for the target devices reached (DeviceId key of inner HashMap),
 * the ECMP paths are detailed (2D array).
 *
 * @return the hash table of target Devices learned in multiple Dijkstra
 *         iterations and corresponding ECMP paths in terms of Devices to
 *         be traversed (via) from the root Device to the target Device
 */
public HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> getAllLearnedSwitchesAndVia() {
    HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap = new HashMap<>();
    for (Integer itrIndx : distanceDeviceMap.keySet()) {
        HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap = new HashMap<>();
        for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
            ArrayList<ArrayList<DeviceId>> swViaArray = new ArrayList<>();
            for (Path path : getECMPPaths(sw)) {
                ArrayList<DeviceId> swVia = new ArrayList<>();
                for (Link link : path.links()) {
                    if (link.src().deviceId().equals(rootDevice)) {
                        /* No need to add the root Device again in
                             * the Via list
                             */
                        continue;
                    }
                    swVia.add(link.src().deviceId());
                }
                swViaArray.add(swVia);
            }
            swMap.put(sw, swViaArray);
        }
        deviceViaMap.put(itrIndx, swMap);
    }
    return deviceViaMap;
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link)

Example 12 with DeviceId

use of org.onosproject.net.DeviceId in project trellis-control by opennetworkinglab.

the class EcmpShortestPathGraph method getDFSPaths.

private void getDFSPaths(DeviceId dstDeviceDeviceId, Path path, ArrayList<Path> paths) {
    DeviceId rootDeviceDeviceId = rootDevice;
    for (Link upstreamLink : upstreamLinks.get(dstDeviceDeviceId)) {
        /* Deep clone the path object */
        Path sofarPath;
        ArrayList<Link> sofarLinks = new ArrayList<>();
        if (path != null && !path.links().isEmpty()) {
            sofarLinks.addAll(path.links());
        }
        sofarLinks.add(upstreamLink);
        sofarPath = new DefaultPath(ProviderId.NONE, sofarLinks, ScalarWeight.toWeight(0));
        if (upstreamLink.src().deviceId().equals(rootDeviceDeviceId)) {
            paths.add(sofarPath);
            return;
        } else {
            getDFSPaths(upstreamLink.src().deviceId(), sofarPath, paths);
        }
    }
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) DefaultPath(org.onosproject.net.DefaultPath) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link)

Example 13 with DeviceId

use of org.onosproject.net.DeviceId in project trellis-control by opennetworkinglab.

the class EcmpShortestPathGraph method getCompleteLearnedDeviceesAndPaths.

/**
 * Return the complete info of the computed ECMP paths for each Device
 * learned in multiple iterations from the root Device.
 *
 * @return the hash table of Devices learned in multiple Dijkstra
 *         iterations and corresponding ECMP paths to it from the root
 *         Device
 */
public HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> getCompleteLearnedDeviceesAndPaths() {
    HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new HashMap<>();
    for (Integer itrIndx : distanceDeviceMap.keySet()) {
        HashMap<DeviceId, ArrayList<Path>> swMap = new HashMap<>();
        for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
            swMap.put(sw, getECMPPaths(sw));
        }
        pathGraph.put(itrIndx, swMap);
    }
    return pathGraph;
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList)

Example 14 with DeviceId

use of org.onosproject.net.DeviceId in project trellis-control by opennetworkinglab.

the class HostHandler method processHostRemoved.

private void processHostRemoved(Host host) {
    MacAddress hostMac = host.mac();
    VlanId hostVlanId = host.vlan();
    Set<HostLocation> locations = effectiveLocations(host);
    Set<IpAddress> ips = host.ipAddresses();
    log.info("Host {}/{} is removed from {}", hostMac, hostVlanId, locations);
    locations.forEach(location -> {
        if (isDoubleTaggedHost(host)) {
            ips.forEach(ip -> processDoubleTaggedRoutingRule(location.deviceId(), location.port(), hostMac, host.innerVlan(), hostVlanId, host.tpid(), ip, true));
        } else {
            processBridgingRule(location.deviceId(), location.port(), hostMac, hostVlanId, true);
            ips.forEach(ip -> processRoutingRule(location.deviceId(), location.port(), hostMac, hostVlanId, ip, true));
        }
        // Also remove redirection flows on the pair device if exists.
        Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(location.deviceId());
        Optional<PortNumber> pairLocalPort = srManager.getPairLocalPort(location.deviceId());
        if (pairDeviceId.isPresent() && pairLocalPort.isPresent()) {
            // NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
            // when the host is untagged
            VlanId vlanId = vlanForPairPort(hostVlanId, location);
            if (vlanId == null) {
                return;
            }
            processBridgingRule(pairDeviceId.get(), pairLocalPort.get(), hostMac, vlanId, true);
            ips.forEach(ip -> processRoutingRule(pairDeviceId.get(), pairLocalPort.get(), hostMac, vlanId, ip, true));
        }
        // Delete prefix from sr-device-subnet when the next hop host is removed
        srManager.routeService.getRouteTables().forEach(tableId -> {
            srManager.routeService.getRoutes(tableId).forEach(routeInfo -> {
                if (routeInfo.allRoutes().stream().anyMatch(rr -> ips.contains(rr.nextHop()))) {
                    log.debug("HostRemoved. removeSubnet {}, {}", location, routeInfo.prefix());
                    srManager.deviceConfiguration.removeSubnet(location, routeInfo.prefix());
                }
            });
        });
    });
}
Also used : DeviceId(org.onosproject.net.DeviceId) HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Example 15 with DeviceId

use of org.onosproject.net.DeviceId in project trellis-control by opennetworkinglab.

the class HostHandler method isHostInVlanOfPort.

/**
 * Checks if given host located on given device id matches VLAN config of current port.
 *
 * @param host host to check
 * @param deviceId device id to check
 * @param cp current connect point
 * @return true if the host located at deviceId matches the VLAN config on cp
 */
private boolean isHostInVlanOfPort(Host host, DeviceId deviceId, ConnectPoint cp) {
    VlanId internalVlan = srManager.getInternalVlanId(cp);
    Set<VlanId> taggedVlan = srManager.interfaceService.getTaggedVlanId(cp);
    return taggedVlan.contains(host.vlan()) || (internalVlan != null && effectiveLocations(host).stream().filter(l -> l.deviceId().equals(deviceId)).map(srManager::getInternalVlanId).anyMatch(internalVlan::equals));
}
Also used : HostLocation(org.onosproject.net.HostLocation) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) PredictableExecutor(org.onlab.util.PredictableExecutor) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) CompletableFuture(java.util.concurrent.CompletableFuture) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) IpAddress(org.onlab.packet.IpAddress) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Phase(org.onosproject.segmentrouting.phasedrecovery.api.Phase) ProbeMode(org.onosproject.net.host.ProbeMode) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) EthType(org.onlab.packet.EthType) List(java.util.List) Objective(org.onosproject.net.flowobjective.Objective) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) VlanId(org.onlab.packet.VlanId)

Aggregations

DeviceId (org.onosproject.net.DeviceId)782 List (java.util.List)178 PortNumber (org.onosproject.net.PortNumber)170 Collectors (java.util.stream.Collectors)152 ConnectPoint (org.onosproject.net.ConnectPoint)152 Set (java.util.Set)138 DeviceService (org.onosproject.net.device.DeviceService)122 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)118 ArrayList (java.util.ArrayList)115 VlanId (org.onlab.packet.VlanId)115 Logger (org.slf4j.Logger)114 Collections (java.util.Collections)109 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)109 Device (org.onosproject.net.Device)107 Collection (java.util.Collection)106 Test (org.junit.Test)104 CoreService (org.onosproject.core.CoreService)103 FlowRule (org.onosproject.net.flow.FlowRule)101 ImmutableSet (com.google.common.collect.ImmutableSet)99 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)96