use of org.onosproject.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualLinkListCommand method getSortedVirtualLinks.
/**
* Returns the list of virtual links sorted using the device identifier.
*
* @return virtual link list
*/
private List<VirtualLink> getSortedVirtualLinks() {
VirtualNetworkService service = get(VirtualNetworkService.class);
List<VirtualLink> virtualLinks = new ArrayList<>();
virtualLinks.addAll(service.getVirtualLinks(NetworkId.networkId(networkId)));
return virtualLinks;
}
use of org.onosproject.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualNetworkIntentCreateCommand method doExecute.
@Override
protected void doExecute() {
VirtualNetworkService service = get(VirtualNetworkService.class);
IntentService virtualNetworkIntentService = service.get(NetworkId.networkId(networkId), IntentService.class);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
Intent intent = VirtualNetworkIntent.builder().networkId(NetworkId.networkId(networkId)).appId(appId()).key(key()).selector(selector).treatment(treatment).ingressPoint(ingress).egressPoint(egress).constraints(constraints).priority(priority()).build();
virtualNetworkIntentService.submit(intent);
print("Virtual intent submitted:\n%s", intent.toString());
}
use of org.onosproject.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualNetworkListCommand method getSortedVirtualNetworks.
/**
* Returns the list of virtual networks sorted using the tenant identifier.
*
* @return sorted virtual network list
*/
private List<VirtualNetwork> getSortedVirtualNetworks() {
VirtualNetworkService service = get(VirtualNetworkService.class);
VirtualNetworkAdminService adminService = get(VirtualNetworkAdminService.class);
List<VirtualNetwork> virtualNetworks = new ArrayList<>();
Set<TenantId> tenantSet = adminService.getTenantIds();
tenantSet.forEach(tenantId -> virtualNetworks.addAll(service.getVirtualNetworks(tenantId)));
Collections.sort(virtualNetworks, Comparators.VIRTUAL_NETWORK_COMPARATOR);
return virtualNetworks;
}
use of org.onosproject.incubator.net.virtual.VirtualNetworkService 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.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualPortBindCommand method getVirtualPort.
/**
* Returns the virtual port matching the device and port identifier.
*
* @param aPortNumber port identifier
* @return matching virtual port, or null.
*/
private VirtualPort getVirtualPort(PortNumber aPortNumber) {
VirtualNetworkService service = get(VirtualNetworkService.class);
Set<VirtualPort> ports = service.getVirtualPorts(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId));
return ports.stream().filter(p -> p.number().equals(aPortNumber)).findFirst().get();
}
Aggregations