Hyunsun Moon
Committed by Gerrit Code Review

Refactored bridge config to take bridge description

OVSDB provides lots of bridge configuration options but the exisisting
bridge config implementation only allows some of them by overloading
addBridge method. Also some of the bridge properties were set static
and unable to configure. This patch fixes these limitations.

- Added some bridge config options to the bridge description
- Deprecated multiple overloaded addBridge methods
- Some code clean up

Change-Id: Ibc828177b210bd4b215aea0b63cc359776c13e03
...@@ -35,8 +35,10 @@ import org.onosproject.net.Device; ...@@ -35,8 +35,10 @@ import org.onosproject.net.Device;
35 import org.onosproject.net.DeviceId; 35 import org.onosproject.net.DeviceId;
36 import org.onosproject.net.Port; 36 import org.onosproject.net.Port;
37 import org.onosproject.net.behaviour.BridgeConfig; 37 import org.onosproject.net.behaviour.BridgeConfig;
38 +import org.onosproject.net.behaviour.BridgeDescription;
38 import org.onosproject.net.behaviour.BridgeName; 39 import org.onosproject.net.behaviour.BridgeName;
39 import org.onosproject.net.behaviour.ControllerInfo; 40 import org.onosproject.net.behaviour.ControllerInfo;
41 +import org.onosproject.net.behaviour.DefaultBridgeDescription;
40 import org.onosproject.net.behaviour.DefaultTunnelDescription; 42 import org.onosproject.net.behaviour.DefaultTunnelDescription;
41 import org.onosproject.net.behaviour.TunnelConfig; 43 import org.onosproject.net.behaviour.TunnelConfig;
42 import org.onosproject.net.behaviour.TunnelDescription; 44 import org.onosproject.net.behaviour.TunnelDescription;
...@@ -399,7 +401,16 @@ public class OpenstackNodeManager implements OpenstackNodeService { ...@@ -399,7 +401,16 @@ public class OpenstackNodeManager implements OpenstackNodeService {
399 try { 401 try {
400 DriverHandler handler = driverService.createHandler(node.ovsdbId()); 402 DriverHandler handler = driverService.createHandler(node.ovsdbId());
401 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); 403 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
402 - bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE), dpid, controllers); 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);
403 } catch (ItemNotFoundException e) { 414 } catch (ItemNotFoundException e) {
404 log.warn("Failed to create integration bridge on {}", node.ovsdbId()); 415 log.warn("Failed to create integration bridge on {}", node.ovsdbId());
405 } 416 }
......
...@@ -715,24 +715,17 @@ public class VtnManager implements VtnService { ...@@ -715,24 +715,17 @@ public class VtnManager implements VtnService {
715 .filter(d -> !("ovsdb:" + ipAddress).equals(d.id().toString())) 715 .filter(d -> !("ovsdb:" + ipAddress).equals(d.id().toString()))
716 .forEach(d -> { 716 .forEach(d -> {
717 DriverHandler handler = driverService.createHandler(d.id()); 717 DriverHandler handler = driverService.createHandler(d.id());
718 - BridgeConfig bridgeConfig = handler 718 + BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
719 - .behaviour(BridgeConfig.class); 719 + Collection<BridgeDescription> bridgeDescriptions = bridgeConfig.getBridges();
720 - Collection<BridgeDescription> bridgeDescriptions = bridgeConfig 720 + for (BridgeDescription sw : bridgeDescriptions) {
721 - .getBridges(); 721 + if (sw.name().equals(VtnConfig.DEFAULT_BRIDGE_NAME) &&
722 - Iterator<BridgeDescription> it = bridgeDescriptions 722 + sw.deviceId().isPresent()) {
723 - .iterator(); 723 + List<Port> ports = deviceService.getPorts(sw.deviceId().get());
724 - while (it.hasNext()) { 724 + ports.stream().filter(p -> p.annotations().value(AnnotationKeys.PORT_NAME)
725 - BridgeDescription sw = it.next();
726 - if (sw.bridgeName().name().equals(VtnConfig.DEFAULT_BRIDGE_NAME)) {
727 - List<Port> ports = deviceService.getPorts(sw.deviceId());
728 - ports.stream()
729 - .filter(p -> p.annotations().value(AnnotationKeys.PORT_NAME)
730 .equalsIgnoreCase(tunnelName)) 725 .equalsIgnoreCase(tunnelName))
731 - .forEach(p -> { 726 + .forEach(p -> l2ForwardService.programTunnelOut(
732 - l2ForwardService.programTunnelOut(sw.deviceId(), 727 + sw.deviceId().get(), segmentationId, p.number(),
733 - segmentationId, p.number(), 728 + dstMac, type, ipAddress));
734 - dstMac, type, ipAddress);
735 - });
736 break; 729 break;
737 } 730 }
738 } 731 }
......
...@@ -23,7 +23,9 @@ import org.onlab.packet.IpAddress; ...@@ -23,7 +23,9 @@ import org.onlab.packet.IpAddress;
23 import org.onosproject.net.DefaultAnnotations; 23 import org.onosproject.net.DefaultAnnotations;
24 import org.onosproject.net.PortNumber; 24 import org.onosproject.net.PortNumber;
25 import org.onosproject.net.behaviour.BridgeConfig; 25 import org.onosproject.net.behaviour.BridgeConfig;
26 +import org.onosproject.net.behaviour.BridgeDescription;
26 import org.onosproject.net.behaviour.BridgeName; 27 import org.onosproject.net.behaviour.BridgeName;
28 +import org.onosproject.net.behaviour.DefaultBridgeDescription;
27 import org.onosproject.net.behaviour.DefaultTunnelDescription; 29 import org.onosproject.net.behaviour.DefaultTunnelDescription;
28 import org.onosproject.net.behaviour.IpTunnelEndPoint; 30 import org.onosproject.net.behaviour.IpTunnelEndPoint;
29 import org.onosproject.net.behaviour.TunnelConfig; 31 import org.onosproject.net.behaviour.TunnelConfig;
...@@ -62,7 +64,16 @@ public final class VtnConfig { ...@@ -62,7 +64,16 @@ public final class VtnConfig {
62 */ 64 */
63 public static void applyBridgeConfig(DriverHandler handler, String dpid, String exPortName) { 65 public static void applyBridgeConfig(DriverHandler handler, String dpid, String exPortName) {
64 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); 66 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
65 - bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), dpid, exPortName); 67 + BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
68 + .name(DEFAULT_BRIDGE_NAME)
69 + .failMode(BridgeDescription.FailMode.SECURE)
70 + .datapathId(dpid)
71 + .disableInBand()
72 + .enableLocalController()
73 + .build();
74 +
75 + bridgeConfig.addBridge(bridgeDesc);
76 + bridgeConfig.addPort(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), exPortName);
66 } 77 }
67 78
68 /** 79 /**
......
...@@ -31,31 +31,45 @@ public interface BridgeConfig extends HandlerBehaviour { ...@@ -31,31 +31,45 @@ public interface BridgeConfig extends HandlerBehaviour {
31 /** 31 /**
32 * Add a bridge. 32 * Add a bridge.
33 * 33 *
34 + * @deprecated version 1.7.0 - Hummingbird
34 * @param bridgeName bridge name 35 * @param bridgeName bridge name
35 */ 36 */
37 + @Deprecated
36 void addBridge(BridgeName bridgeName); 38 void addBridge(BridgeName bridgeName);
37 39
38 /** 40 /**
39 * Adds a bridge with given bridge name, dpid and exPortName. 41 * Adds a bridge with given bridge name, dpid and exPortName.
40 * 42 *
43 + * @deprecated version 1.7.0 - Hummingbird
41 * @param bridgeName bridge name 44 * @param bridgeName bridge name
42 * @param dpid dpid 45 * @param dpid dpid
43 * @param exPortName external port name 46 * @param exPortName external port name
44 */ 47 */
48 + @Deprecated
45 void addBridge(BridgeName bridgeName, String dpid, String exPortName); 49 void addBridge(BridgeName bridgeName, String dpid, String exPortName);
46 50
47 /** 51 /**
48 * Adds a bridge with given bridge name and dpid, and sets the controller 52 * Adds a bridge with given bridge name and dpid, and sets the controller
49 * of the bridge with given controllers. 53 * of the bridge with given controllers.
50 * 54 *
55 + * @deprecated version 1.7.0 - Hummingbird
51 * @param bridgeName bridge name 56 * @param bridgeName bridge name
52 * @param dpid dpid 57 * @param dpid dpid
53 * @param controllers list of controller 58 * @param controllers list of controller
54 * @return true if succeeds, fail otherwise 59 * @return true if succeeds, fail otherwise
55 */ 60 */
61 + @Deprecated
56 boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers); 62 boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers);
57 63
58 /** 64 /**
65 + * Adds a bridge with a given description.
66 + *
67 + * @param bridgeDescription bridge description
68 + * @return true if succeeds, or false
69 + */
70 + boolean addBridge(BridgeDescription bridgeDescription);
71 +
72 + /**
59 * Remove a bridge. 73 * Remove a bridge.
60 * 74 *
61 * @param bridgeName bridge name 75 * @param bridgeName bridge name
......
...@@ -18,29 +18,140 @@ package org.onosproject.net.behaviour; ...@@ -18,29 +18,140 @@ package org.onosproject.net.behaviour;
18 import org.onosproject.net.Description; 18 import org.onosproject.net.Description;
19 import org.onosproject.net.DeviceId; 19 import org.onosproject.net.DeviceId;
20 20
21 +import java.util.List;
22 +import java.util.Optional;
23 +
21 /** 24 /**
22 - * The abstraction of bridge in OVSDB protocol. 25 + * The abstraction of a bridge. Bridge represents an Ethernet switch with no or
26 + * multiple OpenFlow controllers. Only OVSDB device provides bridge config behavior
27 + * now and the bridge description is based on OVSDB schema.
23 */ 28 */
24 public interface BridgeDescription extends Description { 29 public interface BridgeDescription extends Description {
25 30
31 + enum FailMode {
32 + /**
33 + * The bridge will not set up flows on its own when the controller
34 + * connection fails or no controllers are defined.
35 + */
36 + SECURE,
37 + /**
38 + * The bridge will take over responsibility of setting up flows.
39 + */
40 + STANDALONE
41 + }
42 +
26 /** 43 /**
27 * Returns bridge name. 44 * Returns bridge name.
28 * 45 *
29 * @return bridge name 46 * @return bridge name
30 */ 47 */
31 - BridgeName bridgeName(); 48 + String name();
49 +
50 + /**
51 + * Returns OpenFlow controllers of the bridge.
52 + * If it's empty, then no OpenFlow controllers are used for the bridge.
53 + *
54 + * @return set of controllers
55 + */
56 + List<ControllerInfo> controllers();
57 +
58 + /**
59 + * Returns whether to use local controller as an OpenFlow controller of the
60 + * bridge if no controllers are specified.
61 + *
62 + * @return true to set local controller, false otherwise
63 + */
64 + boolean enableLocalController();
65 +
66 + /**
67 + * Returns fail mode of the bridge.
68 + * If it's not set, the default setting of the bridge is used.
69 + *
70 + * @return fail mode
71 + */
72 + Optional<FailMode> failMode();
73 +
74 + /**
75 + * Returns OpenFlow datapath ID of the bridge. Valid only if OpenFlow controller
76 + * is configured for the bridge.
77 + *
78 + * @return datapath id
79 + */
80 + Optional<String> datapathId();
81 +
82 + /**
83 + * Returns OpenFlow device ID. Valid only if OpenFlow controller is configured
84 + * for the bridge.
85 + *
86 + * @return device id
87 + */
88 + Optional<DeviceId> deviceId();
89 +
90 + /**
91 + * Returns in band control is enabled or not. If set to true, disable in-band
92 + * control on the bridge regardless of controller and manager settings.
93 + * If it's not set, the default setting of the bridge is used.
94 + *
95 + * @return true if in-band is disabled, false if in-band is enabled
96 + */
97 + Optional<Boolean> disableInBand();
98 +
99 + /**
100 + * Builder of bridge description entities.
101 + */
102 + interface Builder {
103 +
104 + /**
105 + * Returns bridge description builder with a given name.
106 + *
107 + * @param name bridge name
108 + * @return bridge description builder
109 + */
110 + Builder name(String name);
111 +
112 + /**
113 + * Returns bridge description builder with given controllers.
114 + *
115 + * @param controllers set of controllers
116 + * @return bridge description builder
117 + */
118 + Builder controllers(List<ControllerInfo> controllers);
119 +
120 + /**
121 + * Returns bridge description builder with local controller enabled.
122 + *
123 + * @return bridge description builder
124 + */
125 + Builder enableLocalController();
126 +
127 + /**
128 + * Returns bridge description builder with a given fail mode.
129 + *
130 + * @param failMode fail mode
131 + * @return bridge description builder
132 + */
133 + Builder failMode(FailMode failMode);
134 +
135 + /**
136 + * Returns bridge description builder with a given datapath ID.
137 + *
138 + * @param datapathId datapath id
139 + * @return bridge description builder
140 + */
141 + Builder datapathId(String datapathId);
32 142
33 /** 143 /**
34 - * Returns controller identifier that this bridge belongs to. 144 + * Returns bridge description builder with in-band control disabled.
35 * 145 *
36 - * @return controller identifier 146 + * @return bridge description builder
37 */ 147 */
38 - DeviceId cotrollerDeviceId(); 148 + Builder disableInBand();
39 149
40 /** 150 /**
41 - * Returns bridge identifier . 151 + * Builds an immutable bridge description.
42 * 152 *
43 - * @return bridge identifier 153 + * @return bridge description
44 */ 154 */
45 - DeviceId deviceId(); 155 + BridgeDescription build();
156 + }
46 } 157 }
......
...@@ -15,73 +15,158 @@ ...@@ -15,73 +15,158 @@
15 */ 15 */
16 package org.onosproject.net.behaviour; 16 package org.onosproject.net.behaviour;
17 17
18 -import java.util.Objects; 18 +import com.google.common.base.Strings;
19 - 19 +import com.google.common.collect.Lists;
20 -import org.onosproject.net.AbstractDescription;
21 import org.onosproject.net.DeviceId; 20 import org.onosproject.net.DeviceId;
22 import org.onosproject.net.SparseAnnotations; 21 import org.onosproject.net.SparseAnnotations;
23 22
24 -import com.google.common.base.MoreObjects; 23 +import java.util.List;
24 +import java.util.Optional;
25 +
26 +import static com.google.common.base.Preconditions.checkArgument;
27 +import static com.google.common.base.Preconditions.checkNotNull;
25 28
26 /** 29 /**
27 * The default implementation of bridge. 30 * The default implementation of bridge.
28 */ 31 */
29 -public final class DefaultBridgeDescription extends AbstractDescription 32 +public final class DefaultBridgeDescription implements BridgeDescription {
30 - implements BridgeDescription {
31 33
32 - private final BridgeName name; 34 + private final String name;
33 - private final DeviceId deviceId;
34 - private final DeviceId controllerId;
35 35
36 - public DefaultBridgeDescription(BridgeName name, DeviceId controllerId, 36 + /* Optional OpenFlow configurations */
37 - DeviceId deviceId, 37 + private final List<ControllerInfo> controllers;
38 - SparseAnnotations... annotations) { 38 + private final boolean enableLocalController;
39 - super(annotations); 39 + private final Optional<FailMode> failMode;
40 - this.name = name; 40 + private final Optional<String> datapathId;
41 - this.deviceId = deviceId; 41 + private final Optional<Boolean> disableInBand;
42 - this.controllerId = controllerId; 42 +
43 + /* Adds more configurations */
44 +
45 + private DefaultBridgeDescription(String name,
46 + List<ControllerInfo> controllers,
47 + boolean enableLocalController,
48 + Optional<FailMode> failMode,
49 + Optional<String> datapathId,
50 + Optional<Boolean> disableInBand) {
51 + this.name = checkNotNull(name);
52 + this.controllers = controllers;
53 + this.enableLocalController = enableLocalController;
54 + this.failMode = failMode;
55 + this.datapathId = datapathId;
56 + this.disableInBand = disableInBand;
43 } 57 }
44 58
45 @Override 59 @Override
46 - public BridgeName bridgeName() { 60 + public SparseAnnotations annotations() {
61 + return null;
62 + }
63 +
64 + @Override
65 + public String name() {
47 return name; 66 return name;
48 } 67 }
49 68
50 @Override 69 @Override
51 - public DeviceId deviceId() { 70 + public List<ControllerInfo> controllers() {
52 - return deviceId; 71 + return controllers;
72 + }
73 +
74 + @Override
75 + public boolean enableLocalController() {
76 + return enableLocalController;
53 } 77 }
54 78
55 @Override 79 @Override
56 - public DeviceId cotrollerDeviceId() { 80 + public Optional<FailMode> failMode() {
57 - return controllerId; 81 + return failMode;
58 } 82 }
59 83
60 @Override 84 @Override
61 - public int hashCode() { 85 + public Optional<String> datapathId() {
62 - return Objects.hash(name, deviceId, controllerId); 86 + return datapathId;
63 } 87 }
64 88
65 @Override 89 @Override
66 - public boolean equals(Object obj) { 90 + public Optional<DeviceId> deviceId() {
67 - if (this == obj) { 91 + if (datapathId.isPresent()) {
68 - return true; 92 + return Optional.of(DeviceId.deviceId("of:" + datapathId.get()));
93 + } else {
94 + return Optional.empty();
69 } 95 }
70 - if (obj instanceof DefaultBridgeDescription) {
71 - final DefaultBridgeDescription that = (DefaultBridgeDescription) obj;
72 - return this.getClass() == that.getClass()
73 - && Objects.equals(this.name, that.name)
74 - && Objects.equals(this.deviceId, that.deviceId)
75 - && Objects.equals(this.controllerId, that.controllerId);
76 } 96 }
77 - return false; 97 +
98 + @Override
99 + public Optional<Boolean> disableInBand() {
100 + return disableInBand;
101 + }
102 +
103 + /**
104 + * Creates and returns a new builder instance.
105 + *
106 + * @return new builder
107 + */
108 + public static BridgeDescription.Builder builder() {
109 + return new Builder();
110 + }
111 +
112 + public static final class Builder implements BridgeDescription.Builder {
113 +
114 + private String name;
115 + private List<ControllerInfo> controllers = Lists.newArrayList();
116 + private boolean enableLocalController = false;
117 + private Optional<FailMode> failMode = Optional.empty();
118 + private Optional<String> datapathId = Optional.empty();
119 + private Optional<Boolean> disableInBand = Optional.empty();
120 +
121 + private Builder() {
78 } 122 }
79 123
80 @Override 124 @Override
81 - public String toString() { 125 + public BridgeDescription build() {
82 - return MoreObjects.toStringHelper(getClass()).add("name", name) 126 + return new DefaultBridgeDescription(name, controllers,
83 - .add("deviceId", deviceId).add("controllerId", controllerId) 127 + enableLocalController,
84 - .toString(); 128 + failMode,
129 + datapathId,
130 + disableInBand);
85 } 131 }
86 132
133 + @Override
134 + public Builder name(String name) {
135 + checkArgument(!Strings.isNullOrEmpty(name));
136 + this.name = name;
137 + return this;
138 + }
139 +
140 + @Override
141 + public Builder controllers(List<ControllerInfo> controllers) {
142 + if (controllers != null) {
143 + this.controllers = Lists.newArrayList(controllers);
144 + }
145 + return this;
146 + }
147 +
148 + @Override
149 + public Builder enableLocalController() {
150 + this.enableLocalController = true;
151 + return this;
152 + }
153 +
154 + @Override
155 + public Builder failMode(FailMode failMode) {
156 + this.failMode = Optional.ofNullable(failMode);
157 + return this;
158 + }
159 +
160 + @Override
161 + public Builder datapathId(String datapathId) {
162 + this.datapathId = Optional.ofNullable(datapathId);
163 + return this;
164 + }
165 +
166 + @Override
167 + public Builder disableInBand() {
168 + this.disableInBand = Optional.of(Boolean.TRUE);
169 + return this;
170 + }
171 + }
87 } 172 }
......
...@@ -49,48 +49,74 @@ import java.util.stream.Collectors; ...@@ -49,48 +49,74 @@ import java.util.stream.Collectors;
49 public class OvsdbBridgeConfig extends AbstractHandlerBehaviour 49 public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
50 implements BridgeConfig { 50 implements BridgeConfig {
51 51
52 + @Deprecated
52 @Override 53 @Override
53 public void addBridge(BridgeName bridgeName) { 54 public void addBridge(BridgeName bridgeName) {
54 - DriverHandler handler = handler(); 55 + BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
55 - OvsdbClientService clientService = getOvsdbClientService(handler); 56 + .name(bridgeName.name())
56 - clientService.createBridge(bridgeName.name()); 57 + .build();
58 +
59 + addBridge(bridgeDesc);
57 } 60 }
58 61
62 + @Deprecated
59 @Override 63 @Override
60 public void addBridge(BridgeName bridgeName, String dpid, String exPortName) { 64 public void addBridge(BridgeName bridgeName, String dpid, String exPortName) {
61 - DriverHandler handler = handler(); 65 + BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
62 - OvsdbClientService clientService = getOvsdbClientService(handler); 66 + .name(bridgeName.name())
63 - clientService.createBridge(bridgeName.name(), dpid, exPortName); 67 + .failMode(BridgeDescription.FailMode.SECURE)
68 + .datapathId(dpid)
69 + .disableInBand()
70 + .enableLocalController()
71 + .build();
72 +
73 + addBridge(bridgeDesc);
74 +
75 + OvsdbClientService client = getOvsdbClientService(handler());
76 + client.createPort(bridgeName.name(), exPortName);
64 } 77 }
65 78
79 + @Deprecated
66 @Override 80 @Override
67 public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) { 81 public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) {
68 - DriverHandler handler = handler(); 82 + BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
69 - OvsdbClientService clientService = getOvsdbClientService(handler); 83 + .name(bridgeName.name())
70 - return clientService.createBridge(bridgeName.name(), dpid, controllers); 84 + .failMode(BridgeDescription.FailMode.SECURE)
85 + .datapathId(dpid)
86 + .disableInBand()
87 + .controllers(controllers)
88 + .build();
89 +
90 + return addBridge(bridgeDesc);
91 + }
92 +
93 + @Override
94 + public boolean addBridge(BridgeDescription bridgeDesc) {
95 + OvsdbClientService client = getOvsdbClientService(handler());
96 +
97 + OvsdbBridge.Builder bridgeBuilder = OvsdbBridge.builder(bridgeDesc);
98 + if (bridgeDesc.enableLocalController()) {
99 + bridgeBuilder.controller(client.localController());
100 + }
101 + return client.createBridge(bridgeBuilder.build());
71 } 102 }
72 103
73 @Override 104 @Override
74 public void deleteBridge(BridgeName bridgeName) { 105 public void deleteBridge(BridgeName bridgeName) {
75 - DriverHandler handler = handler(); 106 + OvsdbClientService client = getOvsdbClientService(handler());
76 - OvsdbClientService clientService = getOvsdbClientService(handler); 107 + client.dropBridge(bridgeName.name());
77 - clientService.dropBridge(bridgeName.name());
78 } 108 }
79 109
80 @Override 110 @Override
81 public Collection<BridgeDescription> getBridges() { 111 public Collection<BridgeDescription> getBridges() {
82 - DriverHandler handler = handler(); 112 + OvsdbClientService client = getOvsdbClientService(handler());
83 - DeviceId deviceId = handler.data().deviceId(); 113 + Set<OvsdbBridge> bridges = client.getBridges();
84 - OvsdbClientService clientService = getOvsdbClientService(handler);
85 - Set<OvsdbBridge> bridges = clientService.getBridges();
86 114
87 return bridges.stream() 115 return bridges.stream()
88 - .map(x -> new DefaultBridgeDescription( 116 + .map(bridge -> DefaultBridgeDescription.builder()
89 - BridgeName.bridgeName(x.bridgeName().value()), 117 + .name(bridge.name())
90 - deviceId, 118 + .datapathId(bridge.datapathId().get())
91 - DeviceId.deviceId("of:" + x.datapathId().value()) 119 + .build())
92 - )
93 - )
94 .collect(Collectors.toSet()); 120 .collect(Collectors.toSet());
95 } 121 }
96 122
...@@ -98,49 +124,42 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour ...@@ -98,49 +124,42 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
98 @Deprecated 124 @Deprecated
99 @Override 125 @Override
100 public void addPort(PortDescription port) { 126 public void addPort(PortDescription port) {
101 - DriverHandler handler = handler(); 127 + OvsdbClientService client = getOvsdbClientService(handler());
102 - OvsdbClientService clientService = getOvsdbClientService(handler); 128 + Set<OvsdbBridge> ovsdbSet = client.getBridges();
103 - Set<OvsdbBridge> ovsdbSet = clientService.getBridges();
104 if (ovsdbSet != null && ovsdbSet.size() > 0) { 129 if (ovsdbSet != null && ovsdbSet.size() > 0) {
105 OvsdbBridge bridge = ovsdbSet.iterator().next(); 130 OvsdbBridge bridge = ovsdbSet.iterator().next();
106 - clientService.createPort(bridge.bridgeName().value(), port 131 + client.createPort(bridge.name(), port.portNumber().toString());
107 - .portNumber().toString());
108 } 132 }
109 } 133 }
110 134
111 @Override 135 @Override
112 public void addPort(BridgeName bridgeName, String portName) { 136 public void addPort(BridgeName bridgeName, String portName) {
113 - DriverHandler handler = handler(); 137 + OvsdbClientService client = getOvsdbClientService(handler());
114 - OvsdbClientService clientService = getOvsdbClientService(handler); 138 + client.createPort(bridgeName.name(), portName);
115 - clientService.createPort(bridgeName.name(), portName);
116 } 139 }
117 140
118 //Deprecated from version 1.5.0 - Falcon 141 //Deprecated from version 1.5.0 - Falcon
119 @Deprecated 142 @Deprecated
120 @Override 143 @Override
121 public void deletePort(PortDescription port) { 144 public void deletePort(PortDescription port) {
122 - DriverHandler handler = handler(); 145 + OvsdbClientService client = getOvsdbClientService(handler());
123 - OvsdbClientService clientService = getOvsdbClientService(handler); 146 + Set<OvsdbBridge> ovsdbSet = client.getBridges();
124 - Set<OvsdbBridge> ovsdbSet = clientService.getBridges();
125 if (ovsdbSet != null && ovsdbSet.size() > 0) { 147 if (ovsdbSet != null && ovsdbSet.size() > 0) {
126 OvsdbBridge bridge = ovsdbSet.iterator().next(); 148 OvsdbBridge bridge = ovsdbSet.iterator().next();
127 - clientService.dropPort(bridge.bridgeName().value(), port 149 + client.dropPort(bridge.name(), port.portNumber().toString());
128 - .portNumber().toString());
129 } 150 }
130 } 151 }
131 152
132 @Override 153 @Override
133 public void deletePort(BridgeName bridgeName, String portName) { 154 public void deletePort(BridgeName bridgeName, String portName) {
134 - DriverHandler handler = handler(); 155 + OvsdbClientService client = getOvsdbClientService(handler());
135 - OvsdbClientService clientService = getOvsdbClientService(handler); 156 + client.dropPort(bridgeName.name(), portName);
136 - clientService.dropPort(bridgeName.name(), portName);
137 } 157 }
138 158
139 @Override 159 @Override
140 public Collection<PortDescription> getPorts() { 160 public Collection<PortDescription> getPorts() {
141 - DriverHandler handler = handler(); 161 + OvsdbClientService client = getOvsdbClientService(handler());
142 - OvsdbClientService clientService = getOvsdbClientService(handler); 162 + Set<OvsdbPort> ports = client.getPorts();
143 - Set<OvsdbPort> ports = clientService.getPorts();
144 163
145 return ports.stream() 164 return ports.stream()
146 .map(x -> new DefaultPortDescription( 165 .map(x -> new DefaultPortDescription(
...@@ -174,8 +193,8 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour ...@@ -174,8 +193,8 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
174 @Override 193 @Override
175 public Set<PortNumber> getPortNumbers() { 194 public Set<PortNumber> getPortNumbers() {
176 DriverHandler handler = handler(); 195 DriverHandler handler = handler();
177 - OvsdbClientService clientService = getOvsdbClientService(handler); 196 + OvsdbClientService client = getOvsdbClientService(handler);
178 - Set<OvsdbPort> ports = clientService.getPorts(); 197 + Set<OvsdbPort> ports = client.getPorts();
179 198
180 return ports.stream() 199 return ports.stream()
181 .map(x -> PortNumber.portNumber( 200 .map(x -> PortNumber.portNumber(
...@@ -190,8 +209,8 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour ...@@ -190,8 +209,8 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
190 public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) { 209 public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) {
191 List<PortNumber> ports = new ArrayList<>(); 210 List<PortNumber> ports = new ArrayList<>();
192 DriverHandler handler = handler(); 211 DriverHandler handler = handler();
193 - OvsdbClientService clientService = getOvsdbClientService(handler); 212 + OvsdbClientService client = getOvsdbClientService(handler);
194 - Set<OvsdbPort> ovsdbSet = clientService.getLocalPorts(ifaceIds); 213 + Set<OvsdbPort> ovsdbSet = client.getLocalPorts(ifaceIds);
195 ovsdbSet.forEach(o -> { 214 ovsdbSet.forEach(o -> {
196 PortNumber port = PortNumber.portNumber(o.portNumber().value(), 215 PortNumber port = PortNumber.portNumber(o.portNumber().value(),
197 o.portName().value()); 216 o.portName().value());
......
...@@ -36,6 +36,7 @@ import java.util.List; ...@@ -36,6 +36,7 @@ import java.util.List;
36 import java.util.Set; 36 import java.util.Set;
37 import java.util.stream.Collectors; 37 import java.util.stream.Collectors;
38 38
39 +import static com.google.common.base.Preconditions.checkArgument;
39 import static com.google.common.base.Preconditions.checkState; 40 import static com.google.common.base.Preconditions.checkState;
40 import static org.onlab.util.Tools.delay; 41 import static org.onlab.util.Tools.delay;
41 42
...@@ -96,7 +97,9 @@ public class OvsdbControllerConfig extends AbstractHandlerBehaviour implements C ...@@ -96,7 +97,9 @@ public class OvsdbControllerConfig extends AbstractHandlerBehaviour implements C
96 } 97 }
97 98
98 private static boolean dpidMatches(OvsdbBridge bridge, DeviceId deviceId) { 99 private static boolean dpidMatches(OvsdbBridge bridge, DeviceId deviceId) {
99 - String bridgeDpid = "of:" + bridge.datapathId().value(); 100 + checkArgument(bridge.datapathId().isPresent());
101 +
102 + String bridgeDpid = "of:" + bridge.datapathId().get();
100 String ofDpid = deviceId.toString(); 103 String ofDpid = deviceId.toString();
101 return bridgeDpid.equals(ofDpid); 104 return bridgeDpid.equals(ofDpid);
102 } 105 }
......
...@@ -15,32 +15,55 @@ ...@@ -15,32 +15,55 @@
15 */ 15 */
16 package org.onosproject.ovsdb.controller; 16 package org.onosproject.ovsdb.controller;
17 17
18 +import com.google.common.collect.Lists;
19 +import com.google.common.collect.Maps;
20 +import org.onosproject.net.behaviour.BridgeDescription;
21 +import org.onosproject.net.behaviour.BridgeDescription.FailMode;
22 +import org.onosproject.net.behaviour.ControllerInfo;
23 +
18 import static com.google.common.base.MoreObjects.toStringHelper; 24 import static com.google.common.base.MoreObjects.toStringHelper;
19 -import static com.google.common.base.Preconditions.checkNotNull; 25 +import static org.onosproject.ovsdb.controller.OvsdbConstant.DATAPATH_ID;
26 +import static org.onosproject.ovsdb.controller.OvsdbConstant.DISABLE_INBAND;
20 27
28 +import java.util.List;
29 +import java.util.Map;
21 import java.util.Objects; 30 import java.util.Objects;
31 +import java.util.Optional;
32 +
33 +import static com.google.common.base.Preconditions.checkNotNull;
22 34
23 /** 35 /**
24 - * The class representing an ovsdb bridge. 36 + * The class representing an OVSDB bridge.
25 * This class is immutable. 37 * This class is immutable.
26 */ 38 */
27 public final class OvsdbBridge { 39 public final class OvsdbBridge {
28 40
29 - private final OvsdbBridgeName bridgeName; 41 + private final String name;
30 - private final OvsdbDatapathId datapathId; 42 +
43 + /* OpenFlow properties */
44 + private final Optional<FailMode> failMode;
45 + private final List<ControllerInfo> controllers;
46 +
47 + /* Adds more properties */
48 +
49 + /* other optional configs */
50 + private final Map<String, String> otherConfigs;
31 51
32 /** 52 /**
33 - * Constructor from an OvsdbBridgeName bridgeName and an OvsdbDatapathId 53 + * Default constructor.
34 - * datapathId.
35 * 54 *
36 - * @param bridgeName the bridgeName to use 55 + * @param name name of the bridge
37 - * @param datapathId the datapathId to use 56 + * @param failMode openflow controller fail mode policy
57 + * @param controllers list of openflow controllers
58 + * @param otherConfigs other configs
38 */ 59 */
39 - public OvsdbBridge(OvsdbBridgeName bridgeName, OvsdbDatapathId datapathId) { 60 + private OvsdbBridge(String name, Optional<FailMode> failMode,
40 - checkNotNull(bridgeName, "bridgeName is not null"); 61 + List<ControllerInfo> controllers,
41 - checkNotNull(datapathId, "datapathId is not null"); 62 + Map<String, String> otherConfigs) {
42 - this.bridgeName = bridgeName; 63 + this.name = checkNotNull(name);
43 - this.datapathId = datapathId; 64 + this.failMode = failMode;
65 + this.controllers = controllers;
66 + this.otherConfigs = otherConfigs;
44 } 67 }
45 68
46 /** 69 /**
...@@ -48,22 +71,49 @@ public final class OvsdbBridge { ...@@ -48,22 +71,49 @@ public final class OvsdbBridge {
48 * 71 *
49 * @return the bridge name of bridge 72 * @return the bridge name of bridge
50 */ 73 */
51 - public OvsdbBridgeName bridgeName() { 74 + public String name() {
52 - return bridgeName; 75 + return name;
76 + }
77 +
78 + /**
79 + * Returns the controllers of the bridge.
80 + *
81 + * @return list of controllers
82 + */
83 + public List<ControllerInfo> controllers() {
84 + return controllers;
85 + }
86 +
87 + /**
88 + * Returns fail mode of the bridge.
89 + *
90 + * @return fail mode
91 + */
92 + public Optional<FailMode> failMode() {
93 + return failMode;
94 + }
95 +
96 + /**
97 + * Returns other configurations of the bridge.
98 + *
99 + * @return map of configurations
100 + */
101 + public Map<String, String> otherConfigs() {
102 + return otherConfigs;
53 } 103 }
54 104
55 /** 105 /**
56 * Gets the datapathId of bridge. 106 * Gets the datapathId of bridge.
57 * 107 *
58 - * @return datapathId the datapathId to use 108 + * @return datapath id; null if not used
59 */ 109 */
60 - public OvsdbDatapathId datapathId() { 110 + public Optional<String> datapathId() {
61 - return datapathId; 111 + return Optional.ofNullable(otherConfigs.get(DATAPATH_ID));
62 } 112 }
63 113
64 @Override 114 @Override
65 public int hashCode() { 115 public int hashCode() {
66 - return Objects.hash(bridgeName, datapathId); 116 + return Objects.hash(name);
67 } 117 }
68 118
69 @Override 119 @Override
...@@ -73,16 +123,154 @@ public final class OvsdbBridge { ...@@ -73,16 +123,154 @@ public final class OvsdbBridge {
73 } 123 }
74 if (obj instanceof OvsdbBridge) { 124 if (obj instanceof OvsdbBridge) {
75 final OvsdbBridge otherOvsdbBridge = (OvsdbBridge) obj; 125 final OvsdbBridge otherOvsdbBridge = (OvsdbBridge) obj;
76 - return Objects.equals(this.bridgeName, otherOvsdbBridge.bridgeName) 126 + return Objects.equals(this.name, otherOvsdbBridge.name);
77 - && Objects.equals(this.datapathId,
78 - otherOvsdbBridge.datapathId);
79 } 127 }
80 return false; 128 return false;
81 } 129 }
82 130
83 @Override 131 @Override
84 public String toString() { 132 public String toString() {
85 - return toStringHelper(this).add("bridgeName", bridgeName.value()) 133 + return toStringHelper(this)
86 - .add("datapathId", datapathId.value()).toString(); 134 + .add("bridgeName", name)
135 + .add("failMode", failMode)
136 + .add("controllers", controllers)
137 + .add("otherConfigs", otherConfigs)
138 + .toString();
139 + }
140 +
141 + /**
142 + * Returns a new builder instance.
143 + *
144 + * @return ovsdb bridge builder
145 + */
146 + public static OvsdbBridge.Builder builder() {
147 + return new Builder();
148 + }
149 +
150 + /**
151 + * Returns OVSDB bridge object with a given bridge description.
152 + *
153 + * @param bridgeDesc bridge description
154 + * @return ovsdb bridge
155 + */
156 + public static OvsdbBridge.Builder builder(BridgeDescription bridgeDesc) {
157 + return new Builder(bridgeDesc);
158 + }
159 +
160 + /**
161 + * Builder of OVSDB bridge entities.
162 + */
163 + public static final class Builder {
164 + private String name;
165 + private Optional<FailMode> failMode = Optional.empty();
166 + private List<ControllerInfo> controllers = Lists.newArrayList();
167 + private Map<String, String> otherConfigs = Maps.newHashMap();
168 +
169 + private Builder() {
170 + }
171 +
172 + /**
173 + * Constructs OVSDB bridge builder with a given bridge description.
174 + *
175 + * @param bridgeDesc bridge description
176 + */
177 + private Builder(BridgeDescription bridgeDesc) {
178 + if (bridgeDesc.datapathId().isPresent()) {
179 + otherConfigs.put(DATAPATH_ID, bridgeDesc.datapathId().get());
180 + }
181 + if (bridgeDesc.disableInBand().isPresent()) {
182 + otherConfigs.put(DISABLE_INBAND,
183 + bridgeDesc.disableInBand().get().toString());
184 + }
185 +
186 + this.name = bridgeDesc.name();
187 + this.failMode = bridgeDesc.failMode();
188 + this.controllers = Lists.newArrayList(bridgeDesc.controllers());
189 + }
190 +
191 + /**
192 + * Builds an immutable OVSDB bridge.
193 + *
194 + * @return ovsdb bridge
195 + */
196 + public OvsdbBridge build() {
197 + return new OvsdbBridge(name, failMode, controllers, otherConfigs);
198 + }
199 +
200 + /**
201 + * Returns OVSDB bridge builder with a given name.
202 + *
203 + * @param name name of the bridge
204 + * @return ovsdb bridge builder
205 + */
206 + public Builder name(String name) {
207 + this.name = name;
208 + return this;
209 + }
210 +
211 + /**
212 + * Returns OVSDB bridge builder with a given fail mode.
213 + *
214 + * @param failMode fail mode
215 + * @return ovsdb bridge builder
216 + */
217 + public Builder failMode(FailMode failMode) {
218 + this.failMode = Optional.ofNullable(failMode);
219 + return this;
220 + }
221 +
222 + /**
223 + * Returns OVSDB bridge builder with given controllers.
224 + *
225 + * @param controllers list of controllers
226 + * @return ovsdb bridge builder
227 + */
228 + public Builder controllers(List<ControllerInfo> controllers) {
229 + this.controllers = Lists.newArrayList(controllers);
230 + return this;
231 + }
232 +
233 + /**
234 + * Returns OVSDB bridge builder with a given controller.
235 + *
236 + * @param controller controller
237 + * @return ovsdb bridge builder
238 + */
239 + public Builder controller(ControllerInfo controller) {
240 + this.controllers = Lists.newArrayList(controller);
241 + return this;
242 + }
243 +
244 + /**
245 + * Returns OVSDB bridge builder with given configs.
246 + *
247 + * @param otherConfigs other configs
248 + * @return ovsdb bridge builder
249 + */
250 + public Builder otherConfigs(Map<String, String> otherConfigs) {
251 + this.otherConfigs = Maps.newHashMap(otherConfigs);
252 + return this;
253 + }
254 +
255 + /**
256 + * Returns OVSDB bridge builder with a given datapath ID.
257 + *
258 + * @param datapathId datapath id
259 + * @return ovsdb bridge builder
260 + */
261 + public Builder datapathId(String datapathId) {
262 + otherConfigs.put(DATAPATH_ID, datapathId);
263 + return this;
264 + }
265 +
266 + /**
267 + * Returns OVSDB bridge builder with a given disable in-band config.
268 + *
269 + * @return ovsdb bridge builder
270 + */
271 + public Builder disableInBand() {
272 + otherConfigs.put(DATAPATH_ID, Boolean.TRUE.toString());
273 + return this;
274 + }
87 } 275 }
88 } 276 }
......
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 -/**
24 - * The class representing a bridge name.
25 - * This class is immutable.
26 - */
27 -public final class OvsdbBridgeName {
28 -
29 - private final String value;
30 -
31 - /**
32 - * Constructor from a String.
33 - *
34 - * @param value the bridge name to use
35 - */
36 - public OvsdbBridgeName(String value) {
37 - checkNotNull(value, "value is not null");
38 - this.value = value;
39 - }
40 -
41 - /**
42 - * Gets the value of bridge name.
43 - *
44 - * @return the value of the bridge name
45 - */
46 - public String value() {
47 - return value;
48 - }
49 -
50 - @Override
51 - public int hashCode() {
52 - return value.hashCode();
53 - }
54 -
55 - @Override
56 - public boolean equals(Object obj) {
57 - if (this == obj) {
58 - return true;
59 - }
60 - if (obj instanceof OvsdbBridgeName) {
61 - final OvsdbBridgeName otherBridgeName = (OvsdbBridgeName) obj;
62 - return Objects.equals(this.value, otherBridgeName.value);
63 - }
64 - return false;
65 - }
66 -
67 - @Override
68 - public String toString() {
69 - return toStringHelper(this).add("value", value).toString();
70 - }
71 -
72 -}
...@@ -72,31 +72,45 @@ public interface OvsdbClientService extends OvsdbRpc { ...@@ -72,31 +72,45 @@ public interface OvsdbClientService extends OvsdbRpc {
72 /** 72 /**
73 * Creates a bridge. 73 * Creates a bridge.
74 * 74 *
75 + * @deprecated version 1.7.0 - Hummingbird
75 * @param bridgeName bridge name 76 * @param bridgeName bridge name
76 */ 77 */
78 + @Deprecated
77 void createBridge(String bridgeName); 79 void createBridge(String bridgeName);
78 80
79 /** 81 /**
80 * Creates a bridge. 82 * Creates a bridge.
81 * 83 *
84 + * @deprecated version 1.7.0 - Hummingbird
82 * @param bridgeName bridge name 85 * @param bridgeName bridge name
83 * @param dpid data path id 86 * @param dpid data path id
84 * @param exPortName external port name 87 * @param exPortName external port name
85 */ 88 */
89 + @Deprecated
86 void createBridge(String bridgeName, String dpid, String exPortName); 90 void createBridge(String bridgeName, String dpid, String exPortName);
87 91
88 /** 92 /**
89 * Creates a bridge with given name and dpid. 93 * Creates a bridge with given name and dpid.
90 * Sets the bridge's controller with given controllers. 94 * Sets the bridge's controller with given controllers.
91 * 95 *
96 + * @deprecated version 1.7.0 - Hummingbird
92 * @param bridgeName bridge name 97 * @param bridgeName bridge name
93 * @param dpid data path id 98 * @param dpid data path id
94 * @param controllers controllers 99 * @param controllers controllers
95 * @return true if bridge creation is successful, false otherwise 100 * @return true if bridge creation is successful, false otherwise
96 */ 101 */
102 + @Deprecated
97 boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers); 103 boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers);
98 104
99 /** 105 /**
106 + * Creates a bridge with a given bridge description.
107 + *
108 + * @param ovsdbBridge ovsdb bridge description
109 + * @return true if bridge creation is successful, otherwise false
110 + */
111 + boolean createBridge(OvsdbBridge ovsdbBridge);
112 +
113 + /**
100 * Drops a bridge. 114 * Drops a bridge.
101 * 115 *
102 * @param bridgeName bridge name 116 * @param bridgeName bridge name
...@@ -119,6 +133,15 @@ public interface OvsdbClientService extends OvsdbRpc { ...@@ -119,6 +133,15 @@ public interface OvsdbClientService extends OvsdbRpc {
119 Set<ControllerInfo> getControllers(DeviceId openflowDeviceId); 133 Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
120 134
121 /** 135 /**
136 + * Returns local controller information.
137 + * The connection is a TCP connection to the local ONOS instance's IP
138 + * and the default OpenFlow port.
139 + *
140 + * @return local controller
141 + */
142 + ControllerInfo localController();
143 +
144 + /**
122 * Sets the Controllers for the specified bridge. 145 * Sets the Controllers for the specified bridge.
123 * <p> 146 * <p>
124 * This method will replace the existing controller list with the new controller 147 * This method will replace the existing controller list with the new controller
......
...@@ -29,40 +29,46 @@ public final class OvsdbConstant { ...@@ -29,40 +29,46 @@ public final class OvsdbConstant {
29 private OvsdbConstant() { 29 private OvsdbConstant() {
30 } 30 }
31 31
32 + /** Common column names. */
33 + public static final String UUID = "_uuid";
34 +
32 /** Ovsdb database Open_vSwitch. */ 35 /** Ovsdb database Open_vSwitch. */
33 public static final String DATABASENAME = "Open_vSwitch"; 36 public static final String DATABASENAME = "Open_vSwitch";
34 37
35 - /** Ovsdb table Bridge. */ 38 + /** Open_vSwitch table. */
39 + public static final String BRIDGES = "bridges";
40 +
41 + /** Bridge table. */
36 public static final String BRIDGE = "Bridge"; 42 public static final String BRIDGE = "Bridge";
43 + public static final String PORTS = "ports";
44 + // other configs
45 + public static final String DATAPATH_ID = "datapath-id";
46 + public static final String DISABLE_INBAND = "disable-in-band";
37 47
38 - /** Ovsdb table Interface. */ 48 + /** Interface table. */
39 public static final String INTERFACE = "Interface"; 49 public static final String INTERFACE = "Interface";
50 + // type
51 + public static final String TYPEVXLAN = "vxlan";
52 + // virtual machine identifiers
53 + public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id";
54 + public static final String EXTERNAL_ID_VM_MAC = "attached-mac";
40 55
41 - /** Ovsdb table Controller. */ 56 + /** Controller table. */
42 public static final String CONTROLLER = "Controller"; 57 public static final String CONTROLLER = "Controller";
43 58
44 - /** Ovsdb table Port. */ 59 + /** Port table. */
45 public static final String PORT = "Port"; 60 public static final String PORT = "Port";
46 61
47 /** Ovsdb bridge name. */ 62 /** Ovsdb bridge name. */
63 + // TODO remove this particular bridge name from OVSDB provider
48 public static final String INTEGRATION_BRIDGE = "br-int"; 64 public static final String INTEGRATION_BRIDGE = "br-int";
49 65
50 - /** Ovsdb vxlan tunnel type. */
51 - public static final String TYPEVXLAN = "vxlan";
52 -
53 /** Openflow version. */ 66 /** Openflow version. */
54 public static final String OPENFLOW13 = "OpenFlow13"; 67 public static final String OPENFLOW13 = "OpenFlow13";
55 68
56 - /** Ovsdb external_id_interface_id.. */
57 - public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id";
58 -
59 - /** Ovsdb external_id_vm_mac. */
60 - public static final String EXTERNAL_ID_VM_MAC = "attached-mac";
61 -
62 /** Openflow port. */ 69 /** Openflow port. */
63 public static final int OFPORT = 6653; 70 public static final int OFPORT = 6653;
64 71
65 /** Ovsdb port. */ 72 /** Ovsdb port. */
66 public static final int OVSDBPORT = 6640; 73 public static final int OVSDBPORT = 6640;
67 -
68 } 74 }
......
...@@ -74,6 +74,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { ...@@ -74,6 +74,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService {
74 } 74 }
75 75
76 @Override 76 @Override
77 + public boolean createBridge(OvsdbBridge ovsdbBridge) {
78 + return true;
79 + }
80 +
81 + @Override
77 public void dropBridge(String bridgeName) { 82 public void dropBridge(String bridgeName) {
78 83
79 } 84 }
...@@ -89,6 +94,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { ...@@ -89,6 +94,11 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService {
89 } 94 }
90 95
91 @Override 96 @Override
97 + public ControllerInfo localController() {
98 + return null;
99 + }
100 +
101 + @Override
92 public void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers) { 102 public void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers) {
93 103
94 } 104 }
......