use of org.onosproject.incubator.net.tunnel.DefaultTunnelDescription 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());
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnelDescription 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());
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnelDescription 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);
}
}
}
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnelDescription 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);
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnelDescription in project onos by opennetworkinglab.
the class TunnelCreateCommand method doExecute.
@Override
protected void doExecute() {
TunnelProvider service = get(TunnelProvider.class);
ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
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;
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 ("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.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;
}
SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", bandwidth == null || "".equals(bandwidth) ? "0" : bandwidth).build();
TunnelDescription tunnel = new DefaultTunnelDescription(null, srcPoint, dstPoint, trueType, new GroupId(Integer.parseInt(groupId)), producerName, TunnelName.tunnelName(tunnelName), null, annotations);
TunnelId tunnelId = service.tunnelAdded(tunnel);
if (tunnelId == null) {
error("Create tunnel failed.");
return;
}
print(FMT, tunnelId.id());
}
Aggregations