Search in sources :

Example 76 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class VirtualNetworkFlowObjectiveManager method getNextMappings.

@Override
public List<String> getNextMappings() {
    List<String> mappings = new ArrayList<>();
    Map<Integer, NextGroup> allnexts = flowObjectiveStore.getAllGroups();
    for (Map.Entry<Integer, NextGroup> e : allnexts.entrySet()) {
        // get the device this next Objective was sent to
        DeviceId deviceId = nextToDevice.get(e.getKey());
        mappings.add("NextId " + e.getKey() + ": " + ((deviceId != null) ? deviceId : "nextId not in this onos instance"));
        if (deviceId != null) {
            // this instance of the controller sent the nextObj to a driver
            Pipeliner pipeliner = getDevicePipeliner(deviceId);
            List<String> nextMappings = pipeliner.getNextMappings(e.getValue());
            if (nextMappings != null) {
                mappings.addAll(nextMappings);
            }
        }
    }
    return mappings;
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) Pipeliner(org.onosproject.net.behaviour.Pipeliner) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 77 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class VirtualDeviceCodec method decode.

@Override
public VirtualDevice decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    DeviceId dId = DeviceId.deviceId(extractMember(ID, json));
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    return new DefaultVirtualDevice(nId, dId);
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Example 78 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class VirtualPortCodec method decode.

@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
    VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
    Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
    VirtualDevice vDev = vDevs.stream().filter(virtualDevice -> virtualDevice.id().equals(dId)).findFirst().orElse(null);
    nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
    PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
    DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
    PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
    ConnectPoint realizedBy = new ConnectPoint(physDId, physPortNum);
    return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
Also used : DeviceId(org.onosproject.net.DeviceId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultVirtualPort(org.onosproject.incubator.net.virtual.DefaultVirtualPort)

Example 79 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class UiTopology method inferSyntheticLink.

private UiSynthLink inferSyntheticLink(UiDeviceLink link) {
    /*
          Look at the containment hierarchy of each end of the link. Find the
          common ancestor region R. A synthetic link will be added to R, based
          on the "next" node back down the branch...

                S1 --- S2       * in the same region ...
                :      :
                R      R          return S1 --- S2 (same link instance)


                S1 --- S2       * in different regions (R1, R2) at same level
                :      :
                R1     R2         return R1 --- R2
                :      :
                R      R

                S1 --- S2       * in different regions at different levels
                :      :
                R1     R2         return R1 --- R3
                :      :
                R      R3
                       :
                       R

                S1 --- S2       * in different regions at different levels
                :      :
                R      R2         return S1 --- R2
                       :
                       R

         */
    DeviceId a = link.deviceA();
    DeviceId b = link.deviceB();
    List<RegionId> aBranch = ancestors(a);
    List<RegionId> bBranch = ancestors(b);
    if (aBranch == null || bBranch == null) {
        return null;
    }
    return makeSynthLink(link, aBranch, bBranch);
}
Also used : DeviceId(org.onosproject.net.DeviceId) RegionId(org.onosproject.net.region.RegionId)

Example 80 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class EncodeConstraintCodecHelper method encodeWaypointConstraint.

/**
 * Encodes a waypoint constraint.
 *
 * @return JSON ObjectNode representing the constraint
 */
private ObjectNode encodeWaypointConstraint() {
    checkNotNull(constraint, "Waypoint constraint cannot be null");
    final WaypointConstraint waypointConstraint = (WaypointConstraint) constraint;
    final ObjectNode result = context.mapper().createObjectNode();
    final ArrayNode jsonWaypoints = result.putArray("waypoints");
    for (DeviceId did : waypointConstraint.waypoints()) {
        jsonWaypoints.add(did.toString());
    }
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) WaypointConstraint(org.onosproject.net.intent.constraint.WaypointConstraint) DeviceId(org.onosproject.net.DeviceId) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

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