use of org.onosproject.incubator.net.virtual.VirtualPort in project onos by opennetworkinglab.
the class DefaultVirtualFlowRuleProvider method extractEgressPoints.
/**
* Extract egress connect point of the physical network
* from the requested traffic treatment.
*
* @param networkId the virtual network identifier
* @param deviceId the virtual device identifier
* @param treatment the traffic treatment to extract ingress point
* @return the egress connect point of the physical network
*/
private ConnectPoint extractEgressPoints(NetworkId networkId, DeviceId deviceId, TrafficTreatment treatment) {
Set<VirtualPort> vPorts = vnService.getVirtualPorts(networkId, deviceId);
PortNumber vOutPortNum = treatment.allInstructions().stream().filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> ((Instructions.OutputInstruction) i).port()).findFirst().get();
Optional<ConnectPoint> optionalCpOut = vPorts.stream().filter(v -> v.number().equals(vOutPortNum)).map(VirtualPort::realizedBy).findFirst();
if (!optionalCpOut.isPresent()) {
if (vOutPortNum.isLogical()) {
return new ConnectPoint(DeviceId.deviceId("vNet"), vOutPortNum);
}
log.warn("Port {} is not realized yet, in Network {}, Device {}", vOutPortNum, networkId, deviceId);
return null;
}
return optionalCpOut.get();
}
use of org.onosproject.incubator.net.virtual.VirtualPort in project onos by opennetworkinglab.
the class DefaultVirtualFlowRuleProvider method extractIngressPoints.
/**
* Extract ingress connect points of the physical network
* from the requested traffic selector.
*
* @param networkId the virtual network identifier
* @param deviceId the virtual device identifier
* @param selector the traffic selector to extract ingress point
* @return the set of ingress connect points of the physical network
*/
private Set<ConnectPoint> extractIngressPoints(NetworkId networkId, DeviceId deviceId, TrafficSelector selector) {
Set<ConnectPoint> ingressPoints = new HashSet<>();
Set<VirtualPort> vPorts = vnService.getVirtualPorts(networkId, deviceId);
PortCriterion portCriterion = ((PortCriterion) selector.getCriterion(Criterion.Type.IN_PORT));
if (portCriterion != null) {
PortNumber vInPortNum = portCriterion.port();
Optional<ConnectPoint> optionalCp = vPorts.stream().filter(v -> v.number().equals(vInPortNum)).map(VirtualPort::realizedBy).findFirst();
if (!optionalCp.isPresent()) {
log.warn("Port {} is not realized yet, in Network {}, Device {}", vInPortNum, networkId, deviceId);
return ingressPoints;
}
ingressPoints.add(optionalCp.get());
} else {
for (VirtualPort vPort : vPorts) {
if (vPort.realizedBy() != null) {
ingressPoints.add(vPort.realizedBy());
} else {
log.warn("Port {} is not realized yet, in Network {}, " + "Device {}", vPort, networkId, deviceId);
}
}
}
return ingressPoints;
}
use of org.onosproject.incubator.net.virtual.VirtualPort in project onos by opennetworkinglab.
the class VirtualPortCompleter method getSortedVirtualPorts.
/**
* Returns the list of virtual ports sorted using the port number.
*
* @param networkId network id.
* @param deviceId device id
* @return sorted virtual port list
*/
private List<VirtualPort> getSortedVirtualPorts(long networkId, String deviceId) {
VirtualNetworkService service = getService(VirtualNetworkService.class);
List<VirtualPort> virtualPorts = new ArrayList<>();
virtualPorts.addAll(service.getVirtualPorts(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId)));
Collections.sort(virtualPorts, Comparators.VIRTUAL_PORT_COMPARATOR);
return virtualPorts;
}
use of org.onosproject.incubator.net.virtual.VirtualPort in project onos by opennetworkinglab.
the class VirtualPortListCommand method getSortedVirtualPorts.
/**
* Returns the list of virtual ports sorted using the network identifier.
*
* @return sorted virtual port list
*/
private List<VirtualPort> getSortedVirtualPorts() {
VirtualNetworkService service = get(VirtualNetworkService.class);
List<VirtualPort> virtualPorts = new ArrayList<>();
virtualPorts.addAll(service.getVirtualPorts(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId)));
Collections.sort(virtualPorts, Comparators.VIRTUAL_PORT_COMPARATOR);
return virtualPorts;
}
use of org.onosproject.incubator.net.virtual.VirtualPort in project onos by opennetworkinglab.
the class VirtualPortStateCommand method doExecute.
@Override
protected void doExecute() {
VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
VirtualPort vPort = getVirtualPort(PortNumber.portNumber(portNum));
checkNotNull(vPort, "The virtual Port does not exist");
boolean isEnabled;
if ("enable".equals(portState)) {
isEnabled = true;
} else if ("disable".equals(portState)) {
isEnabled = false;
} else {
print("State must be enable or disable");
return;
}
service.updatePortState(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId), vPort.number(), isEnabled);
print("Virtual port state updated.");
}
Aggregations