Search in sources :

Example 1 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class TunnelQueryCommand method doExecute.

@Override
protected void doExecute() {
    Tunnel.Type trueType = null;
    TunnelService service = get(TunnelService.class);
    ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
    Collection<Tunnel> tunnelSet = null;
    if (isNull(src) && isNull(dst) && isNull(type) && isNull(tunnelId)) {
        tunnelSet = service.queryAllTunnels();
    }
    if (!isNull(src) && !isNull(dst) && !isNull(type)) {
        TunnelEndPoint srcPoint = null;
        TunnelEndPoint dstPoint = null;
        if ("MPLS".equals(type) || "VXLAN".equals(type) || "GRE".equals(type)) {
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("VLAN".equals(type)) {
            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, null, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, null, OpticalLogicId.logicId(0), true);
        } else if ("ODUK".equals(type)) {
            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)) {
            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.TIMESLOT, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
        } else {
            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
            return;
        }
        tunnelSet = service.queryTunnel(srcPoint, dstPoint);
    }
    if (!isNull(type)) {
        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 = service.queryTunnel(trueType);
    }
    if (!isNull(tunnelId)) {
        TunnelId id = TunnelId.valueOf(tunnelId);
        Tunnel tunnel = service.queryTunnel(id);
        tunnelSet = new HashSet<Tunnel>();
        tunnelSet.add(tunnel);
    }
    if (tunnelSet != null) {
        for (Tunnel tunnel : tunnelSet) {
            print(FMT, tunnel.tunnelId().id(), tunnel.src().toString(), tunnel.dst().toString(), tunnel.type(), tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), tunnel.groupId(), showPath(tunnel.path()), annotations(tunnel.annotations()));
        }
    }
}
Also used : TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) ProviderId(org.onosproject.net.provider.ProviderId) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) 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) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Example 2 with ProviderId

use of org.onosproject.net.provider.ProviderId 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 3 with ProviderId

use of org.onosproject.net.provider.ProviderId 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 4 with ProviderId

use of org.onosproject.net.provider.ProviderId 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 5 with ProviderId

use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.

the class TunnelReturnCommand method doExecute.

@Override
protected void doExecute() {
    Tunnel.Type trueType = null;
    TunnelService service = get(TunnelService.class);
    ApplicationId appId = new DefaultApplicationId(1, consumerId);
    ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
    if (!isNull(src) && !isNull(dst) && !isNull(type)) {
        TunnelEndPoint srcPoint = null;
        TunnelEndPoint dstPoint = null;
        if ("MPLS".equals(type)) {
            trueType = Tunnel.Type.MPLS;
            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 ("VLAN".equals(type)) {
            trueType = Tunnel.Type.VLAN;
            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, null, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, null, OpticalLogicId.logicId(0), true);
        } 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.TIMESLOT, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
        } else {
            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
            return;
        }
        service.returnTunnel(appId, srcPoint, dstPoint, trueType);
    }
    if (!isNull(tunnelId)) {
        TunnelId id = TunnelId.valueOf(tunnelId);
        service.returnTunnel(appId, id);
    }
    if (!isNull(tunnelName)) {
        TunnelName name = TunnelName.tunnelName(tunnelName);
        service.returnTunnel(appId, name);
    }
}
Also used : TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) ProviderId(org.onosproject.net.provider.ProviderId) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) 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) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) TunnelName(org.onosproject.incubator.net.tunnel.TunnelName) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Aggregations

ProviderId (org.onosproject.net.provider.ProviderId)61 DefaultDevice (org.onosproject.net.DefaultDevice)15 DeviceId (org.onosproject.net.DeviceId)13 Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)12 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)12 Device (org.onosproject.net.Device)12 PortDescription (org.onosproject.net.device.PortDescription)12 TunnelProvider (org.onosproject.incubator.net.tunnel.TunnelProvider)10 DefaultPort (org.onosproject.net.DefaultPort)10 Port (org.onosproject.net.Port)10 DeviceEvent (org.onosproject.net.device.DeviceEvent)10 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)10 PortNumber (org.onosproject.net.PortNumber)9 DeviceDescription (org.onosproject.net.device.DeviceDescription)9 Timestamp (org.onosproject.store.Timestamp)9 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)9 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)9 DefaultTunnel (org.onosproject.incubator.net.tunnel.DefaultTunnel)7 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)7 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)7