Search in sources :

Example 1 with TunnelEndPoint

use of org.onosproject.incubator.net.tunnel.TunnelEndPoint 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 TunnelEndPoint

use of org.onosproject.incubator.net.tunnel.TunnelEndPoint 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)

Example 3 with TunnelEndPoint

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

the class OvsdbTunnelProviderTest method testTunnelAdded.

@Test
public void testTunnelAdded() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel12"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelAdded(tunnel);
    assertEquals(1, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 4 with TunnelEndPoint

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

the class OvsdbTunnelProviderTest method testTunnelRemoved.

@Test
public void testTunnelRemoved() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel1"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelRemoved(tunnel);
    assertEquals(0, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 5 with TunnelEndPoint

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

the class TunnelBorrowCommand method doExecute.

@Override
protected void doExecute() {
    Collection<Tunnel> tunnelSet = null;
    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;
        }
        tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType);
    }
    if (!isNull(tunnelId)) {
        TunnelId id = TunnelId.valueOf(tunnelId);
        Tunnel tunnel = service.borrowTunnel(appId, id);
        tunnelSet = new HashSet<Tunnel>();
        tunnelSet.add(tunnel);
    }
    if (!isNull(tunnelName)) {
        TunnelName name = TunnelName.tunnelName(tunnelName);
        tunnelSet = service.borrowTunnel(appId, name);
    }
    for (Tunnel tunnel : tunnelSet) {
        print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), tunnel.groupId());
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) 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) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) TunnelName(org.onosproject.incubator.net.tunnel.TunnelName) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId)

Aggregations

IpTunnelEndPoint (org.onosproject.incubator.net.tunnel.IpTunnelEndPoint)7 TunnelEndPoint (org.onosproject.incubator.net.tunnel.TunnelEndPoint)7 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)5 OpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint)5 Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)5 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)5 ProviderId (org.onosproject.net.provider.ProviderId)5 DefaultTunnelDescription (org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)4 TunnelDescription (org.onosproject.incubator.net.tunnel.TunnelDescription)4 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)4 GroupId (org.onosproject.core.GroupId)3 SparseAnnotations (org.onosproject.net.SparseAnnotations)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ApplicationId (org.onosproject.core.ApplicationId)2 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)2 TunnelName (org.onosproject.incubator.net.tunnel.TunnelName)2 TunnelProvider (org.onosproject.incubator.net.tunnel.TunnelProvider)2 DefaultLink (org.onosproject.net.DefaultLink)2 DefaultPath (org.onosproject.net.DefaultPath)2