Search in sources :

Example 1 with TunnelProvider

use of org.onosproject.incubator.net.tunnel.TunnelProvider in project onos by opennetworkinglab.

the class TunnelManager method removeTunnels.

@Override
public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, ProviderId producerName) {
    Collection<Tunnel> setTunnels = store.queryTunnel(src, dst);
    if (!setTunnels.isEmpty()) {
        store.deleteTunnel(src, dst, producerName);
        for (Tunnel tunnel : setTunnels) {
            if (producerName != null && !tunnel.providerId().equals(producerName)) {
                continue;
            }
            if (tunnel.providerId() != null) {
                TunnelProvider provider = getProvider(tunnel.providerId());
                if (provider != null) {
                    provider.releaseTunnel(tunnel);
                }
            } else {
                Set<ProviderId> ids = getProviders();
                for (ProviderId providerId : ids) {
                    TunnelProvider provider = getProvider(providerId);
                    provider.releaseTunnel(tunnel);
                }
            }
        }
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel)

Example 2 with TunnelProvider

use of org.onosproject.incubator.net.tunnel.TunnelProvider in project onos by opennetworkinglab.

the class TunnelManager method downTunnel.

@Override
public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) {
    // TODO: producerId to check if really required to consider while deleting the tunnel.
    checkNotNull(tunnelId, TUNNNEL_ID_NULL);
    Tunnel tunnel = store.queryTunnel(tunnelId);
    if (tunnel != null) {
        TunnelId updtTunnelId = store.createOrUpdateTunnel(tunnel, State.INACTIVE);
        if (updtTunnelId != null) {
            Set<ProviderId> ids = getProviders();
            for (ProviderId providerId : ids) {
                TunnelProvider provider = getProvider(providerId);
                provider.releaseTunnel(tunnel);
            }
        }
        return true;
    }
    return false;
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Example 3 with TunnelProvider

use of org.onosproject.incubator.net.tunnel.TunnelProvider in project onos by opennetworkinglab.

the class TunnelManager method removeTunnels.

@Override
public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Type type, ProviderId producerName) {
    Collection<Tunnel> setTunnels = store.queryTunnel(src, dst);
    if (!setTunnels.isEmpty()) {
        store.deleteTunnel(src, dst, type, producerName);
        for (Tunnel tunnel : setTunnels) {
            if (producerName != null && !tunnel.providerId().equals(producerName) || !type.equals(tunnel.type())) {
                continue;
            }
            if (tunnel.providerId() != null) {
                TunnelProvider provider = getProvider(tunnel.providerId());
                if (provider != null) {
                    provider.releaseTunnel(tunnel);
                }
            } else {
                Set<ProviderId> ids = getProviders();
                for (ProviderId providerId : ids) {
                    TunnelProvider provider = getProvider(providerId);
                    provider.releaseTunnel(tunnel);
                }
            }
        }
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel)

Example 4 with TunnelProvider

use of org.onosproject.incubator.net.tunnel.TunnelProvider in project onos by opennetworkinglab.

the class TunnelRemoveCommand method doExecute.

@Override
protected void doExecute() {
    TunnelDescription tunnel = null;
    TunnelProvider service = get(TunnelProvider.class);
    ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
    if (!isNull(src) && !isNull(dst) && !isNull(type)) {
        TunnelEndPoint srcPoint = null;
        TunnelEndPoint dstPoint = null;
        Tunnel.Type trueType = null;
        if ("MPLS".equals(type)) {
            trueType = Tunnel.Type.MPLS;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("VLAN".equals(type)) {
            trueType = Tunnel.Type.VLAN;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("VXLAN".equals(type)) {
            trueType = Tunnel.Type.VXLAN;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("GRE".equals(type)) {
            trueType = Tunnel.Type.GRE;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("ODUK".equals(type)) {
            trueType = Tunnel.Type.ODUK;
            String[] srcArray = src.split("/");
            String[] dstArray = dst.split("/");
            srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
        } else if ("OCH".equals(type)) {
            trueType = Tunnel.Type.OCH;
            String[] srcArray = src.split("/");
            String[] dstArray = dst.split("/");
            srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
        } else {
            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
            return;
        }
        tunnel = new DefaultTunnelDescription(null, srcPoint, dstPoint, trueType, null, producerName, null, null);
        service.tunnelRemoved(tunnel);
        return;
    }
    if (!isNull(tunnelId)) {
        TunnelId id = TunnelId.valueOf(tunnelId);
        tunnel = new DefaultTunnelDescription(id, null, null, null, null, producerName, null, null);
        service.tunnelRemoved(tunnel);
        return;
    }
    if (!isNull(type)) {
        Tunnel.Type trueType = null;
        Collection<Tunnel> tunnelSet = null;
        TunnelService tunnelService = get(TunnelService.class);
        if ("MPLS".equals(type)) {
            trueType = Tunnel.Type.MPLS;
        } else if ("VLAN".equals(type)) {
            trueType = Tunnel.Type.VLAN;
        } else if ("VXLAN".equals(type)) {
            trueType = Tunnel.Type.VXLAN;
        } else if ("GRE".equals(type)) {
            trueType = Tunnel.Type.GRE;
        } else if ("ODUK".equals(type)) {
            trueType = Tunnel.Type.ODUK;
        } else if ("OCH".equals(type)) {
            trueType = Tunnel.Type.OCH;
        } else {
            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
            return;
        }
        tunnelSet = tunnelService.queryTunnel(trueType);
        if (tunnelSet != null) {
            for (Tunnel tunnelTemp : tunnelSet) {
                tunnel = new DefaultTunnelDescription(tunnelTemp.tunnelId(), null, null, null, null, producerName, null, null);
                service.tunnelRemoved(tunnel);
            }
        }
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) OpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)

Example 5 with TunnelProvider

use of org.onosproject.incubator.net.tunnel.TunnelProvider in project onos by opennetworkinglab.

the class TunnelUpdateCommand method doExecute.

@Override
protected void doExecute() {
    TunnelProvider service = get(TunnelProvider.class);
    TunnelId id = TunnelId.valueOf(tunnelId);
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", bandwidth).build();
    TunnelDescription tunnel = new DefaultTunnelDescription(id, null, null, null, null, null, null, null, annotations);
    service.tunnelUpdated(tunnel);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Aggregations

TunnelProvider (org.onosproject.incubator.net.tunnel.TunnelProvider)11 ProviderId (org.onosproject.net.provider.ProviderId)10 Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)9 DefaultTunnel (org.onosproject.incubator.net.tunnel.DefaultTunnel)7 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)5 DefaultTunnelDescription (org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)3 TunnelDescription (org.onosproject.incubator.net.tunnel.TunnelDescription)3 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)2 IpTunnelEndPoint (org.onosproject.incubator.net.tunnel.IpTunnelEndPoint)2 OpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint)2 TunnelEndPoint (org.onosproject.incubator.net.tunnel.TunnelEndPoint)2 SparseAnnotations (org.onosproject.net.SparseAnnotations)2 GroupId (org.onosproject.core.GroupId)1 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)1