Search in sources :

Example 6 with VirtualNetworkService

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

Example 7 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)

Example 8 with VirtualNetworkService

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

Example 9 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 10 with VirtualNetworkService

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

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