Committed by
Gerrit Code Review
Refactored tunnel and interface config behavior
- Added tunnel interface configuratoin to interfaceConfig and deprecated tunnelConfig - OVSDB client service provides interface create/remove APIs instead of tunnel interface create/remove, and this APIs can be used to create/remove various types of interfaces like tunnel, patch, tap and so on - Use tunnel description when create tunnel interface so that we can extend more config options later - Some cleaup OVSDB client Change-Id: I4653595504a27b18384a92ebe4b31ce9d99237cd
Showing
23 changed files
with
952 additions
and
409 deletions
| ... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.openstacknode; | 16 | package org.onosproject.openstacknode; |
| 17 | 17 | ||
| 18 | -import com.google.common.collect.ImmutableMap; | ||
| 19 | -import com.google.common.collect.Sets; | ||
| 20 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -30,19 +28,18 @@ import org.onosproject.cluster.LeadershipService; | ... | @@ -30,19 +28,18 @@ import org.onosproject.cluster.LeadershipService; |
| 30 | import org.onosproject.cluster.NodeId; | 28 | import org.onosproject.cluster.NodeId; |
| 31 | import org.onosproject.core.ApplicationId; | 29 | import org.onosproject.core.ApplicationId; |
| 32 | import org.onosproject.core.CoreService; | 30 | import org.onosproject.core.CoreService; |
| 33 | -import org.onosproject.net.DefaultAnnotations; | ||
| 34 | import org.onosproject.net.Device; | 31 | import org.onosproject.net.Device; |
| 35 | import org.onosproject.net.DeviceId; | 32 | import org.onosproject.net.DeviceId; |
| 36 | import org.onosproject.net.Port; | 33 | import org.onosproject.net.Port; |
| 37 | import org.onosproject.net.behaviour.BridgeConfig; | 34 | import org.onosproject.net.behaviour.BridgeConfig; |
| 38 | import org.onosproject.net.behaviour.BridgeDescription; | 35 | import org.onosproject.net.behaviour.BridgeDescription; |
| 39 | -import org.onosproject.net.behaviour.BridgeName; | ||
| 40 | import org.onosproject.net.behaviour.ControllerInfo; | 36 | import org.onosproject.net.behaviour.ControllerInfo; |
| 41 | import org.onosproject.net.behaviour.DefaultBridgeDescription; | 37 | import org.onosproject.net.behaviour.DefaultBridgeDescription; |
| 42 | import org.onosproject.net.behaviour.DefaultTunnelDescription; | 38 | import org.onosproject.net.behaviour.DefaultTunnelDescription; |
| 43 | -import org.onosproject.net.behaviour.TunnelConfig; | 39 | +import org.onosproject.net.behaviour.InterfaceConfig; |
| 44 | import org.onosproject.net.behaviour.TunnelDescription; | 40 | import org.onosproject.net.behaviour.TunnelDescription; |
| 45 | -import org.onosproject.net.behaviour.TunnelName; | 41 | +import org.onosproject.net.behaviour.TunnelEndPoints; |
| 42 | +import org.onosproject.net.behaviour.TunnelKeys; | ||
| 46 | import org.onosproject.net.config.ConfigFactory; | 43 | import org.onosproject.net.config.ConfigFactory; |
| 47 | import org.onosproject.net.config.NetworkConfigEvent; | 44 | import org.onosproject.net.config.NetworkConfigEvent; |
| 48 | import org.onosproject.net.config.NetworkConfigListener; | 45 | import org.onosproject.net.config.NetworkConfigListener; |
| ... | @@ -72,7 +69,6 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -72,7 +69,6 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 72 | 69 | ||
| 73 | import java.util.ArrayList; | 70 | import java.util.ArrayList; |
| 74 | import java.util.List; | 71 | import java.util.List; |
| 75 | -import java.util.Map; | ||
| 76 | import java.util.concurrent.ExecutorService; | 72 | import java.util.concurrent.ExecutorService; |
| 77 | import java.util.stream.Collectors; | 73 | import java.util.stream.Collectors; |
| 78 | 74 | ||
| ... | @@ -97,9 +93,6 @@ public class OpenstackNodeManager implements OpenstackNodeService { | ... | @@ -97,9 +93,6 @@ public class OpenstackNodeManager implements OpenstackNodeService { |
| 97 | private static final String OPENSTACK_NODESTORE = "openstacknode-nodestore"; | 93 | private static final String OPENSTACK_NODESTORE = "openstacknode-nodestore"; |
| 98 | private static final String OPENSTACK_NODEMANAGER_ID = "org.onosproject.openstacknode"; | 94 | private static final String OPENSTACK_NODEMANAGER_ID = "org.onosproject.openstacknode"; |
| 99 | 95 | ||
| 100 | - private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS | ||
| 101 | - = ImmutableMap.of("key", "flow", "remote_ip", "flow"); | ||
| 102 | - | ||
| 103 | private static final int DPID_BEGIN = 3; | 96 | private static final int DPID_BEGIN = 3; |
| 104 | private static final int OFPORT = 6653; | 97 | private static final int OFPORT = 6653; |
| 105 | 98 | ||
| ... | @@ -390,26 +383,22 @@ public class OpenstackNodeManager implements OpenstackNodeService { | ... | @@ -390,26 +383,22 @@ public class OpenstackNodeManager implements OpenstackNodeService { |
| 390 | return; | 383 | return; |
| 391 | } | 384 | } |
| 392 | 385 | ||
| 393 | - List<ControllerInfo> controllers = new ArrayList<>(); | 386 | + List<ControllerInfo> controllers = clusterService.getNodes().stream() |
| 394 | - Sets.newHashSet(clusterService.getNodes()).stream() | 387 | + .map(controller -> new ControllerInfo(controller.ip(), OFPORT, "tcp")) |
| 395 | - .forEach(controller -> { | 388 | + .collect(Collectors.toList()); |
| 396 | - ControllerInfo ctrlInfo = new ControllerInfo(controller.ip(), OFPORT, "tcp"); | ||
| 397 | - controllers.add(ctrlInfo); | ||
| 398 | - }); | ||
| 399 | String dpid = node.intBrId().toString().substring(DPID_BEGIN); | 389 | String dpid = node.intBrId().toString().substring(DPID_BEGIN); |
| 400 | 390 | ||
| 391 | + BridgeDescription bridgeDesc = DefaultBridgeDescription.builder() | ||
| 392 | + .name(DEFAULT_BRIDGE) | ||
| 393 | + .failMode(BridgeDescription.FailMode.SECURE) | ||
| 394 | + .datapathId(dpid) | ||
| 395 | + .disableInBand() | ||
| 396 | + .controllers(controllers) | ||
| 397 | + .build(); | ||
| 398 | + | ||
| 401 | try { | 399 | try { |
| 402 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); | 400 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); |
| 403 | BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); | 401 | BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); |
| 404 | - | ||
| 405 | - BridgeDescription bridgeDesc = DefaultBridgeDescription.builder() | ||
| 406 | - .name(DEFAULT_BRIDGE) | ||
| 407 | - .failMode(BridgeDescription.FailMode.SECURE) | ||
| 408 | - .datapathId(dpid) | ||
| 409 | - .disableInBand() | ||
| 410 | - .controllers(controllers) | ||
| 411 | - .build(); | ||
| 412 | - | ||
| 413 | bridgeConfig.addBridge(bridgeDesc); | 402 | bridgeConfig.addBridge(bridgeDesc); |
| 414 | } catch (ItemNotFoundException e) { | 403 | } catch (ItemNotFoundException e) { |
| 415 | log.warn("Failed to create integration bridge on {}", node.ovsdbId()); | 404 | log.warn("Failed to create integration bridge on {}", node.ovsdbId()); |
| ... | @@ -426,17 +415,17 @@ public class OpenstackNodeManager implements OpenstackNodeService { | ... | @@ -426,17 +415,17 @@ public class OpenstackNodeManager implements OpenstackNodeService { |
| 426 | return; | 415 | return; |
| 427 | } | 416 | } |
| 428 | 417 | ||
| 429 | - DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder(); | 418 | + TunnelDescription description = DefaultTunnelDescription.builder() |
| 430 | - for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) { | 419 | + .deviceId(DEFAULT_BRIDGE) |
| 431 | - optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key)); | 420 | + .ifaceName(DEFAULT_TUNNEL) |
| 432 | - } | 421 | + .type(VXLAN) |
| 433 | - TunnelDescription description = | 422 | + .remote(TunnelEndPoints.flowTunnelEndpoint()) |
| 434 | - new DefaultTunnelDescription(null, null, VXLAN, TunnelName.tunnelName(DEFAULT_TUNNEL), | 423 | + .key(TunnelKeys.flowTunnelKey()) |
| 435 | - optionBuilder.build()); | 424 | + .build(); |
| 436 | try { | 425 | try { |
| 437 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); | 426 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); |
| 438 | - TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); | 427 | + InterfaceConfig ifaceConfig = handler.behaviour(InterfaceConfig.class); |
| 439 | - tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE), description); | 428 | + ifaceConfig.addTunnelMode(DEFAULT_TUNNEL, description); |
| 440 | } catch (ItemNotFoundException e) { | 429 | } catch (ItemNotFoundException e) { |
| 441 | log.warn("Failed to create tunnel interface on {}", node.ovsdbId()); | 430 | log.warn("Failed to create tunnel interface on {}", node.ovsdbId()); |
| 442 | } | 431 | } | ... | ... |
| ... | @@ -487,7 +487,7 @@ public class VtnManager implements VtnService { | ... | @@ -487,7 +487,7 @@ public class VtnManager implements VtnService { |
| 487 | private void programTunnelConfig(DeviceId localDeviceId, IpAddress localIp, | 487 | private void programTunnelConfig(DeviceId localDeviceId, IpAddress localIp, |
| 488 | DriverHandler localHandler) { | 488 | DriverHandler localHandler) { |
| 489 | if (mastershipService.isLocalMaster(localDeviceId)) { | 489 | if (mastershipService.isLocalMaster(localDeviceId)) { |
| 490 | - VtnConfig.applyTunnelConfig(localHandler, localIp, IpAddress.valueOf(DEFAULT_IP)); | 490 | + VtnConfig.applyTunnelConfig(localHandler, localIp); |
| 491 | log.info("Add tunnel on {}", localIp); | 491 | log.info("Add tunnel on {}", localIp); |
| 492 | } | 492 | } |
| 493 | } | 493 | } | ... | ... |
| ... | @@ -27,11 +27,10 @@ import org.onosproject.net.behaviour.BridgeDescription; | ... | @@ -27,11 +27,10 @@ import org.onosproject.net.behaviour.BridgeDescription; |
| 27 | import org.onosproject.net.behaviour.BridgeName; | 27 | import org.onosproject.net.behaviour.BridgeName; |
| 28 | import org.onosproject.net.behaviour.DefaultBridgeDescription; | 28 | import org.onosproject.net.behaviour.DefaultBridgeDescription; |
| 29 | import org.onosproject.net.behaviour.DefaultTunnelDescription; | 29 | import org.onosproject.net.behaviour.DefaultTunnelDescription; |
| 30 | -import org.onosproject.net.behaviour.IpTunnelEndPoint; | 30 | +import org.onosproject.net.behaviour.InterfaceConfig; |
| 31 | -import org.onosproject.net.behaviour.TunnelConfig; | ||
| 32 | import org.onosproject.net.behaviour.TunnelDescription; | 31 | import org.onosproject.net.behaviour.TunnelDescription; |
| 33 | -import org.onosproject.net.behaviour.TunnelEndPoint; | 32 | +import org.onosproject.net.behaviour.TunnelEndPoints; |
| 34 | -import org.onosproject.net.behaviour.TunnelName; | 33 | +import org.onosproject.net.behaviour.TunnelKeys; |
| 35 | import org.onosproject.net.driver.DriverHandler; | 34 | import org.onosproject.net.driver.DriverHandler; |
| 36 | 35 | ||
| 37 | /** | 36 | /** |
| ... | @@ -95,43 +94,34 @@ public final class VtnConfig { | ... | @@ -95,43 +94,34 @@ public final class VtnConfig { |
| 95 | * | 94 | * |
| 96 | * @param handler DriverHandler | 95 | * @param handler DriverHandler |
| 97 | * @param srcIp the ipAddress of the local controller device | 96 | * @param srcIp the ipAddress of the local controller device |
| 98 | - * @param dstIp the ipAddress of the remote controller device | ||
| 99 | */ | 97 | */ |
| 100 | - public static void applyTunnelConfig(DriverHandler handler, IpAddress srcIp, | 98 | + public static void applyTunnelConfig(DriverHandler handler, IpAddress srcIp) { |
| 101 | - IpAddress dstIp) { | ||
| 102 | DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder(); | 99 | DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder(); |
| 103 | for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) { | 100 | for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) { |
| 104 | optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key)); | 101 | optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key)); |
| 105 | } | 102 | } |
| 106 | - TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); | 103 | + |
| 107 | - TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); | 104 | + InterfaceConfig interfaceConfig = handler.behaviour(InterfaceConfig.class); |
| 108 | - TunnelDescription tunnel = new DefaultTunnelDescription( | 105 | + TunnelDescription tunnel = DefaultTunnelDescription.builder() |
| 109 | - tunnelAsSrc, | 106 | + .deviceId(DEFAULT_BRIDGE_NAME) |
| 110 | - null, | 107 | + .ifaceName(DEFAULT_TUNNEL) |
| 111 | - TunnelDescription.Type.VXLAN, | 108 | + .type(TunnelDescription.Type.VXLAN) |
| 112 | - TunnelName.tunnelName(DEFAULT_TUNNEL), | 109 | + .local(TunnelEndPoints.ipTunnelEndpoint(srcIp)) |
| 113 | - optionBuilder.build()); | 110 | + .remote(TunnelEndPoints.flowTunnelEndpoint()) |
| 114 | - tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), tunnel); | 111 | + .key(TunnelKeys.flowTunnelKey()) |
| 112 | + .otherConfigs(optionBuilder.build()) | ||
| 113 | + .build(); | ||
| 114 | + interfaceConfig.addTunnelMode(DEFAULT_TUNNEL, tunnel); | ||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | /** | 117 | /** |
| 118 | * Creates or update tunnel in the controller device. | 118 | * Creates or update tunnel in the controller device. |
| 119 | * | 119 | * |
| 120 | * @param handler DriverHandler | 120 | * @param handler DriverHandler |
| 121 | - * @param srcIp the ipAddress of the local controller device | ||
| 122 | - * @param dstIp the ipAddress of the remote controller device | ||
| 123 | */ | 121 | */ |
| 124 | - public static void removeTunnelConfig(DriverHandler handler, IpAddress srcIp, | 122 | + public static void removeTunnelConfig(DriverHandler handler) { |
| 125 | - IpAddress dstIp) { | 123 | + InterfaceConfig interfaceConfig = handler.behaviour(InterfaceConfig.class); |
| 126 | - TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); | 124 | + interfaceConfig.removeTunnelMode(DEFAULT_TUNNEL); |
| 127 | - TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); | ||
| 128 | - TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); | ||
| 129 | - TunnelDescription tunnel = new DefaultTunnelDescription( | ||
| 130 | - tunnelAsSrc, | ||
| 131 | - tunnelAsDst, | ||
| 132 | - TunnelDescription.Type.VXLAN, | ||
| 133 | - null); | ||
| 134 | - tunnelConfig.removeTunnel(tunnel); | ||
| 135 | } | 125 | } |
| 136 | 126 | ||
| 137 | /** | 127 | /** | ... | ... |
| ... | @@ -15,25 +15,29 @@ | ... | @@ -15,25 +15,29 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.net.behaviour; | 16 | package org.onosproject.net.behaviour; |
| 17 | 17 | ||
| 18 | +import com.google.common.base.Strings; | ||
| 18 | import org.onosproject.net.AbstractDescription; | 19 | import org.onosproject.net.AbstractDescription; |
| 19 | import org.onosproject.net.SparseAnnotations; | 20 | import org.onosproject.net.SparseAnnotations; |
| 20 | 21 | ||
| 21 | -import com.google.common.annotations.Beta; | ||
| 22 | import com.google.common.base.MoreObjects; | 22 | import com.google.common.base.MoreObjects; |
| 23 | 23 | ||
| 24 | +import java.util.Optional; | ||
| 25 | + | ||
| 26 | +import static com.google.common.base.Preconditions.checkArgument; | ||
| 27 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 28 | + | ||
| 24 | /** | 29 | /** |
| 25 | - * Default implementation of immutable tunnel description entity. | 30 | + * Default implementation of immutable tunnel interface description entity. |
| 26 | */ | 31 | */ |
| 27 | -@Beta | 32 | +public final class DefaultTunnelDescription extends AbstractDescription |
| 28 | -public class DefaultTunnelDescription extends AbstractDescription | ||
| 29 | implements TunnelDescription { | 33 | implements TunnelDescription { |
| 30 | 34 | ||
| 31 | - private final TunnelEndPoint src; | 35 | + private final Optional<String> deviceId; |
| 32 | - private final TunnelEndPoint dst; | 36 | + private final String ifaceName; |
| 33 | private final Type type; | 37 | private final Type type; |
| 34 | - // which a tunnel match up | 38 | + private final Optional<TunnelEndPoint> local; |
| 35 | - // tunnel producer | 39 | + private final Optional<TunnelEndPoint> remote; |
| 36 | - private final TunnelName tunnelName; // name of a tunnel | 40 | + private final Optional<TunnelKey> key; |
| 37 | 41 | ||
| 38 | /** | 42 | /** |
| 39 | * Creates a tunnel description using the supplied information. | 43 | * Creates a tunnel description using the supplied information. |
| ... | @@ -43,26 +47,67 @@ public class DefaultTunnelDescription extends AbstractDescription | ... | @@ -43,26 +47,67 @@ public class DefaultTunnelDescription extends AbstractDescription |
| 43 | * @param type tunnel type | 47 | * @param type tunnel type |
| 44 | * @param tunnelName tunnel name | 48 | * @param tunnelName tunnel name |
| 45 | * @param annotations optional key/value annotations | 49 | * @param annotations optional key/value annotations |
| 50 | + * @deprecated version 1.7.0 - Hummingbird | ||
| 46 | */ | 51 | */ |
| 52 | + @Deprecated | ||
| 47 | public DefaultTunnelDescription(TunnelEndPoint src, | 53 | public DefaultTunnelDescription(TunnelEndPoint src, |
| 48 | TunnelEndPoint dst, Type type, | 54 | TunnelEndPoint dst, Type type, |
| 49 | TunnelName tunnelName, | 55 | TunnelName tunnelName, |
| 50 | SparseAnnotations... annotations) { | 56 | SparseAnnotations... annotations) { |
| 51 | super(annotations); | 57 | super(annotations); |
| 52 | - this.src = src; | 58 | + this.deviceId = Optional.empty(); |
| 53 | - this.dst = dst; | 59 | + this.local = Optional.ofNullable(src); |
| 60 | + this.remote = Optional.ofNullable(dst); | ||
| 61 | + this.type = type; | ||
| 62 | + this.ifaceName = tunnelName.value(); | ||
| 63 | + this.key = Optional.empty(); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * Creates a tunnel description using the supplied information. | ||
| 68 | + * | ||
| 69 | + * @param ifaceName tunnel interface ifaceName | ||
| 70 | + * @param local source tunnel endpoint | ||
| 71 | + * @param remote destination tunnel endpoint | ||
| 72 | + * @param type tunnel type | ||
| 73 | + * @param annotations optional key/value annotations | ||
| 74 | + */ | ||
| 75 | + private DefaultTunnelDescription(Optional<String> deviceId, | ||
| 76 | + String ifaceName, | ||
| 77 | + Type type, | ||
| 78 | + Optional<TunnelEndPoint> local, | ||
| 79 | + Optional<TunnelEndPoint> remote, | ||
| 80 | + Optional<TunnelKey> key, | ||
| 81 | + SparseAnnotations... annotations) { | ||
| 82 | + super(annotations); | ||
| 83 | + this.deviceId = deviceId; | ||
| 84 | + this.ifaceName = checkNotNull(ifaceName); | ||
| 54 | this.type = type; | 85 | this.type = type; |
| 55 | - this.tunnelName = tunnelName; | 86 | + this.local = local; |
| 87 | + this.remote = remote; | ||
| 88 | + this.key = key; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @Override | ||
| 92 | + public Optional<String> deviceId() { | ||
| 93 | + return deviceId; | ||
| 56 | } | 94 | } |
| 57 | 95 | ||
| 58 | @Override | 96 | @Override |
| 97 | + public String ifaceName() { | ||
| 98 | + return ifaceName; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Deprecated | ||
| 102 | + @Override | ||
| 59 | public TunnelEndPoint src() { | 103 | public TunnelEndPoint src() { |
| 60 | - return src; | 104 | + return local.isPresent() ? local.get() : null; |
| 61 | } | 105 | } |
| 62 | 106 | ||
| 107 | + @Deprecated | ||
| 63 | @Override | 108 | @Override |
| 64 | public TunnelEndPoint dst() { | 109 | public TunnelEndPoint dst() { |
| 65 | - return dst; | 110 | + return remote.isPresent() ? remote.get() : null; |
| 66 | } | 111 | } |
| 67 | 112 | ||
| 68 | @Override | 113 | @Override |
| ... | @@ -71,17 +116,112 @@ public class DefaultTunnelDescription extends AbstractDescription | ... | @@ -71,17 +116,112 @@ public class DefaultTunnelDescription extends AbstractDescription |
| 71 | } | 116 | } |
| 72 | 117 | ||
| 73 | @Override | 118 | @Override |
| 119 | + public Optional<TunnelEndPoint> local() { | ||
| 120 | + return local; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + @Override | ||
| 124 | + public Optional<TunnelEndPoint> remote() { | ||
| 125 | + return remote; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + @Override | ||
| 129 | + public Optional<TunnelKey> key() { | ||
| 130 | + return key; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + @Deprecated | ||
| 134 | + @Override | ||
| 74 | public TunnelName tunnelName() { | 135 | public TunnelName tunnelName() { |
| 75 | - return tunnelName; | 136 | + return TunnelName.tunnelName(ifaceName); |
| 76 | } | 137 | } |
| 77 | 138 | ||
| 78 | @Override | 139 | @Override |
| 79 | public String toString() { | 140 | public String toString() { |
| 80 | return MoreObjects.toStringHelper(this) | 141 | return MoreObjects.toStringHelper(this) |
| 81 | - .add("src", src()) | 142 | + .add("deviceId", deviceId) |
| 82 | - .add("dst", dst()) | 143 | + .add("ifaceName", ifaceName) |
| 83 | - .add("type", type()) | 144 | + .add("type", type) |
| 84 | - .add("tunnelName", tunnelName()) | 145 | + .add("local", local) |
| 146 | + .add("remote", remote) | ||
| 147 | + .add("key", key) | ||
| 85 | .toString(); | 148 | .toString(); |
| 86 | } | 149 | } |
| 150 | + | ||
| 151 | + /** | ||
| 152 | + * Creates and returns a new builder instance. | ||
| 153 | + * | ||
| 154 | + * @return default tunnel description builder | ||
| 155 | + */ | ||
| 156 | + public static Builder builder() { | ||
| 157 | + return new Builder(); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public static final class Builder implements TunnelDescription.Builder { | ||
| 161 | + private Optional<String> deviceId = Optional.empty(); | ||
| 162 | + private String ifaceName; | ||
| 163 | + private Type type; | ||
| 164 | + private Optional<TunnelEndPoint> local = Optional.empty(); | ||
| 165 | + private Optional<TunnelEndPoint> remote = Optional.empty(); | ||
| 166 | + private Optional<TunnelKey> key = Optional.empty(); | ||
| 167 | + private Optional<SparseAnnotations> otherConfigs = Optional.empty(); | ||
| 168 | + | ||
| 169 | + private Builder() { | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @Override | ||
| 173 | + public TunnelDescription build() { | ||
| 174 | + if (otherConfigs.isPresent()) { | ||
| 175 | + return new DefaultTunnelDescription(deviceId, ifaceName, type, | ||
| 176 | + local, remote, key, | ||
| 177 | + otherConfigs.get()); | ||
| 178 | + } else { | ||
| 179 | + return new DefaultTunnelDescription(deviceId, ifaceName, type, | ||
| 180 | + local, remote, key); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + @Override | ||
| 185 | + public Builder deviceId(String deviceId) { | ||
| 186 | + this.deviceId = Optional.ofNullable(deviceId); | ||
| 187 | + return this; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + @Override | ||
| 191 | + public Builder ifaceName(String ifaceName) { | ||
| 192 | + checkArgument(!Strings.isNullOrEmpty(ifaceName)); | ||
| 193 | + this.ifaceName = ifaceName; | ||
| 194 | + return this; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + @Override | ||
| 198 | + public Builder type(Type type) { | ||
| 199 | + this.type = type; | ||
| 200 | + return this; | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + @Override | ||
| 204 | + public Builder local(TunnelEndPoint endpoint) { | ||
| 205 | + local = Optional.ofNullable(endpoint); | ||
| 206 | + return this; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + @Override | ||
| 210 | + public Builder remote(TunnelEndPoint endpoint) { | ||
| 211 | + remote = Optional.ofNullable(endpoint); | ||
| 212 | + return this; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + @Override | ||
| 216 | + public Builder key(TunnelKey key) { | ||
| 217 | + this.key = Optional.ofNullable(key); | ||
| 218 | + return this; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + @Override | ||
| 222 | + public Builder otherConfigs(SparseAnnotations configs) { | ||
| 223 | + otherConfigs = Optional.ofNullable(configs); | ||
| 224 | + return this; | ||
| 225 | + } | ||
| 226 | + } | ||
| 87 | } | 227 | } | ... | ... |
| ... | @@ -125,6 +125,23 @@ public interface InterfaceConfig extends HandlerBehaviour { | ... | @@ -125,6 +125,23 @@ public interface InterfaceConfig extends HandlerBehaviour { |
| 125 | boolean removeRateLimit(String intf); | 125 | boolean removeRateLimit(String intf); |
| 126 | 126 | ||
| 127 | /** | 127 | /** |
| 128 | + * Adds a tunnel mode to supplied interface. | ||
| 129 | + * | ||
| 130 | + * @param intf the name of the interface | ||
| 131 | + * @param tunnelDesc tunnel interface description | ||
| 132 | + * @return true if the operation succeeds | ||
| 133 | + */ | ||
| 134 | + boolean addTunnelMode(String intf, TunnelDescription tunnelDesc); | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * Removes a tunnel interface. | ||
| 138 | + * | ||
| 139 | + * @param intf tunnel interface name | ||
| 140 | + * @return true if the operation succeeds | ||
| 141 | + */ | ||
| 142 | + boolean removeTunnelMode(String intf); | ||
| 143 | + | ||
| 144 | + /** | ||
| 128 | * Provides the interfaces configured on a device. | 145 | * Provides the interfaces configured on a device. |
| 129 | * | 146 | * |
| 130 | * @param deviceId the device ID | 147 | * @param deviceId the device ID |
| ... | @@ -148,5 +165,4 @@ public interface InterfaceConfig extends HandlerBehaviour { | ... | @@ -148,5 +165,4 @@ public interface InterfaceConfig extends HandlerBehaviour { |
| 148 | * getTrunkVlans(Interface), getAccessVlan(Interface) should be added to | 165 | * getTrunkVlans(Interface), getAccessVlan(Interface) should be added to |
| 149 | * complete the behavior. | 166 | * complete the behavior. |
| 150 | */ | 167 | */ |
| 151 | - | ||
| 152 | } | 168 | } | ... | ... |
| ... | @@ -16,27 +16,25 @@ | ... | @@ -16,27 +16,25 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.net.behaviour; | 17 | package org.onosproject.net.behaviour; |
| 18 | 18 | ||
| 19 | -import java.util.Objects; | ||
| 20 | - | ||
| 21 | import com.google.common.annotations.Beta; | 19 | import com.google.common.annotations.Beta; |
| 22 | -import org.onlab.packet.IpAddress; | ||
| 23 | - | ||
| 24 | import com.google.common.base.MoreObjects; | 20 | import com.google.common.base.MoreObjects; |
| 21 | +import org.onlab.packet.IpAddress; | ||
| 25 | 22 | ||
| 26 | /** | 23 | /** |
| 27 | * Represent for a tunnel point using ip address. | 24 | * Represent for a tunnel point using ip address. |
| 25 | + * | ||
| 26 | + * @deprecated version 1.7.0 - Hummingbird; use {@code TunnelEndPoint<IpAddress>} | ||
| 28 | */ | 27 | */ |
| 28 | +@Deprecated | ||
| 29 | @Beta | 29 | @Beta |
| 30 | -public final class IpTunnelEndPoint implements TunnelEndPoint { | 30 | +public final class IpTunnelEndPoint extends TunnelEndPoint<IpAddress> { |
| 31 | - | ||
| 32 | - private final IpAddress ip; | ||
| 33 | 31 | ||
| 34 | /** | 32 | /** |
| 35 | * Public construction is prohibited. | 33 | * Public construction is prohibited. |
| 36 | * @param ip ip address | 34 | * @param ip ip address |
| 37 | */ | 35 | */ |
| 38 | private IpTunnelEndPoint(IpAddress ip) { | 36 | private IpTunnelEndPoint(IpAddress ip) { |
| 39 | - this.ip = ip; | 37 | + super(ip); |
| 40 | } | 38 | } |
| 41 | 39 | ||
| 42 | /** | 40 | /** |
| ... | @@ -53,28 +51,11 @@ public final class IpTunnelEndPoint implements TunnelEndPoint { | ... | @@ -53,28 +51,11 @@ public final class IpTunnelEndPoint implements TunnelEndPoint { |
| 53 | * @return IP address | 51 | * @return IP address |
| 54 | */ | 52 | */ |
| 55 | public IpAddress ip() { | 53 | public IpAddress ip() { |
| 56 | - return ip; | 54 | + return value; |
| 57 | - } | ||
| 58 | - | ||
| 59 | - @Override | ||
| 60 | - public int hashCode() { | ||
| 61 | - return Objects.hash(ip); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - @Override | ||
| 65 | - public boolean equals(Object obj) { | ||
| 66 | - if (this == obj) { | ||
| 67 | - return true; | ||
| 68 | - } | ||
| 69 | - if (obj instanceof IpTunnelEndPoint) { | ||
| 70 | - final IpTunnelEndPoint other = (IpTunnelEndPoint) obj; | ||
| 71 | - return Objects.equals(this.ip, other.ip); | ||
| 72 | - } | ||
| 73 | - return false; | ||
| 74 | } | 55 | } |
| 75 | 56 | ||
| 76 | @Override | 57 | @Override |
| 77 | public String toString() { | 58 | public String toString() { |
| 78 | - return MoreObjects.toStringHelper(getClass()).add("ip", ip).toString(); | 59 | + return MoreObjects.toStringHelper(getClass()).add("ip", value).toString(); |
| 79 | } | 60 | } |
| 80 | } | 61 | } | ... | ... |
| ... | @@ -21,7 +21,10 @@ import org.onosproject.net.driver.HandlerBehaviour; | ... | @@ -21,7 +21,10 @@ import org.onosproject.net.driver.HandlerBehaviour; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * Behaviour for handling various drivers for tunnel configuration. | 23 | * Behaviour for handling various drivers for tunnel configuration. |
| 24 | + * | ||
| 25 | + * @deprecated version 1.7.0 - Hummingbird; use interface config tunnel mode | ||
| 24 | */ | 26 | */ |
| 27 | +@Deprecated | ||
| 25 | public interface TunnelConfig extends HandlerBehaviour { | 28 | public interface TunnelConfig extends HandlerBehaviour { |
| 26 | 29 | ||
| 27 | /** | 30 | /** | ... | ... |
| ... | @@ -19,9 +19,12 @@ import org.onosproject.net.Annotated; | ... | @@ -19,9 +19,12 @@ import org.onosproject.net.Annotated; |
| 19 | import org.onosproject.net.Description; | 19 | import org.onosproject.net.Description; |
| 20 | 20 | ||
| 21 | import com.google.common.annotations.Beta; | 21 | import com.google.common.annotations.Beta; |
| 22 | +import org.onosproject.net.SparseAnnotations; | ||
| 23 | + | ||
| 24 | +import java.util.Optional; | ||
| 22 | 25 | ||
| 23 | /** | 26 | /** |
| 24 | - * Describes a tunnel. | 27 | + * Describes a tunnel interface. |
| 25 | */ | 28 | */ |
| 26 | @Beta | 29 | @Beta |
| 27 | public interface TunnelDescription extends Description, Annotated { | 30 | public interface TunnelDescription extends Description, Annotated { |
| ... | @@ -57,18 +60,18 @@ public interface TunnelDescription extends Description, Annotated { | ... | @@ -57,18 +60,18 @@ public interface TunnelDescription extends Description, Annotated { |
| 57 | } | 60 | } |
| 58 | 61 | ||
| 59 | /** | 62 | /** |
| 60 | - * Returns the connection point source. | 63 | + * Returns the identifier of the device where the interface is. |
| 61 | * | 64 | * |
| 62 | - * @return tunnel source ConnectionPoint | 65 | + * @return device identifier |
| 63 | */ | 66 | */ |
| 64 | - TunnelEndPoint src(); | 67 | + Optional<String> deviceId(); |
| 65 | 68 | ||
| 66 | /** | 69 | /** |
| 67 | - * Returns the connection point destination. | 70 | + * Return the name of the tunnel interface. |
| 68 | * | 71 | * |
| 69 | - * @return tunnel destination | 72 | + * @return tunnel interface name |
| 70 | */ | 73 | */ |
| 71 | - TunnelEndPoint dst(); | 74 | + String ifaceName(); |
| 72 | 75 | ||
| 73 | /** | 76 | /** |
| 74 | * Returns the tunnel type. | 77 | * Returns the tunnel type. |
| ... | @@ -78,9 +81,120 @@ public interface TunnelDescription extends Description, Annotated { | ... | @@ -78,9 +81,120 @@ public interface TunnelDescription extends Description, Annotated { |
| 78 | Type type(); | 81 | Type type(); |
| 79 | 82 | ||
| 80 | /** | 83 | /** |
| 84 | + * Returns the local connection point. | ||
| 85 | + * | ||
| 86 | + * @return tunnel source ConnectionPoint | ||
| 87 | + */ | ||
| 88 | + Optional<TunnelEndPoint> local(); | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Returns the remote connection point. | ||
| 92 | + * | ||
| 93 | + * @return tunnel destination | ||
| 94 | + */ | ||
| 95 | + Optional<TunnelEndPoint> remote(); | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * Returns the tunnel key. | ||
| 99 | + * | ||
| 100 | + * @return tunnel key | ||
| 101 | + */ | ||
| 102 | + Optional<TunnelKey> key(); | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * Returns the connection point source. | ||
| 106 | + * | ||
| 107 | + * @deprecated version 1.7.0 - Hummingbird; use local instead | ||
| 108 | + * @return tunnel source ConnectionPoint | ||
| 109 | + */ | ||
| 110 | + @Deprecated | ||
| 111 | + TunnelEndPoint src(); | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * Returns the connection point destination. | ||
| 115 | + * | ||
| 116 | + * @deprecated version 1.7.0 - Hummingbird; use remote instead | ||
| 117 | + * @return tunnel destination | ||
| 118 | + */ | ||
| 119 | + @Deprecated | ||
| 120 | + TunnelEndPoint dst(); | ||
| 121 | + | ||
| 122 | + /** | ||
| 81 | * Return the name of a tunnel. | 123 | * Return the name of a tunnel. |
| 82 | * | 124 | * |
| 125 | + * @deprecated version 1.7.0 - Hummingbird; use ifaceName instead | ||
| 83 | * @return Tunnel Name | 126 | * @return Tunnel Name |
| 84 | */ | 127 | */ |
| 128 | + @Deprecated | ||
| 85 | TunnelName tunnelName(); | 129 | TunnelName tunnelName(); |
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * Builder of tunnel interface description entities. | ||
| 133 | + */ | ||
| 134 | + interface Builder { | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * Returns new tunnel interface description. | ||
| 138 | + * | ||
| 139 | + * @return tunnel description | ||
| 140 | + */ | ||
| 141 | + TunnelDescription build(); | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Returns tunnel interface description biulder with supplied device ID. | ||
| 145 | + * | ||
| 146 | + * @param deviceId device identifier | ||
| 147 | + * @return tunnel description builder | ||
| 148 | + */ | ||
| 149 | + Builder deviceId(String deviceId); | ||
| 150 | + | ||
| 151 | + /** | ||
| 152 | + * Returns tunnel interface description builder with a given interface name. | ||
| 153 | + * | ||
| 154 | + * @param name tunnel interface name | ||
| 155 | + * @return tunnel description builder | ||
| 156 | + */ | ||
| 157 | + Builder ifaceName(String name); | ||
| 158 | + | ||
| 159 | + /** | ||
| 160 | + * Returns tunnel interface description builder with a given tunnel type. | ||
| 161 | + * | ||
| 162 | + * @param type tunnel type | ||
| 163 | + * @return tunnel description builder | ||
| 164 | + */ | ||
| 165 | + Builder type(Type type); | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * Returns tunnel interface description builder with a given local | ||
| 169 | + * tunnel endpoint. | ||
| 170 | + * | ||
| 171 | + * @param endpoint tunnel endpoint | ||
| 172 | + * @return tunnel description builder | ||
| 173 | + */ | ||
| 174 | + Builder local(TunnelEndPoint endpoint); | ||
| 175 | + | ||
| 176 | + /** | ||
| 177 | + * Returns tunnel interface description builder with a given remote | ||
| 178 | + * tunnel endpoint. | ||
| 179 | + * | ||
| 180 | + * @param endpoint tunnel endpoint | ||
| 181 | + * @return tunnel description builder | ||
| 182 | + */ | ||
| 183 | + Builder remote(TunnelEndPoint endpoint); | ||
| 184 | + | ||
| 185 | + /** | ||
| 186 | + * Returns tunnel interface description builder with a tunnel key. | ||
| 187 | + * | ||
| 188 | + * @return tunnel description builder | ||
| 189 | + */ | ||
| 190 | + Builder key(TunnelKey tunnelKey); | ||
| 191 | + | ||
| 192 | + /** | ||
| 193 | + * Returns tunnel interface descriptions builder with other configurations. | ||
| 194 | + * | ||
| 195 | + * @param configs configurations | ||
| 196 | + * @return tunnel description builder | ||
| 197 | + */ | ||
| 198 | + Builder otherConfigs(SparseAnnotations configs); | ||
| 199 | + } | ||
| 86 | } | 200 | } | ... | ... |
| ... | @@ -16,13 +16,58 @@ | ... | @@ -16,13 +16,58 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.net.behaviour; | 17 | package org.onosproject.net.behaviour; |
| 18 | 18 | ||
| 19 | -import com.google.common.annotations.Beta; | 19 | +import java.util.Objects; |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | * Represents for source end point or destination end point of a tunnel. Maybe a tunnel | 22 | * Represents for source end point or destination end point of a tunnel. Maybe a tunnel |
| 23 | * based on ConnectPoint, IpAddress, MacAddress and so on is built. | 23 | * based on ConnectPoint, IpAddress, MacAddress and so on is built. |
| 24 | */ | 24 | */ |
| 25 | -@Beta | 25 | +public class TunnelEndPoint<T> { |
| 26 | -public interface TunnelEndPoint { | ||
| 27 | 26 | ||
| 27 | + protected final T value; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Default constructor. | ||
| 31 | + * | ||
| 32 | + * @param value value of the tunnel endpoint | ||
| 33 | + */ | ||
| 34 | + public TunnelEndPoint(T value) { | ||
| 35 | + this.value = value; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Returns the value. | ||
| 40 | + * | ||
| 41 | + * @return tunnel endpoint value | ||
| 42 | + */ | ||
| 43 | + public T value() { | ||
| 44 | + return value; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Returns the value as a string. | ||
| 49 | + * | ||
| 50 | + * @return string value | ||
| 51 | + */ | ||
| 52 | + public String strValue() { | ||
| 53 | + return value.toString(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public boolean equals(Object obj) { | ||
| 58 | + if (this == obj) { | ||
| 59 | + return true; | ||
| 60 | + } | ||
| 61 | + if (obj instanceof TunnelEndPoint) { | ||
| 62 | + final TunnelEndPoint that = (TunnelEndPoint) obj; | ||
| 63 | + return this.getClass() == that.getClass() && | ||
| 64 | + Objects.equals(this.value, that.value); | ||
| 65 | + } | ||
| 66 | + return false; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public int hashCode() { | ||
| 71 | + return value.hashCode(); | ||
| 72 | + } | ||
| 28 | } | 73 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.behaviour; | ||
| 17 | + | ||
| 18 | +import org.onlab.packet.IpAddress; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Static utility methods pertaining to {@link TunnelEndPoint} instances. | ||
| 22 | + */ | ||
| 23 | +public final class TunnelEndPoints { | ||
| 24 | + | ||
| 25 | + private TunnelEndPoints() { | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + private static TunnelEndPoint<String> flowEndpoint = new TunnelEndPoint<>("flow"); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Returns a tunnel endpoint with supplied IP address. | ||
| 32 | + * | ||
| 33 | + * @param ipAddress ip address | ||
| 34 | + * @return tunnel endpoint instance | ||
| 35 | + */ | ||
| 36 | + public static TunnelEndPoint<IpAddress> ipTunnelEndpoint(IpAddress ipAddress) { | ||
| 37 | + return new TunnelEndPoint<>(ipAddress); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Returns a tunnel endpoint with FLOW keyword. | ||
| 42 | + * | ||
| 43 | + * @return tunnel endpoint instance | ||
| 44 | + */ | ||
| 45 | + public static TunnelEndPoint<String> flowTunnelEndpoint() { | ||
| 46 | + return flowEndpoint; | ||
| 47 | + } | ||
| 48 | +} |
| 1 | /* | 1 | /* |
| 2 | - * Copyright 2015-present Open Networking Laboratory | 2 | + * Copyright 2016-present Open Networking Laboratory |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| ... | @@ -13,42 +13,46 @@ | ... | @@ -13,42 +13,46 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.ovsdb.controller; | ||
| 17 | 16 | ||
| 18 | -import static com.google.common.base.MoreObjects.toStringHelper; | 17 | +package org.onosproject.net.behaviour; |
| 19 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 20 | 18 | ||
| 21 | import java.util.Objects; | 19 | import java.util.Objects; |
| 22 | 20 | ||
| 23 | /** | 21 | /** |
| 24 | - * The class representing a tunnel name. | 22 | + * Represent for a tunnel key. The tunnel accepts packets with the tunnel key. |
| 25 | - * This class is immutable. | 23 | + * A positive 24-bit (for Geneve, VXLAN, and LISP), 32-bit (for GRE) or 64-bit (for |
| 24 | + * GRE64) number value is used for example. Open vSwitch allows "flow" as the key | ||
| 25 | + * to set this value with matching in the flow table. | ||
| 26 | */ | 26 | */ |
| 27 | -public final class OvsdbTunnelName { | 27 | +public final class TunnelKey<T> { |
| 28 | - private final String value; | 28 | + |
| 29 | + private final T value; | ||
| 29 | 30 | ||
| 30 | /** | 31 | /** |
| 31 | - * Constructor from a String. | 32 | + * Default constructor. |
| 32 | * | 33 | * |
| 33 | - * @param value the tunnel name to use | 34 | + * @param value value of the tunnel key |
| 34 | */ | 35 | */ |
| 35 | - public OvsdbTunnelName(String value) { | 36 | + public TunnelKey(T value) { |
| 36 | - checkNotNull(value, "value is not null"); | ||
| 37 | this.value = value; | 37 | this.value = value; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | - * Gets the value of tunnel name. | 41 | + * Returns the value. |
| 42 | * | 42 | * |
| 43 | - * @return the value of tunnel name | 43 | + * @return tunnel key value |
| 44 | */ | 44 | */ |
| 45 | - public String value() { | 45 | + public T value() { |
| 46 | return value; | 46 | return value; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | - @Override | 49 | + /** |
| 50 | - public int hashCode() { | 50 | + * Returns the value as a string. |
| 51 | - return value.hashCode(); | 51 | + * |
| 52 | + * @return string value | ||
| 53 | + */ | ||
| 54 | + public String strValue() { | ||
| 55 | + return value.toString(); | ||
| 52 | } | 56 | } |
| 53 | 57 | ||
| 54 | @Override | 58 | @Override |
| ... | @@ -56,15 +60,16 @@ public final class OvsdbTunnelName { | ... | @@ -56,15 +60,16 @@ public final class OvsdbTunnelName { |
| 56 | if (this == obj) { | 60 | if (this == obj) { |
| 57 | return true; | 61 | return true; |
| 58 | } | 62 | } |
| 59 | - if (obj instanceof OvsdbTunnelName) { | 63 | + if (obj instanceof TunnelKey) { |
| 60 | - final OvsdbTunnelName otherOvsdbTunnelName = (OvsdbTunnelName) obj; | 64 | + final TunnelKey that = (TunnelKey) obj; |
| 61 | - return Objects.equals(this.value, otherOvsdbTunnelName.value); | 65 | + return this.getClass() == that.getClass() && |
| 66 | + Objects.equals(this.value, that.value); | ||
| 62 | } | 67 | } |
| 63 | return false; | 68 | return false; |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | @Override | 71 | @Override |
| 67 | - public String toString() { | 72 | + public int hashCode() { |
| 68 | - return toStringHelper(this).add("value", value).toString(); | 73 | + return value.hashCode(); |
| 69 | } | 74 | } |
| 70 | } | 75 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.net.behaviour; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Static utility methods pertaining to {@link TunnelKey} instances. | ||
| 20 | + */ | ||
| 21 | +public final class TunnelKeys { | ||
| 22 | + | ||
| 23 | + private TunnelKeys() { | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + private static TunnelKey<String> flowKey = new TunnelKey<>("flow"); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Returns a tunnel key with FLOW keyword. | ||
| 30 | + * | ||
| 31 | + * @return tunnel key instance | ||
| 32 | + */ | ||
| 33 | + public static TunnelKey<String> flowTunnelKey() { | ||
| 34 | + return flowKey; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + // TODO add more for various types of tunnel | ||
| 38 | +} |
| ... | @@ -24,7 +24,10 @@ import java.util.Objects; | ... | @@ -24,7 +24,10 @@ import java.util.Objects; |
| 24 | * Represents for a unique tunnel name. TunnelId is generated by ONOS while | 24 | * Represents for a unique tunnel name. TunnelId is generated by ONOS while |
| 25 | * TunnelName is given by producer. The consumer can borrow tunnels with | 25 | * TunnelName is given by producer. The consumer can borrow tunnels with |
| 26 | * TunnelId or TunnelName. | 26 | * TunnelId or TunnelName. |
| 27 | + * | ||
| 28 | + * @deprecated version 1.7.0 - Hummingbird | ||
| 27 | */ | 29 | */ |
| 30 | +@Deprecated | ||
| 28 | @Beta | 31 | @Beta |
| 29 | public final class TunnelName { | 32 | public final class TunnelName { |
| 30 | private final String str; | 33 | private final String str; | ... | ... |
| ... | @@ -22,6 +22,7 @@ import org.onlab.packet.VlanId; | ... | @@ -22,6 +22,7 @@ import org.onlab.packet.VlanId; |
| 22 | import org.onosproject.drivers.utilities.XmlConfigParser; | 22 | import org.onosproject.drivers.utilities.XmlConfigParser; |
| 23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.behaviour.InterfaceConfig; | 24 | import org.onosproject.net.behaviour.InterfaceConfig; |
| 25 | +import org.onosproject.net.behaviour.TunnelDescription; | ||
| 25 | import org.onosproject.net.device.DeviceInterfaceDescription; | 26 | import org.onosproject.net.device.DeviceInterfaceDescription; |
| 26 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 27 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 27 | import org.onosproject.netconf.NetconfController; | 28 | import org.onosproject.netconf.NetconfController; |
| ... | @@ -480,5 +481,14 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour | ... | @@ -480,5 +481,14 @@ public class InterfaceConfigCiscoIosImpl extends AbstractHandlerBehaviour |
| 480 | return rpc.toString(); | 481 | return rpc.toString(); |
| 481 | } | 482 | } |
| 482 | 483 | ||
| 484 | + @Override | ||
| 485 | + public boolean addTunnelMode(String ifaceName, TunnelDescription tunnelDesc) { | ||
| 486 | + throw new UnsupportedOperationException("Add tunnel mode is not supported"); | ||
| 487 | + } | ||
| 488 | + | ||
| 489 | + @Override | ||
| 490 | + public boolean removeTunnelMode(String ifaceName) { | ||
| 491 | + throw new UnsupportedOperationException("Remove tunnel mode is not supported"); | ||
| 492 | + } | ||
| 483 | } | 493 | } |
| 484 | 494 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.drivers.ovsdb; | ||
| 18 | + | ||
| 19 | +import org.onlab.packet.IpAddress; | ||
| 20 | +import org.onlab.packet.VlanId; | ||
| 21 | +import org.onosproject.net.DeviceId; | ||
| 22 | +import org.onosproject.net.behaviour.InterfaceConfig; | ||
| 23 | +import org.onosproject.net.behaviour.TunnelDescription; | ||
| 24 | +import org.onosproject.net.device.DeviceInterfaceDescription; | ||
| 25 | +import org.onosproject.net.driver.AbstractHandlerBehaviour; | ||
| 26 | +import org.onosproject.net.driver.DriverHandler; | ||
| 27 | +import org.onosproject.ovsdb.controller.OvsdbClientService; | ||
| 28 | +import org.onosproject.ovsdb.controller.OvsdbController; | ||
| 29 | +import org.onosproject.ovsdb.controller.OvsdbInterface; | ||
| 30 | +import org.onosproject.ovsdb.controller.OvsdbNodeId; | ||
| 31 | +import org.slf4j.Logger; | ||
| 32 | + | ||
| 33 | +import java.util.List; | ||
| 34 | + | ||
| 35 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 36 | + | ||
| 37 | +/** | ||
| 38 | + * OVSDB-based implementation of interface config behaviour. | ||
| 39 | + */ | ||
| 40 | +public class OvsdbInterfaceConfig extends AbstractHandlerBehaviour implements InterfaceConfig { | ||
| 41 | + | ||
| 42 | + private final Logger log = getLogger(getClass()); | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public boolean addTunnelMode(String ifaceName, TunnelDescription tunnelDesc) { | ||
| 46 | + OvsdbInterface ovsdbIface = OvsdbInterface.builder(tunnelDesc).build(); | ||
| 47 | + OvsdbClientService ovsdbClient = getOvsdbClient(handler()); | ||
| 48 | + | ||
| 49 | + if (!tunnelDesc.deviceId().isPresent()) { | ||
| 50 | + log.warn("Device ID is required {}", tunnelDesc); | ||
| 51 | + return false; | ||
| 52 | + } | ||
| 53 | + return ovsdbClient.createInterface(tunnelDesc.deviceId().get(), ovsdbIface); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public boolean removeTunnelMode(String ifaceName) { | ||
| 58 | + OvsdbClientService ovsdbClient = getOvsdbClient(handler()); | ||
| 59 | + return ovsdbClient.dropInterface(ifaceName); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public boolean addAccessMode(String ifaceName, VlanId vlanId) { | ||
| 64 | + // TODO implement | ||
| 65 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public boolean removeAccessMode(String ifaceName) { | ||
| 70 | + // TODO implement | ||
| 71 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public boolean addTrunkMode(String ifaceName, List<VlanId> vlanIds) { | ||
| 76 | + // TODO implement | ||
| 77 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public boolean removeTrunkMode(String ifaceName) { | ||
| 82 | + // TODO implement | ||
| 83 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @Override | ||
| 87 | + public boolean addRateLimit(String ifaceName, short limit) { | ||
| 88 | + // TODO implement | ||
| 89 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public boolean removeRateLimit(String ifaceName) { | ||
| 94 | + // TODO implement | ||
| 95 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @Override | ||
| 99 | + public List<DeviceInterfaceDescription> getInterfaces() { | ||
| 100 | + // TODO implement | ||
| 101 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + // deprecated interfaces | ||
| 105 | + @Override | ||
| 106 | + public boolean addAccessInterface(DeviceId deviceId, String ifaceName, VlanId vlanId) { | ||
| 107 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + public boolean removeAccessInterface(DeviceId deviceId, String ifaceName) { | ||
| 112 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 116 | + public boolean addTrunkInterface(DeviceId deviceId, String ifaceName, List<VlanId> vlanIds) { | ||
| 117 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @Override | ||
| 121 | + public List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId) { | ||
| 122 | + return null; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + @Override | ||
| 126 | + public boolean removeTrunkInterface(DeviceId deviceId, String ifaceName) { | ||
| 127 | + throw new UnsupportedOperationException("Not implemented yet"); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) | ||
| 131 | + // is used in the core. So DeviceId need be changed to OvsdbNodeId. | ||
| 132 | + private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { | ||
| 133 | + String[] splits = deviceId.toString().split(":"); | ||
| 134 | + if (splits.length < 1) { | ||
| 135 | + return null; | ||
| 136 | + } | ||
| 137 | + IpAddress ipAddress = IpAddress.valueOf(splits[1]); | ||
| 138 | + return new OvsdbNodeId(ipAddress, 0); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + private OvsdbClientService getOvsdbClient(DriverHandler handler) { | ||
| 142 | + OvsdbController ovsController = handler.get(OvsdbController.class); | ||
| 143 | + OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId()); | ||
| 144 | + | ||
| 145 | + return ovsController.getOvsdbClient(nodeId); | ||
| 146 | + } | ||
| 147 | +} |
| ... | @@ -17,68 +17,43 @@ | ... | @@ -17,68 +17,43 @@ |
| 17 | package org.onosproject.drivers.ovsdb; | 17 | package org.onosproject.drivers.ovsdb; |
| 18 | 18 | ||
| 19 | import org.onlab.packet.IpAddress; | 19 | import org.onlab.packet.IpAddress; |
| 20 | -import org.onosproject.net.DefaultAnnotations; | ||
| 21 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.behaviour.BridgeName; | 21 | import org.onosproject.net.behaviour.BridgeName; |
| 23 | -import org.onosproject.net.behaviour.DefaultTunnelDescription; | ||
| 24 | -import org.onosproject.net.behaviour.IpTunnelEndPoint; | ||
| 25 | import org.onosproject.net.behaviour.TunnelConfig; | 22 | import org.onosproject.net.behaviour.TunnelConfig; |
| 26 | import org.onosproject.net.behaviour.TunnelDescription; | 23 | import org.onosproject.net.behaviour.TunnelDescription; |
| 27 | -import org.onosproject.net.behaviour.TunnelName; | ||
| 28 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 24 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 29 | import org.onosproject.net.driver.DriverHandler; | 25 | import org.onosproject.net.driver.DriverHandler; |
| 30 | import org.onosproject.ovsdb.controller.OvsdbClientService; | 26 | import org.onosproject.ovsdb.controller.OvsdbClientService; |
| 31 | import org.onosproject.ovsdb.controller.OvsdbController; | 27 | import org.onosproject.ovsdb.controller.OvsdbController; |
| 28 | +import org.onosproject.ovsdb.controller.OvsdbInterface; | ||
| 32 | import org.onosproject.ovsdb.controller.OvsdbNodeId; | 29 | import org.onosproject.ovsdb.controller.OvsdbNodeId; |
| 33 | -import org.onosproject.ovsdb.controller.OvsdbTunnel; | ||
| 34 | 30 | ||
| 35 | import java.util.Collection; | 31 | import java.util.Collection; |
| 36 | -import java.util.Map; | 32 | +import java.util.Collections; |
| 37 | -import java.util.Set; | ||
| 38 | -import java.util.stream.Collectors; | ||
| 39 | 33 | ||
| 40 | /** | 34 | /** |
| 41 | * OVSDB-based implementation of tunnel config behaviour. | 35 | * OVSDB-based implementation of tunnel config behaviour. |
| 36 | + * | ||
| 37 | + * @deprecated version 1.7.0 - Hummingbird; use interface config instead | ||
| 42 | */ | 38 | */ |
| 39 | +@Deprecated | ||
| 43 | public class OvsdbTunnelConfig extends AbstractHandlerBehaviour | 40 | public class OvsdbTunnelConfig extends AbstractHandlerBehaviour |
| 44 | implements TunnelConfig { | 41 | implements TunnelConfig { |
| 45 | 42 | ||
| 46 | - private static final String DEFAULT_ADDRESS = "0.0.0.0"; | ||
| 47 | - private static final String OPTION_LOCAL_IP = "local_ip"; | ||
| 48 | - private static final String OPTION_REMOTE_IP = "remote_ip"; | ||
| 49 | - | ||
| 50 | @Override | 43 | @Override |
| 51 | public boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel) { | 44 | public boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel) { |
| 52 | - Map<String, String> options = ((DefaultAnnotations) tunnel.annotations()).asMap(); | ||
| 53 | - if (tunnel.src() != null) { | ||
| 54 | - options.put(OPTION_LOCAL_IP, ((IpTunnelEndPoint) tunnel.src()).ip().toString()); | ||
| 55 | - } | ||
| 56 | - if (tunnel.dst() != null) { | ||
| 57 | - options.put(OPTION_REMOTE_IP, ((IpTunnelEndPoint) tunnel.dst()).ip().toString()); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | DriverHandler handler = handler(); | 45 | DriverHandler handler = handler(); |
| 61 | - OvsdbClientService ovsdbClient = getOvsdbNode(handler); | 46 | + OvsdbClientService ovsdbNode = getOvsdbNode(handler); |
| 62 | - return ovsdbClient.createTunnel(bridgeName.name(), tunnel.tunnelName().toString(), | 47 | + |
| 63 | - tunnel.type().toString().toLowerCase(), options); | 48 | + OvsdbInterface ovsdbIface = OvsdbInterface.builder(tunnel).build(); |
| 49 | + return ovsdbNode.createInterface(bridgeName.name(), ovsdbIface); | ||
| 64 | } | 50 | } |
| 65 | 51 | ||
| 66 | @Override | 52 | @Override |
| 67 | public void removeTunnel(TunnelDescription tunnel) { | 53 | public void removeTunnel(TunnelDescription tunnel) { |
| 68 | DriverHandler handler = handler(); | 54 | DriverHandler handler = handler(); |
| 69 | OvsdbClientService ovsdbNode = getOvsdbNode(handler); | 55 | OvsdbClientService ovsdbNode = getOvsdbNode(handler); |
| 70 | - IpTunnelEndPoint ipSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress | 56 | + ovsdbNode.dropInterface(tunnel.ifaceName()); |
| 71 | - .valueOf(DEFAULT_ADDRESS)); | ||
| 72 | - IpTunnelEndPoint ipDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress | ||
| 73 | - .valueOf(DEFAULT_ADDRESS)); | ||
| 74 | - if (tunnel.src() instanceof IpTunnelEndPoint) { | ||
| 75 | - ipSrc = (IpTunnelEndPoint) tunnel.src(); | ||
| 76 | - } | ||
| 77 | - if (tunnel.dst() instanceof IpTunnelEndPoint) { | ||
| 78 | - ipDst = (IpTunnelEndPoint) tunnel.dst(); | ||
| 79 | - } | ||
| 80 | - //Even if source point ip or destination point ip equals 0:0:0:0, it is still work-in-progress. | ||
| 81 | - ovsdbNode.dropTunnel(ipSrc.ip(), ipDst.ip()); | ||
| 82 | } | 57 | } |
| 83 | 58 | ||
| 84 | @Override | 59 | @Override |
| ... | @@ -89,20 +64,7 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour | ... | @@ -89,20 +64,7 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour |
| 89 | 64 | ||
| 90 | @Override | 65 | @Override |
| 91 | public Collection<TunnelDescription> getTunnels() { | 66 | public Collection<TunnelDescription> getTunnels() { |
| 92 | - DriverHandler handler = handler(); | 67 | + return Collections.emptyList(); |
| 93 | - OvsdbClientService ovsdbNode = getOvsdbNode(handler); | ||
| 94 | - Set<OvsdbTunnel> tunnels = ovsdbNode.getTunnels(); | ||
| 95 | - | ||
| 96 | - return tunnels.stream() | ||
| 97 | - .map(x -> | ||
| 98 | - new DefaultTunnelDescription( | ||
| 99 | - IpTunnelEndPoint.ipTunnelPoint(x.localIp()), | ||
| 100 | - IpTunnelEndPoint.ipTunnelPoint(x.remoteIp()), | ||
| 101 | - TunnelDescription.Type.VXLAN, | ||
| 102 | - TunnelName.tunnelName(x.tunnelName().toString()) | ||
| 103 | - ) | ||
| 104 | - ) | ||
| 105 | - .collect(Collectors.toSet()); | ||
| 106 | } | 68 | } |
| 107 | 69 | ||
| 108 | // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) | 70 | // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) | ... | ... |
| ... | @@ -21,6 +21,8 @@ | ... | @@ -21,6 +21,8 @@ |
| 21 | impl="org.onosproject.drivers.ovsdb.OvsdbTunnelConfig"/> | 21 | impl="org.onosproject.drivers.ovsdb.OvsdbTunnelConfig"/> |
| 22 | <behaviour api="org.onosproject.net.behaviour.BridgeConfig" | 22 | <behaviour api="org.onosproject.net.behaviour.BridgeConfig" |
| 23 | impl="org.onosproject.drivers.ovsdb.OvsdbBridgeConfig"/> | 23 | impl="org.onosproject.drivers.ovsdb.OvsdbBridgeConfig"/> |
| 24 | + <behaviour api="org.onosproject.net.behaviour.InterfaceConfig" | ||
| 25 | + impl="org.onosproject.drivers.ovsdb.OvsdbInterfaceConfig"/> | ||
| 24 | </driver> | 26 | </driver> |
| 25 | <driver name="ovs" extends="default" | 27 | <driver name="ovs" extends="default" |
| 26 | manufacturer="Nicira, Inc\." hwVersion="Open vSwitch" swVersion="2\..*"> | 28 | manufacturer="Nicira, Inc\." hwVersion="Open vSwitch" swVersion="2\..*"> | ... | ... |
| ... | @@ -16,16 +16,12 @@ | ... | @@ -16,16 +16,12 @@ |
| 16 | package org.onosproject.ovsdb.controller; | 16 | package org.onosproject.ovsdb.controller; |
| 17 | 17 | ||
| 18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
| 19 | - | ||
| 20 | import org.onlab.packet.IpAddress; | 19 | import org.onlab.packet.IpAddress; |
| 21 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.behaviour.ControllerInfo; | 21 | import org.onosproject.net.behaviour.ControllerInfo; |
| 23 | import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc; | 22 | import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc; |
| 24 | -import org.onosproject.ovsdb.rfc.message.OperationResult; | ||
| 25 | import org.onosproject.ovsdb.rfc.message.TableUpdates; | 23 | import org.onosproject.ovsdb.rfc.message.TableUpdates; |
| 26 | import org.onosproject.ovsdb.rfc.notation.Row; | 24 | import org.onosproject.ovsdb.rfc.notation.Row; |
| 27 | -import org.onosproject.ovsdb.rfc.notation.Uuid; | ||
| 28 | -import org.onosproject.ovsdb.rfc.operations.Operation; | ||
| 29 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; | 25 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
| 30 | 26 | ||
| 31 | import java.util.List; | 27 | import java.util.List; |
| ... | @@ -46,28 +42,43 @@ public interface OvsdbClientService extends OvsdbRpc { | ... | @@ -46,28 +42,43 @@ public interface OvsdbClientService extends OvsdbRpc { |
| 46 | /** | 42 | /** |
| 47 | * Creates a tunnel port with given options. | 43 | * Creates a tunnel port with given options. |
| 48 | * | 44 | * |
| 45 | + * @deprecated version 1.7.0 - Hummingbird | ||
| 49 | * @param bridgeName bridge name | 46 | * @param bridgeName bridge name |
| 50 | * @param portName port name | 47 | * @param portName port name |
| 51 | * @param tunnelType tunnel type | 48 | * @param tunnelType tunnel type |
| 52 | * @param options tunnel options | 49 | * @param options tunnel options |
| 53 | * @return true if tunnel creation is successful, false otherwise | 50 | * @return true if tunnel creation is successful, false otherwise |
| 54 | */ | 51 | */ |
| 55 | - boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options); | 52 | + @Deprecated |
| 53 | + boolean createTunnel(String bridgeName, String portName, String tunnelType, | ||
| 54 | + Map<String, String> options); | ||
| 56 | 55 | ||
| 57 | /** | 56 | /** |
| 58 | * Drops the configuration for tunnel. | 57 | * Drops the configuration for tunnel. |
| 59 | * | 58 | * |
| 59 | + * @deprecated version 1.7.0 - Hummingbird | ||
| 60 | * @param srcIp source IP address | 60 | * @param srcIp source IP address |
| 61 | * @param dstIp destination IP address | 61 | * @param dstIp destination IP address |
| 62 | */ | 62 | */ |
| 63 | + @Deprecated | ||
| 63 | void dropTunnel(IpAddress srcIp, IpAddress dstIp); | 64 | void dropTunnel(IpAddress srcIp, IpAddress dstIp); |
| 64 | 65 | ||
| 65 | /** | 66 | /** |
| 66 | - * Gets tunnels of node. | 67 | + * Creates an interface with a given OVSDB interface description. |
| 68 | + * | ||
| 69 | + * @param bridgeName bridge name | ||
| 70 | + * @param ovsdbIface ovsdb interface description | ||
| 71 | + * @return true if interface creation is successful, false otherwise | ||
| 72 | + */ | ||
| 73 | + boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface); | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * Removes an interface with the supplied interface name. | ||
| 67 | * | 77 | * |
| 68 | - * @return set of tunnels; empty if no tunnel is find | 78 | + * @param ifaceName interface name |
| 79 | + * @return true if interface creation is successful, false otherwise | ||
| 69 | */ | 80 | */ |
| 70 | - Set<OvsdbTunnel> getTunnels(); | 81 | + boolean dropInterface(String ifaceName); |
| 71 | 82 | ||
| 72 | /** | 83 | /** |
| 73 | * Creates a bridge. | 84 | * Creates a bridge. |
| ... | @@ -142,17 +153,6 @@ public interface OvsdbClientService extends OvsdbRpc { | ... | @@ -142,17 +153,6 @@ public interface OvsdbClientService extends OvsdbRpc { |
| 142 | ControllerInfo localController(); | 153 | ControllerInfo localController(); |
| 143 | 154 | ||
| 144 | /** | 155 | /** |
| 145 | - * Sets the Controllers for the specified bridge. | ||
| 146 | - * <p> | ||
| 147 | - * This method will replace the existing controller list with the new controller | ||
| 148 | - * list. | ||
| 149 | - * | ||
| 150 | - * @param bridgeUuid bridge uuid | ||
| 151 | - * @param controllers list of controllers | ||
| 152 | - */ | ||
| 153 | - void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers); | ||
| 154 | - | ||
| 155 | - /** | ||
| 156 | * Sets the Controllers for the specified device. | 156 | * Sets the Controllers for the specified device. |
| 157 | * <p> | 157 | * <p> |
| 158 | * This method will replace the existing controller list with the new controller | 158 | * This method will replace the existing controller list with the new controller |
| ... | @@ -211,32 +211,6 @@ public interface OvsdbClientService extends OvsdbRpc { | ... | @@ -211,32 +211,6 @@ public interface OvsdbClientService extends OvsdbRpc { |
| 211 | String getPortUuid(String portName, String bridgeUuid); | 211 | String getPortUuid(String portName, String bridgeUuid); |
| 212 | 212 | ||
| 213 | /** | 213 | /** |
| 214 | - * Gets the Interface uuid. | ||
| 215 | - * | ||
| 216 | - * @param portUuid port uuid | ||
| 217 | - * @param portName port name | ||
| 218 | - * @return interface uuid, empty if no uuid is find | ||
| 219 | - */ | ||
| 220 | - String getInterfaceUuid(String portUuid, String portName); | ||
| 221 | - | ||
| 222 | - /** | ||
| 223 | - * Gets the Controller uuid. | ||
| 224 | - * | ||
| 225 | - * @param controllerName controller name | ||
| 226 | - * @param controllerTarget controller target | ||
| 227 | - * @return controller uuid, empty if no uuid is find | ||
| 228 | - */ | ||
| 229 | - String getControllerUuid(String controllerName, String controllerTarget); | ||
| 230 | - | ||
| 231 | - /** | ||
| 232 | - * Gets the OVS uuid. | ||
| 233 | - * | ||
| 234 | - * @param dbName database name | ||
| 235 | - * @return ovs uuid, empty if no uuid is find | ||
| 236 | - */ | ||
| 237 | - String getOvsUuid(String dbName); | ||
| 238 | - | ||
| 239 | - /** | ||
| 240 | * Gets the OVSDB database schema. | 214 | * Gets the OVSDB database schema. |
| 241 | * | 215 | * |
| 242 | * @param dbName database name | 216 | * @param dbName database name |
| ... | @@ -254,16 +228,6 @@ public interface OvsdbClientService extends OvsdbRpc { | ... | @@ -254,16 +228,6 @@ public interface OvsdbClientService extends OvsdbRpc { |
| 254 | ListenableFuture<TableUpdates> monitorTables(String dbName, String id); | 228 | ListenableFuture<TableUpdates> monitorTables(String dbName, String id); |
| 255 | 229 | ||
| 256 | /** | 230 | /** |
| 257 | - * Gets the OVSDB config operation result. | ||
| 258 | - * | ||
| 259 | - * @param dbName database name | ||
| 260 | - * @param operations the list of operations | ||
| 261 | - * @return operation results | ||
| 262 | - */ | ||
| 263 | - ListenableFuture<List<OperationResult>> transactConfig(String dbName, | ||
| 264 | - List<Operation> operations); | ||
| 265 | - | ||
| 266 | - /** | ||
| 267 | * Gets the OVSDB database schema from local. | 231 | * Gets the OVSDB database schema from local. |
| 268 | * | 232 | * |
| 269 | * @param dbName database name | 233 | * @param dbName database name | ... | ... |
| ... | @@ -45,6 +45,10 @@ public final class OvsdbConstant { | ... | @@ -45,6 +45,10 @@ public final class OvsdbConstant { |
| 45 | public static final String DATAPATH_ID = "datapath-id"; | 45 | public static final String DATAPATH_ID = "datapath-id"; |
| 46 | public static final String DISABLE_INBAND = "disable-in-band"; | 46 | public static final String DISABLE_INBAND = "disable-in-band"; |
| 47 | 47 | ||
| 48 | + /** Port table. */ | ||
| 49 | + public static final String PORT = "Port"; | ||
| 50 | + public static final String INTERFACES = "interfaces"; | ||
| 51 | + | ||
| 48 | /** Interface table. */ | 52 | /** Interface table. */ |
| 49 | public static final String INTERFACE = "Interface"; | 53 | public static final String INTERFACE = "Interface"; |
| 50 | // type | 54 | // type |
| ... | @@ -52,13 +56,14 @@ public final class OvsdbConstant { | ... | @@ -52,13 +56,14 @@ public final class OvsdbConstant { |
| 52 | // virtual machine identifiers | 56 | // virtual machine identifiers |
| 53 | public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id"; | 57 | public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id"; |
| 54 | public static final String EXTERNAL_ID_VM_MAC = "attached-mac"; | 58 | public static final String EXTERNAL_ID_VM_MAC = "attached-mac"; |
| 59 | + // tunnel interface options | ||
| 60 | + public static final String TUNNEL_LOCAL_IP = "local_ip"; | ||
| 61 | + public static final String TUNNEL_REMOTE_IP = "remote_ip"; | ||
| 62 | + public static final String TUNNEL_KEY = "key"; | ||
| 55 | 63 | ||
| 56 | /** Controller table. */ | 64 | /** Controller table. */ |
| 57 | public static final String CONTROLLER = "Controller"; | 65 | public static final String CONTROLLER = "Controller"; |
| 58 | 66 | ||
| 59 | - /** Port table. */ | ||
| 60 | - public static final String PORT = "Port"; | ||
| 61 | - | ||
| 62 | /** Ovsdb bridge name. */ | 67 | /** Ovsdb bridge name. */ |
| 63 | // TODO remove this particular bridge name from OVSDB provider | 68 | // TODO remove this particular bridge name from OVSDB provider |
| 64 | public static final String INTEGRATION_BRIDGE = "br-int"; | 69 | public static final String INTEGRATION_BRIDGE = "br-int"; | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.ovsdb.controller; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | +import static org.onosproject.ovsdb.controller.OvsdbConstant.*; | ||
| 20 | + | ||
| 21 | +import java.util.Map; | ||
| 22 | +import java.util.Objects; | ||
| 23 | + | ||
| 24 | +import com.google.common.collect.Maps; | ||
| 25 | +import org.onosproject.net.DefaultAnnotations; | ||
| 26 | +import org.onosproject.net.behaviour.TunnelDescription; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * The class representing an OVSDB interface. | ||
| 30 | + * This class is immutable. | ||
| 31 | + */ | ||
| 32 | +public final class OvsdbInterface { | ||
| 33 | + | ||
| 34 | + public enum Type { | ||
| 35 | + /** | ||
| 36 | + * An ordinary network device, e.g. eth0 on Linux. | ||
| 37 | + */ | ||
| 38 | + SYSTEM, | ||
| 39 | + /** | ||
| 40 | + * A simulated network device that sends and receives traffic. | ||
| 41 | + */ | ||
| 42 | + INTERNAL, | ||
| 43 | + /** | ||
| 44 | + * A TUN/TAP device managed by Open vSwitch. | ||
| 45 | + */ | ||
| 46 | + TAP, | ||
| 47 | + /** | ||
| 48 | + * An Ethernet over RFC 2890 Generic Routing Encapsulation over IPv4 IPsec tunnel. | ||
| 49 | + */ | ||
| 50 | + GRE, | ||
| 51 | + /** | ||
| 52 | + * An Ethernet tunnel over the experimental, UDP-based VXLAN protocol. | ||
| 53 | + */ | ||
| 54 | + VXLAN, | ||
| 55 | + /** | ||
| 56 | + * A pair of virtual devices that act as a patch cable. | ||
| 57 | + */ | ||
| 58 | + PATCH | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + private final String name; | ||
| 62 | + private final Type type; | ||
| 63 | + | ||
| 64 | + /* Adds more configs */ | ||
| 65 | + | ||
| 66 | + /* Fields start with "options:" prefix defined in the OVSDB */ | ||
| 67 | + private final Map<String, String> options; | ||
| 68 | + | ||
| 69 | + private OvsdbInterface(String name, Type type, Map<String, String> options) { | ||
| 70 | + this.name = name; | ||
| 71 | + this.type = type; | ||
| 72 | + this.options = Maps.newHashMap(options); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * Returns name of the interface. | ||
| 77 | + * | ||
| 78 | + * @return interface name | ||
| 79 | + */ | ||
| 80 | + public String name() { | ||
| 81 | + return name; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * Returns type of the interface. | ||
| 86 | + * | ||
| 87 | + * @return interface type | ||
| 88 | + */ | ||
| 89 | + public Type type() { | ||
| 90 | + return type; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * Returns type of the interface with lowercase string. | ||
| 95 | + * | ||
| 96 | + * @return interface type string | ||
| 97 | + */ | ||
| 98 | + public String typeToString() { | ||
| 99 | + return type.name().toLowerCase(); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * Returns optional configs of the interface. | ||
| 104 | + * | ||
| 105 | + * @return interface options | ||
| 106 | + */ | ||
| 107 | + public Map<String, String> options() { | ||
| 108 | + return options; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public int hashCode() { | ||
| 113 | + return Objects.hash(name); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + public boolean equals(Object obj) { | ||
| 118 | + if (this == obj) { | ||
| 119 | + return true; | ||
| 120 | + } | ||
| 121 | + if (obj instanceof OvsdbInterface) { | ||
| 122 | + final OvsdbInterface otherOvsdbInterface = (OvsdbInterface) obj; | ||
| 123 | + return Objects.equals(this.name, otherOvsdbInterface.name); | ||
| 124 | + } | ||
| 125 | + return false; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + @Override | ||
| 129 | + public String toString() { | ||
| 130 | + return toStringHelper(this) | ||
| 131 | + .add("name", name) | ||
| 132 | + .add("type", type) | ||
| 133 | + .add("options", options) | ||
| 134 | + .toString(); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * Returns new OVSDB interface builder. | ||
| 139 | + * | ||
| 140 | + * @return ovsdb interface builder | ||
| 141 | + */ | ||
| 142 | + public static OvsdbInterface.Builder builder() { | ||
| 143 | + return new Builder(); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * Returns new OVSDB interface builder with tunnel interface description. | ||
| 148 | + * | ||
| 149 | + * @param tunnelDesc tunnel interface description | ||
| 150 | + * @return ovsdb interface builder | ||
| 151 | + */ | ||
| 152 | + public static OvsdbInterface.Builder builder(TunnelDescription tunnelDesc) { | ||
| 153 | + return new Builder(tunnelDesc); | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * Builder of OVSDB interface entities. | ||
| 158 | + */ | ||
| 159 | + public static final class Builder { | ||
| 160 | + private String name; | ||
| 161 | + private Type type; | ||
| 162 | + private Map<String, String> options = Maps.newHashMap(); | ||
| 163 | + | ||
| 164 | + private Builder() { | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * Constructs a builder with a given tunnel interface description. | ||
| 169 | + * | ||
| 170 | + * @param tunnelDesc tunnel interface description | ||
| 171 | + */ | ||
| 172 | + private Builder(TunnelDescription tunnelDesc) { | ||
| 173 | + this.name = tunnelDesc.ifaceName(); | ||
| 174 | + this.type = Type.valueOf(tunnelDesc.type().name()); | ||
| 175 | + | ||
| 176 | + if (tunnelDesc.local().isPresent()) { | ||
| 177 | + options.put(TUNNEL_LOCAL_IP, tunnelDesc.local().get().strValue()); | ||
| 178 | + } | ||
| 179 | + if (tunnelDesc.remote().isPresent()) { | ||
| 180 | + options.put(TUNNEL_REMOTE_IP, tunnelDesc.remote().get().strValue()); | ||
| 181 | + } | ||
| 182 | + if (tunnelDesc.key().isPresent()) { | ||
| 183 | + options.put(TUNNEL_KEY, tunnelDesc.key().get().strValue()); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + // set other configurations if there are any | ||
| 187 | + options.putAll(((DefaultAnnotations) tunnelDesc.annotations()).asMap()); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + /** | ||
| 191 | + * Returns new OVSDB interface. | ||
| 192 | + * | ||
| 193 | + * @return ovsdb interface | ||
| 194 | + */ | ||
| 195 | + public OvsdbInterface build() { | ||
| 196 | + return new OvsdbInterface(name, type, options); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * Returns OVSDB interface builder with a given name. | ||
| 201 | + * | ||
| 202 | + * @param name name of the interface | ||
| 203 | + * @return ovsdb interface builder | ||
| 204 | + */ | ||
| 205 | + public Builder name(String name) { | ||
| 206 | + this.name = name; | ||
| 207 | + return this; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + /** | ||
| 211 | + * Returns OVSDB interface builder with a given interface type. | ||
| 212 | + * | ||
| 213 | + * @param type type of the interface | ||
| 214 | + * @return ovsdb interface builder | ||
| 215 | + */ | ||
| 216 | + public Builder type(Type type) { | ||
| 217 | + this.type = type; | ||
| 218 | + return this; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + /** | ||
| 222 | + * Returns OVSDB interface builder with given options. | ||
| 223 | + * | ||
| 224 | + * @param options map of options | ||
| 225 | + * @return ovsdb interface builder | ||
| 226 | + */ | ||
| 227 | + public Builder options(Map<String, String> options) { | ||
| 228 | + this.options = Maps.newHashMap(options); | ||
| 229 | + return this; | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | +} |
protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnel.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015-present Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.ovsdb.controller; | ||
| 17 | - | ||
| 18 | -import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 20 | - | ||
| 21 | -import java.util.Objects; | ||
| 22 | - | ||
| 23 | -import org.onlab.packet.IpAddress; | ||
| 24 | - | ||
| 25 | -/** | ||
| 26 | - * The class representing an ovsdb tunnel. | ||
| 27 | - * This class is immutable. | ||
| 28 | - */ | ||
| 29 | -public final class OvsdbTunnel { | ||
| 30 | - | ||
| 31 | - private final IpAddress localIp; | ||
| 32 | - private final IpAddress remoteIp; | ||
| 33 | - | ||
| 34 | - public enum Type { | ||
| 35 | - VXLAN, GRE | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - private final Type tunnelType; | ||
| 39 | - private final OvsdbTunnelName tunnelName; | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * Constructor from an IpAddress localIp, IpAddress remoteIp Type tunnelType, | ||
| 43 | - * OvsdbTunnelName tunnelName. | ||
| 44 | - * | ||
| 45 | - * @param localIp the localIp to use | ||
| 46 | - * @param remoteIp the remoteIp to use | ||
| 47 | - * @param tunnelType the tunnelType to use | ||
| 48 | - * @param tunnelName the tunnelName to use | ||
| 49 | - */ | ||
| 50 | - public OvsdbTunnel(IpAddress localIp, IpAddress remoteIp, Type tunnelType, | ||
| 51 | - OvsdbTunnelName tunnelName) { | ||
| 52 | - checkNotNull(localIp, "portName is not null"); | ||
| 53 | - checkNotNull(remoteIp, "portName is not null"); | ||
| 54 | - checkNotNull(tunnelName, "portName is not null"); | ||
| 55 | - this.localIp = localIp; | ||
| 56 | - this.remoteIp = remoteIp; | ||
| 57 | - this.tunnelType = tunnelType; | ||
| 58 | - this.tunnelName = tunnelName; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - /** | ||
| 62 | - * Gets the local IP of tunnel. | ||
| 63 | - * | ||
| 64 | - * @return the local IP of tunnel | ||
| 65 | - */ | ||
| 66 | - public IpAddress localIp() { | ||
| 67 | - return localIp; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * Gets the remote IP of tunnel. | ||
| 72 | - * | ||
| 73 | - * @return the remote IP of tunnel | ||
| 74 | - */ | ||
| 75 | - public IpAddress remoteIp() { | ||
| 76 | - return remoteIp; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * Gets the tunnel type of tunnel. | ||
| 81 | - * | ||
| 82 | - * @return the tunnel type of tunnel | ||
| 83 | - */ | ||
| 84 | - public Type tunnelType() { | ||
| 85 | - return tunnelType; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - /** | ||
| 89 | - * Gets the tunnel name of tunnel. | ||
| 90 | - * | ||
| 91 | - * @return the tunnel name of tunnel | ||
| 92 | - */ | ||
| 93 | - public OvsdbTunnelName tunnelName() { | ||
| 94 | - return tunnelName; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - @Override | ||
| 98 | - public int hashCode() { | ||
| 99 | - return Objects.hash(localIp, remoteIp, tunnelType, tunnelName); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - @Override | ||
| 103 | - public boolean equals(Object obj) { | ||
| 104 | - if (this == obj) { | ||
| 105 | - return true; | ||
| 106 | - } | ||
| 107 | - if (obj instanceof OvsdbTunnel) { | ||
| 108 | - final OvsdbTunnel otherOvsdbTunnel = (OvsdbTunnel) obj; | ||
| 109 | - return Objects.equals(this.localIp, otherOvsdbTunnel.localIp) | ||
| 110 | - && Objects.equals(this.remoteIp, otherOvsdbTunnel.remoteIp) | ||
| 111 | - && Objects.equals(this.tunnelType, | ||
| 112 | - otherOvsdbTunnel.tunnelType) | ||
| 113 | - && Objects.equals(this.tunnelName, | ||
| 114 | - otherOvsdbTunnel.tunnelName); | ||
| 115 | - } | ||
| 116 | - return false; | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - @Override | ||
| 120 | - public String toString() { | ||
| 121 | - return toStringHelper(this).add("localIp", localIp.toString()) | ||
| 122 | - .add("remoteIp", remoteIp.toString()) | ||
| 123 | - .add("tunnelType", tunnelType).add("tunnelName", tunnelName) | ||
| 124 | - .toString(); | ||
| 125 | - } | ||
| 126 | -} |
This diff is collapsed. Click to expand it.
| ... | @@ -24,13 +24,11 @@ import org.onosproject.net.DeviceId; | ... | @@ -24,13 +24,11 @@ import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.behaviour.ControllerInfo; | 24 | import org.onosproject.net.behaviour.ControllerInfo; |
| 25 | import org.onosproject.ovsdb.controller.OvsdbBridge; | 25 | import org.onosproject.ovsdb.controller.OvsdbBridge; |
| 26 | import org.onosproject.ovsdb.controller.OvsdbClientService; | 26 | import org.onosproject.ovsdb.controller.OvsdbClientService; |
| 27 | +import org.onosproject.ovsdb.controller.OvsdbInterface; | ||
| 27 | import org.onosproject.ovsdb.controller.OvsdbNodeId; | 28 | import org.onosproject.ovsdb.controller.OvsdbNodeId; |
| 28 | import org.onosproject.ovsdb.controller.OvsdbPort; | 29 | import org.onosproject.ovsdb.controller.OvsdbPort; |
| 29 | -import org.onosproject.ovsdb.controller.OvsdbTunnel; | ||
| 30 | -import org.onosproject.ovsdb.rfc.message.OperationResult; | ||
| 31 | import org.onosproject.ovsdb.rfc.message.TableUpdates; | 30 | import org.onosproject.ovsdb.rfc.message.TableUpdates; |
| 32 | import org.onosproject.ovsdb.rfc.notation.Row; | 31 | import org.onosproject.ovsdb.rfc.notation.Row; |
| 33 | -import org.onosproject.ovsdb.rfc.notation.Uuid; | ||
| 34 | import org.onosproject.ovsdb.rfc.operations.Operation; | 32 | import org.onosproject.ovsdb.rfc.operations.Operation; |
| 35 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; | 33 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
| 36 | 34 | ||
| ... | @@ -55,17 +53,20 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { | ... | @@ -55,17 +53,20 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { |
| 55 | 53 | ||
| 56 | @Override | 54 | @Override |
| 57 | public void dropTunnel(IpAddress srcIp, IpAddress dstIp) { | 55 | public void dropTunnel(IpAddress srcIp, IpAddress dstIp) { |
| 56 | + } | ||
| 58 | 57 | ||
| 58 | + @Override | ||
| 59 | + public boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface) { | ||
| 60 | + return true; | ||
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | @Override | 63 | @Override |
| 62 | - public Set<OvsdbTunnel> getTunnels() { | 64 | + public boolean dropInterface(String name) { |
| 63 | - return null; | 65 | + return true; |
| 64 | } | 66 | } |
| 65 | 67 | ||
| 66 | @Override | 68 | @Override |
| 67 | public void createBridge(String bridgeName) { | 69 | public void createBridge(String bridgeName) { |
| 68 | - | ||
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | @Override | 72 | @Override |
| ... | @@ -80,7 +81,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { | ... | @@ -80,7 +81,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { |
| 80 | 81 | ||
| 81 | @Override | 82 | @Override |
| 82 | public void dropBridge(String bridgeName) { | 83 | public void dropBridge(String bridgeName) { |
| 83 | - | ||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | @Override | 86 | @Override |
| ... | @@ -99,11 +99,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { | ... | @@ -99,11 +99,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | @Override | 101 | @Override |
| 102 | - public void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers) { | ||
| 103 | - | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - @Override | ||
| 107 | public void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers) { | 102 | public void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers) { |
| 108 | 103 | ||
| 109 | } | 104 | } |
| ... | @@ -139,21 +134,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { | ... | @@ -139,21 +134,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { |
| 139 | } | 134 | } |
| 140 | 135 | ||
| 141 | @Override | 136 | @Override |
| 142 | - public String getInterfaceUuid(String portUuid, String portName) { | ||
| 143 | - return null; | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - @Override | ||
| 147 | - public String getControllerUuid(String controllerName, String controllerTarget) { | ||
| 148 | - return null; | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - @Override | ||
| 152 | - public String getOvsUuid(String dbName) { | ||
| 153 | - return null; | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - @Override | ||
| 157 | public ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName) { | 137 | public ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName) { |
| 158 | return null; | 138 | return null; |
| 159 | } | 139 | } |
| ... | @@ -164,11 +144,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { | ... | @@ -164,11 +144,6 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { |
| 164 | } | 144 | } |
| 165 | 145 | ||
| 166 | @Override | 146 | @Override |
| 167 | - public ListenableFuture<List<OperationResult>> transactConfig(String dbName, List<Operation> operations) { | ||
| 168 | - return null; | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - @Override | ||
| 172 | public DatabaseSchema getDatabaseSchema(String dbName) { | 147 | public DatabaseSchema getDatabaseSchema(String dbName) { |
| 173 | return null; | 148 | return null; |
| 174 | } | 149 | } | ... | ... |
-
Please register or login to post a comment