Search in sources :

Example 1 with VirtualNetworkService

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);
}
Also used : DeviceId(org.onosproject.net.DeviceId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultVirtualPort(org.onosproject.incubator.net.virtual.DefaultVirtualPort)

Example 2 with VirtualNetworkService

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;
}
Also used : VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) ArrayList(java.util.ArrayList) VirtualHost(org.onosproject.incubator.net.virtual.VirtualHost)

Example 3 with VirtualNetworkService

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;
}
Also used : VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ArrayList(java.util.ArrayList)

Example 4 with VirtualNetworkService

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));
    }
}
Also used : VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) Device(org.onosproject.net.Device) DeviceService(org.onosproject.net.device.DeviceService) CoreService(org.onosproject.core.CoreService) StringFilter(org.onlab.util.StringFilter) ArrayList(java.util.ArrayList) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) FlowRuleService(org.onosproject.net.flow.FlowRuleService)

Example 5 with VirtualNetworkService

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());
}
Also used : IntentService(org.onosproject.net.intent.IntentService) Constraint(org.onosproject.net.intent.Constraint) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) VirtualNetworkIntent(org.onosproject.incubator.net.virtual.VirtualNetworkIntent) Intent(org.onosproject.net.intent.Intent) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)18 ArrayList (java.util.ArrayList)9 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 CoreService (org.onosproject.core.CoreService)2 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 DeviceId (org.onosproject.net.DeviceId)2 TenantId (org.onosproject.net.TenantId)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 Intent (org.onosproject.net.intent.Intent)2 IntentService (org.onosproject.net.intent.IntentService)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 BigInteger (java.math.BigInteger)1 List (java.util.List)1 StringFilter (org.onlab.util.StringFilter)1 ApplicationId (org.onosproject.core.ApplicationId)1 DefaultVirtualPort (org.onosproject.incubator.net.virtual.DefaultVirtualPort)1 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)1 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)1