Committed by
Gerrit Code Review
CORD-223 Added ovsdb driver methods for bridge and tunnel interface creation
Change-Id: Ida80a4ef5b66cebb83b2629054c68a3546526d23
Showing
4 changed files
with
54 additions
and
3 deletions
... | @@ -36,6 +36,17 @@ public interface BridgeConfig extends HandlerBehaviour { | ... | @@ -36,6 +36,17 @@ public interface BridgeConfig extends HandlerBehaviour { |
36 | void addBridge(BridgeName bridgeName); | 36 | void addBridge(BridgeName bridgeName); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | + * Adds a bridge with given bridge name and dpid, and sets the controller | ||
40 | + * of the bridge with given controllers. | ||
41 | + * | ||
42 | + * @param bridgeName bridge name | ||
43 | + * @param dpid dpid | ||
44 | + * @param controllers list of controller | ||
45 | + * @return true if succeeds, fail otherwise | ||
46 | + */ | ||
47 | + boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers); | ||
48 | + | ||
49 | + /** | ||
39 | * Remove a bridge. | 50 | * Remove a bridge. |
40 | * | 51 | * |
41 | * @param bridgeName bridge name | 52 | * @param bridgeName bridge name | ... | ... |
... | @@ -32,6 +32,15 @@ public interface TunnelConfig extends HandlerBehaviour { | ... | @@ -32,6 +32,15 @@ public interface TunnelConfig extends HandlerBehaviour { |
32 | void createTunnel(TunnelDescription tunnel); | 32 | void createTunnel(TunnelDescription tunnel); |
33 | 33 | ||
34 | /** | 34 | /** |
35 | + * Creates a tunnel interface on a given bridge of this device. | ||
36 | + * | ||
37 | + * @param bridgeName bridge name | ||
38 | + * @param tunnel tunnel description | ||
39 | + * @return true if succeeds, false otherwise | ||
40 | + */ | ||
41 | + boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel); | ||
42 | + | ||
43 | + /** | ||
35 | * Removes a tunnel on this device. | 44 | * Removes a tunnel on this device. |
36 | * | 45 | * |
37 | * @param tunnel tunnel descriptor | 46 | * @param tunnel tunnel descriptor | ... | ... |
... | @@ -22,11 +22,13 @@ import java.util.Set; | ... | @@ -22,11 +22,13 @@ import java.util.Set; |
22 | import java.util.stream.Collectors; | 22 | import java.util.stream.Collectors; |
23 | 23 | ||
24 | import org.onlab.packet.IpAddress; | 24 | import org.onlab.packet.IpAddress; |
25 | +import org.onosproject.net.DefaultAnnotations; | ||
25 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
26 | import org.onosproject.net.PortNumber; | 27 | import org.onosproject.net.PortNumber; |
27 | import org.onosproject.net.behaviour.BridgeConfig; | 28 | import org.onosproject.net.behaviour.BridgeConfig; |
28 | import org.onosproject.net.behaviour.BridgeDescription; | 29 | import org.onosproject.net.behaviour.BridgeDescription; |
29 | import org.onosproject.net.behaviour.BridgeName; | 30 | import org.onosproject.net.behaviour.BridgeName; |
31 | +import org.onosproject.net.behaviour.ControllerInfo; | ||
30 | import org.onosproject.net.behaviour.DefaultBridgeDescription; | 32 | import org.onosproject.net.behaviour.DefaultBridgeDescription; |
31 | import org.onosproject.net.device.DefaultPortDescription; | 33 | import org.onosproject.net.device.DefaultPortDescription; |
32 | import org.onosproject.net.device.PortDescription; | 34 | import org.onosproject.net.device.PortDescription; |
... | @@ -52,6 +54,13 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour | ... | @@ -52,6 +54,13 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour |
52 | } | 54 | } |
53 | 55 | ||
54 | @Override | 56 | @Override |
57 | + public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) { | ||
58 | + DriverHandler handler = handler(); | ||
59 | + OvsdbClientService clientService = getOvsdbClientService(handler); | ||
60 | + return clientService.createBridge(bridgeName.name(), dpid, controllers); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
55 | public void deleteBridge(BridgeName bridgeName) { | 64 | public void deleteBridge(BridgeName bridgeName) { |
56 | DriverHandler handler = handler(); | 65 | DriverHandler handler = handler(); |
57 | OvsdbClientService clientService = getOvsdbClientService(handler); | 66 | OvsdbClientService clientService = getOvsdbClientService(handler); |
... | @@ -108,9 +117,10 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour | ... | @@ -108,9 +117,10 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour |
108 | return ports.stream() | 117 | return ports.stream() |
109 | .map(x -> new DefaultPortDescription( | 118 | .map(x -> new DefaultPortDescription( |
110 | PortNumber.portNumber(x.portNumber().value()), | 119 | PortNumber.portNumber(x.portNumber().value()), |
111 | - true | 120 | + true, |
112 | - ) | 121 | + DefaultAnnotations.builder() |
113 | - ) | 122 | + .set("portName", x.portName().value()) |
123 | + .build())) | ||
114 | .collect(Collectors.toSet()); | 124 | .collect(Collectors.toSet()); |
115 | } | 125 | } |
116 | 126 | ... | ... |
... | @@ -16,11 +16,14 @@ | ... | @@ -16,11 +16,14 @@ |
16 | package org.onosproject.driver.ovsdb; | 16 | package org.onosproject.driver.ovsdb; |
17 | 17 | ||
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | +import java.util.Map; | ||
19 | import java.util.Set; | 20 | import java.util.Set; |
20 | import java.util.stream.Collectors; | 21 | import java.util.stream.Collectors; |
21 | 22 | ||
22 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
24 | +import org.onosproject.net.DefaultAnnotations; | ||
23 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
26 | +import org.onosproject.net.behaviour.BridgeName; | ||
24 | import org.onosproject.net.behaviour.DefaultTunnelDescription; | 27 | import org.onosproject.net.behaviour.DefaultTunnelDescription; |
25 | import org.onosproject.net.behaviour.IpTunnelEndPoint; | 28 | import org.onosproject.net.behaviour.IpTunnelEndPoint; |
26 | import org.onosproject.net.behaviour.TunnelConfig; | 29 | import org.onosproject.net.behaviour.TunnelConfig; |
... | @@ -40,6 +43,8 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour | ... | @@ -40,6 +43,8 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour |
40 | implements TunnelConfig { | 43 | implements TunnelConfig { |
41 | 44 | ||
42 | private static final String DEFAULT_ADDRESS = "0.0.0.0"; | 45 | private static final String DEFAULT_ADDRESS = "0.0.0.0"; |
46 | + private static final String OPTION_LOCAL_IP = "local_ip"; | ||
47 | + private static final String OPTION_REMOTE_IP = "remote_ip"; | ||
43 | 48 | ||
44 | @Override | 49 | @Override |
45 | public void createTunnel(TunnelDescription tunnel) { | 50 | public void createTunnel(TunnelDescription tunnel) { |
... | @@ -60,6 +65,22 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour | ... | @@ -60,6 +65,22 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour |
60 | } | 65 | } |
61 | 66 | ||
62 | @Override | 67 | @Override |
68 | + public boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel) { | ||
69 | + Map<String, String> options = ((DefaultAnnotations) tunnel.annotations()).asMap(); | ||
70 | + if (tunnel.src() != null) { | ||
71 | + options.put(OPTION_LOCAL_IP, tunnel.src().toString()); | ||
72 | + } | ||
73 | + if (tunnel.dst() != null) { | ||
74 | + options.put(OPTION_REMOTE_IP, tunnel.dst().toString()); | ||
75 | + } | ||
76 | + | ||
77 | + DriverHandler handler = handler(); | ||
78 | + OvsdbClientService ovsdbClient = getOvsdbNode(handler); | ||
79 | + return ovsdbClient.createTunnel(bridgeName.name(), tunnel.tunnelName().toString(), | ||
80 | + tunnel.type().toString().toLowerCase(), options); | ||
81 | + } | ||
82 | + | ||
83 | + @Override | ||
63 | public void removeTunnel(TunnelDescription tunnel) { | 84 | public void removeTunnel(TunnelDescription tunnel) { |
64 | DriverHandler handler = handler(); | 85 | DriverHandler handler = handler(); |
65 | OvsdbClientService ovsdbNode = getOvsdbNode(handler); | 86 | OvsdbClientService ovsdbNode = getOvsdbNode(handler); | ... | ... |
-
Please register or login to post a comment