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 VirtualHostListCommand method getSortedVirtualHosts.
/**
* Returns the list of virtual hosts sorted using the device identifier.
*
* @return virtual host list
*/
private List<VirtualHost> getSortedVirtualHosts() {
VirtualNetworkService service = get(VirtualNetworkService.class);
List<VirtualHost> virtualHosts = new ArrayList<>();
virtualHosts.addAll(service.getVirtualHosts(NetworkId.networkId(networkId)));
return virtualHosts;
}
use of org.onosproject.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualDeviceCompleter method getSortedVirtualDevices.
/**
* Returns the list of virtual devices sorted using the network identifier.
*
* @param networkId network id
* @return sorted virtual device list
*/
private List<VirtualDevice> getSortedVirtualDevices(long networkId) {
VirtualNetworkService service = getService(VirtualNetworkService.class);
List<VirtualDevice> virtualDevices = new ArrayList<>();
virtualDevices.addAll(service.getVirtualDevices(NetworkId.networkId(networkId)));
Collections.sort(virtualDevices, Comparators.VIRTUAL_DEVICE_COMPARATOR);
return virtualDevices;
}
use of org.onosproject.incubator.net.virtual.VirtualNetworkService in project onos by opennetworkinglab.
the class VirtualFlowsListCommand method doExecute.
@Override
protected void doExecute() {
CoreService coreService = get(CoreService.class);
VirtualNetworkService vnetservice = get(VirtualNetworkService.class);
DeviceService deviceService = vnetservice.get(NetworkId.networkId(networkId), DeviceService.class);
FlowRuleService service = vnetservice.get(NetworkId.networkId(networkId), FlowRuleService.class);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
compilePredicate();
SortedMap<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service);
if (outputJson()) {
print("%s", json(flows.keySet(), flows));
} else {
flows.forEach((device, flow) -> printFlows(device, flow, coreService));
}
}
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());
}
Aggregations