use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.
the class PortAuthTracker method logPortsNoLongerBlocked.
private void logPortsNoLongerBlocked() {
for (Map.Entry<DeviceId, Map<PortNumber, BlockState>> entry : oldMap.entrySet()) {
DeviceId d = entry.getKey();
Map<PortNumber, BlockState> portMap = entry.getValue();
for (PortNumber p : portMap.keySet()) {
if (notInMap(d, p)) {
clearBlockingFlow(d, p);
log.info("De-configuring port {}/{} (UNCHECKED)", d, p);
}
}
}
}
use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.
the class RouteHandler method processSingleLeafPairIfNeeded.
protected boolean processSingleLeafPairIfNeeded(Set<ConnectPoint> locations, ConnectPoint location, IpPrefix prefix, VlanId nextHopVlan) {
// Special handling for single leaf pair
if (!srManager.getInfraDeviceIds().isEmpty()) {
log.debug("Spine found. Skip single leaf pair handling");
return false;
}
Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(location.deviceId());
if (pairDeviceId.isEmpty()) {
log.debug("Pair device of {} not found", location.deviceId());
return false;
}
if (locations.stream().anyMatch(l -> l.deviceId().equals(pairDeviceId.get()))) {
log.debug("Pair device has a next hop available. Leave it as is.");
return false;
}
Optional<PortNumber> pairRemotePort = srManager.getPairLocalPort(pairDeviceId.get());
if (pairRemotePort.isEmpty()) {
log.debug("Pair remote port of {} not found", pairDeviceId.get());
return false;
}
// Use routerMac of the pair device as the next hop
MacAddress effectiveMac;
try {
effectiveMac = srManager.getDeviceMacAddress(location.deviceId());
} catch (DeviceConfigNotFoundException e) {
log.warn("Abort populateRoute on pair device {}. routerMac not found", pairDeviceId);
return false;
}
// Since the pairLocalPort is trunk port, use assigned vlan of original port
// when the host is untagged
VlanId effectiveVlan = Optional.ofNullable(srManager.getInternalVlanId(location)).orElse(nextHopVlan);
log.debug("Single leaf pair. populateRoute {}/{}, {}, {}, {}", pairDeviceId, pairRemotePort, prefix, effectiveMac, effectiveVlan);
srManager.defaultRoutingHandler.populateRoute(pairDeviceId.get(), prefix, effectiveMac, effectiveVlan, pairRemotePort.get(), false);
return true;
}
use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.
the class PortsCommand method doExecute.
@Override
protected void doExecute() {
PhasedRecoveryService prService = get(PhasedRecoveryService.class);
DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
boolean enabled;
switch(actionStr.toUpperCase()) {
case "ENABLE":
enabled = true;
break;
case "DISABLE":
enabled = false;
break;
default:
print("Action should be either ENABLE or DISABLE");
return;
}
Set<PortNumber> portsChanged;
switch(portsStr.toUpperCase()) {
case "ALL":
portsChanged = prService.changeAllPorts(deviceId, enabled);
break;
case "PAIR":
portsChanged = prService.changePairPort(deviceId, enabled);
break;
case "INFRA":
portsChanged = prService.changeInfraPorts(deviceId, enabled);
break;
case "EDGE":
portsChanged = prService.changeEdgePorts(deviceId, enabled);
break;
default:
print("Ports should be ALL, PAIR, INFRA, EDGE");
return;
}
print("Ports set to %s: %s", enabled ? "enabled" : "disabled", portsChanged.stream().map(PortNumber::toLong).collect(Collectors.toSet()));
}
use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.
the class XconnectManager method getPhysicalPorts.
private Set<PortNumber> getPhysicalPorts(DeviceId deviceId, XconnectEndpoint endpoint) {
if (endpoint.type() == XconnectEndpoint.Type.PORT) {
PortNumber port = ((XconnectPortEndpoint) endpoint).port();
return Sets.newHashSet(port);
}
if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
Set<PortNumber> ports = portLoadBalancerService.getPortLoadBalancer(portLoadBalancerId).ports();
return Sets.newHashSet(ports);
}
return Sets.newHashSet();
}
use of org.onosproject.net.PortNumber in project trellis-control by opennetworkinglab.
the class MockFlowObjectiveService method forward.
@Override
public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
TrafficSelector selector = forwardingObjective.selector();
TrafficTreatment treatment = nextTable.get(forwardingObjective.nextId());
MacAddress macAddress = ((EthCriterion) selector.getCriterion(Criterion.Type.ETH_DST)).mac();
VlanId vlanId = ((VlanIdCriterion) selector.getCriterion(Criterion.Type.VLAN_VID)).vlanId();
boolean popVlan = treatment.allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.L2MODIFICATION)).anyMatch(instruction -> ((L2ModificationInstruction) instruction).subtype().equals(L2ModificationInstruction.L2SubType.VLAN_POP));
PortNumber portNumber = treatment.allInstructions().stream().filter(instruction -> instruction.type().equals(Instruction.Type.OUTPUT)).map(instruction -> ((Instructions.OutputInstruction) instruction).port()).findFirst().orElse(null);
if (portNumber == null) {
throw new IllegalArgumentException();
}
Objective.Operation op = forwardingObjective.op();
MockBridgingTableKey btKey = new MockBridgingTableKey(deviceId, macAddress, vlanId);
MockBridgingTableValue btValue = new MockBridgingTableValue(popVlan, portNumber);
if (op.equals(Objective.Operation.ADD)) {
bridgingTable.put(btKey, btValue);
forwardingObjective.context().ifPresent(context -> context.onSuccess(forwardingObjective));
} else if (op.equals(Objective.Operation.REMOVE)) {
bridgingTable.remove(btKey, btValue);
forwardingObjective.context().ifPresent(context -> context.onSuccess(forwardingObjective));
} else {
forwardingObjective.context().ifPresent(context -> context.onError(forwardingObjective, ObjectiveError.UNKNOWN));
throw new IllegalArgumentException();
}
}
Aggregations