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