Use netconf-3.0.5
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / transactions / md / OvsdbBridgeUpdateCommand.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.southbound.transactions.md;
9
10 import static java.util.Objects.requireNonNull;
11 import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog;
12
13 import com.google.common.annotations.VisibleForTesting;
14 import com.google.common.net.InetAddresses;
15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16 import java.net.InetAddress;
17 import java.net.NetworkInterface;
18 import java.net.SocketException;
19 import java.util.ArrayList;
20 import java.util.Enumeration;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.Map.Entry;
24 import java.util.Optional;
25 import java.util.Set;
26 import org.apache.commons.lang3.math.NumberUtils;
27 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
28 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
29 import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
30 import org.opendaylight.ovsdb.lib.message.TableUpdates;
31 import org.opendaylight.ovsdb.lib.notation.UUID;
32 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
33 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
34 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
35 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
36 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
37 import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
38 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
39 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
40 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIdsBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIdsKey;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsKey;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntryKey;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntryBuilder;
63 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
64 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
65 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
66 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
67 import org.opendaylight.yangtools.yang.binding.DataObject;
68 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
69 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
70 import org.slf4j.Logger;
71 import org.slf4j.LoggerFactory;
72
73 public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
74     private static final Logger LOG = LoggerFactory.getLogger(OvsdbBridgeUpdateCommand.class);
75     private final InstanceIdentifierCodec instanceIdentifierCodec;
76     private final Map<UUID,Bridge> updatedBridgeRows;
77     private final Map<UUID, Bridge> oldBridgeRows;
78     private final List<InstanceIdentifier<Node>> updatedBridges = new ArrayList<>();
79     private final Map<NodeId, Node> updatedBridgeNodes;
80
81     @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for mocking")
82     public OvsdbBridgeUpdateCommand(InstanceIdentifierCodec instanceIdentifierCodec, OvsdbConnectionInstance key,
83             TableUpdates updates, DatabaseSchema dbSchema,
84                                     Map<NodeId, Node> updatedBridgeNodes) {
85         super(key,updates,dbSchema);
86         this.instanceIdentifierCodec = instanceIdentifierCodec;
87         updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema());
88         oldBridgeRows = TyperUtils.extractRowsOld(Bridge.class, getUpdates(), getDbSchema());
89         this.updatedBridgeNodes = updatedBridgeNodes;
90     }
91
92     @Override
93     public void execute(ReadWriteTransaction transaction) {
94         if (updatedBridgeRows == null || updatedBridgeRows.isEmpty()) {
95             return;
96         }
97
98         final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
99         Optional<Node> connection = SouthboundUtil.readNode(transaction, connectionIId);
100         if (!connection.isPresent()) {
101             return;
102         }
103
104         for (Entry<UUID, Bridge> entry : updatedBridgeRows.entrySet()) {
105             updateBridge(transaction, entry.getValue(), connectionIId);
106         }
107     }
108
109     @VisibleForTesting
110     void updateBridge(ReadWriteTransaction transaction,
111             Bridge bridge, InstanceIdentifier<Node> connectionIId) {
112         // Update the connection node to let it know it manages this bridge
113         Node connectionNode = buildConnectionNode(bridge);
114         transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
115
116         // Update the bridge node with whatever data we are getting
117         InstanceIdentifier<Node> bridgeIid = getInstanceIdentifier(bridge);
118         Node bridgeNode = buildBridgeNode(bridge);
119         transaction.merge(LogicalDatastoreType.OPERATIONAL, bridgeIid, bridgeNode);
120         updatedBridges.add(bridgeIid);
121         updatedBridgeNodes.put(getNodeId(bridge), bridgeNode);
122         deleteEntries(transaction, protocolEntriesToRemove(bridgeIid, bridge));
123         deleteEntries(transaction, externalIdsToRemove(bridgeIid,bridge));
124         deleteEntries(transaction, bridgeOtherConfigsToRemove(bridgeIid,bridge));
125     }
126
127     @VisibleForTesting
128     <T extends DataObject> void deleteEntries(ReadWriteTransaction transaction,
129             List<InstanceIdentifier<T>> entryIids) {
130         for (InstanceIdentifier<T> entryIid : entryIids) {
131             transaction.delete(LogicalDatastoreType.OPERATIONAL, entryIid);
132         }
133     }
134
135     private List<InstanceIdentifier<BridgeOtherConfigs>> bridgeOtherConfigsToRemove(
136             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
137         requireNonNull(bridgeIid);
138         requireNonNull(bridge);
139         List<InstanceIdentifier<BridgeOtherConfigs>> result = new ArrayList<>();
140
141         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
142
143         if (oldBridge != null && oldBridge.getOtherConfigColumn() != null) {
144             for (Entry<String, String> otherConfig:
145                 oldBridge.getOtherConfigColumn().getData().entrySet()) {
146                 if (bridge.getOtherConfigColumn() == null
147                         || !bridge.getOtherConfigColumn().getData().containsKey(otherConfig.getKey())) {
148                     InstanceIdentifier<BridgeOtherConfigs> iid = bridgeIid
149                             .augmentation(OvsdbBridgeAugmentation.class)
150                             .child(BridgeOtherConfigs.class,
151                                     new BridgeOtherConfigsKey(otherConfig.getKey()));
152                     result.add(iid);
153                 }
154             }
155         }
156         return result;
157     }
158
159     private List<InstanceIdentifier<BridgeExternalIds>> externalIdsToRemove(
160             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
161         requireNonNull(bridgeIid);
162         requireNonNull(bridge);
163         List<InstanceIdentifier<BridgeExternalIds>> result = new ArrayList<>();
164
165         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
166
167         if (oldBridge != null && oldBridge.getExternalIdsColumn() != null) {
168             for (Entry<String, String> externalId:
169                 oldBridge.getExternalIdsColumn().getData().entrySet()) {
170                 if (bridge.getExternalIdsColumn() == null
171                         || !bridge.getExternalIdsColumn().getData().containsKey(externalId.getKey())) {
172                     InstanceIdentifier<BridgeExternalIds> iid = bridgeIid
173                             .augmentation(OvsdbBridgeAugmentation.class)
174                             .child(BridgeExternalIds.class,
175                                     new BridgeExternalIdsKey(externalId.getKey()));
176                     result.add(iid);
177                 }
178             }
179         }
180         return result;
181     }
182
183     private List<InstanceIdentifier<ProtocolEntry>> protocolEntriesToRemove(
184             InstanceIdentifier<Node> bridgeIid, Bridge bridge) {
185         requireNonNull(bridgeIid);
186         requireNonNull(bridge);
187         List<InstanceIdentifier<ProtocolEntry>> result = new ArrayList<>();
188         Bridge oldBridge = oldBridgeRows.get(bridge.getUuid());
189
190         try {
191             if (oldBridge != null && oldBridge.getProtocolsColumn() != null) {
192                 for (String protocol : oldBridge.getProtocolsColumn().getData()) {
193                     if (bridge.getProtocolsColumn() == null || !bridge.getProtocolsColumn().getData()
194                                 .contains(protocol)) {
195                         Class<? extends OvsdbBridgeProtocolBase> proto = SouthboundConstants.OVSDB_PROTOCOL_MAP
196                                 .inverse().get(protocol);
197                         InstanceIdentifier<ProtocolEntry> iid = bridgeIid
198                                 .augmentation(OvsdbBridgeAugmentation.class)
199                                 .child(ProtocolEntry.class,
200                                         new ProtocolEntryKey(proto));
201                         result.add(iid);
202                     }
203                 }
204             }
205         } catch (SchemaVersionMismatchException e) {
206             schemaMismatchLog("protocols", "Bridge", e);
207         }
208         return result;
209     }
210
211     private Node buildConnectionNode(
212             Bridge bridge) {
213         //Update node with managed node reference
214         NodeBuilder connectionNode = new NodeBuilder();
215         connectionNode.setNodeId(getOvsdbConnectionInstance().getNodeId());
216
217         OvsdbNodeAugmentationBuilder ovsdbConnectionAugmentationBuilder = new OvsdbNodeAugmentationBuilder();
218         InstanceIdentifier<Node> bridgeIid =
219                 SouthboundMapper.createInstanceIdentifier(instanceIdentifierCodec, getOvsdbConnectionInstance(),
220                         bridge);
221         ManagedNodeEntry managedBridge = new ManagedNodeEntryBuilder().setBridgeRef(
222                 new OvsdbBridgeRef(bridgeIid)).build();
223         ovsdbConnectionAugmentationBuilder.setManagedNodeEntry(BindingMap.of(managedBridge));
224
225         connectionNode.addAugmentation(ovsdbConnectionAugmentationBuilder.build());
226
227         LOG.debug("Update node with bridge node ref {}",
228                 ovsdbConnectionAugmentationBuilder.getManagedNodeEntry().values().iterator().next());
229         return connectionNode.build();
230     }
231
232     private Node buildBridgeNode(Bridge bridge) {
233         NodeBuilder bridgeNodeBuilder = new NodeBuilder();
234         NodeId bridgeNodeId = getNodeId(bridge);
235         bridgeNodeBuilder.setNodeId(bridgeNodeId);
236         OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
237         ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridge.getName()));
238         ovsdbBridgeAugmentationBuilder.setBridgeUuid(new Uuid(bridge.getUuid().toString()));
239         setDataPath(ovsdbBridgeAugmentationBuilder, bridge);
240         setDataPathType(ovsdbBridgeAugmentationBuilder, bridge);
241         setProtocol(ovsdbBridgeAugmentationBuilder, bridge);
242         setExternalIds(ovsdbBridgeAugmentationBuilder, bridge);
243         setOtherConfig(ovsdbBridgeAugmentationBuilder, bridge);
244         setFailMode(ovsdbBridgeAugmentationBuilder, bridge);
245         setOpenFlowNodeRef(ovsdbBridgeAugmentationBuilder, bridge);
246         setManagedBy(ovsdbBridgeAugmentationBuilder);
247         setAutoAttach(ovsdbBridgeAugmentationBuilder, bridge);
248         setStpEnalbe(ovsdbBridgeAugmentationBuilder,bridge);
249         bridgeNodeBuilder.addAugmentation(ovsdbBridgeAugmentationBuilder.build());
250
251         LOG.debug("Built with the intent to store bridge data {}",
252                 ovsdbBridgeAugmentationBuilder.build());
253         return bridgeNodeBuilder.build();
254     }
255
256     private static void setAutoAttach(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
257         try {
258             if (bridge.getAutoAttachColumn() != null
259                     && bridge.getAutoAttachColumn().getData() != null
260                     && !bridge.getAutoAttachColumn().getData().isEmpty()) {
261                 Set<UUID> uuids = bridge.getAutoAttachColumn().getData();
262                 for (UUID uuid : uuids) {
263                     ovsdbBridgeAugmentationBuilder.setAutoAttach(new Uuid(uuid.toString()));
264                 }
265             }
266         } catch (SchemaVersionMismatchException e) {
267             schemaMismatchLog("auto_attach", "Bridge", e);
268         }
269     }
270
271     private void setManagedBy(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder) {
272         InstanceIdentifier<Node> connectionNodePath = getOvsdbConnectionInstance().getInstanceIdentifier();
273         ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
274     }
275
276     private static void setDataPathType(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
277         ovsdbBridgeAugmentationBuilder.setDatapathType(
278                 SouthboundMapper.createDatapathType(bridge.getDatapathTypeColumn().getData()));
279     }
280
281     private static void setFailMode(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
282         if (bridge.getFailModeColumn() != null
283                 && bridge.getFailModeColumn().getData() != null
284                 && !bridge.getFailModeColumn().getData().isEmpty()) {
285             String[] failmodeArray = new String[bridge.getFailModeColumn().getData().size()];
286             bridge.getFailModeColumn().getData().toArray(failmodeArray);
287             ovsdbBridgeAugmentationBuilder.setFailMode(
288                     SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get(failmodeArray[0]));
289         }
290     }
291
292     @VisibleForTesting
293     static void setOtherConfig(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
294         Map<String, String> otherConfigs = bridge
295                 .getOtherConfigColumn().getData();
296         if (otherConfigs != null && !otherConfigs.isEmpty()) {
297             var otherConfigList = BindingMap.<BridgeOtherConfigsKey, BridgeOtherConfigs>orderedBuilder();
298             for (Entry<String, String> entry : otherConfigs.entrySet()) {
299                 String otherConfigKey = entry.getKey();
300                 String otherConfigValue = entry.getValue();
301                 if (otherConfigKey != null && otherConfigValue != null) {
302                     otherConfigList.add(new BridgeOtherConfigsBuilder()
303                             .setBridgeOtherConfigKey(otherConfigKey)
304                             .setBridgeOtherConfigValue(otherConfigValue)
305                             .build());
306                 }
307             }
308             ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigList.build());
309         }
310     }
311
312     @VisibleForTesting
313     static void setExternalIds(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
314         Map<String, String> externalIds = bridge.getExternalIdsColumn().getData();
315         if (externalIds != null && !externalIds.isEmpty()) {
316             var externalIdsList = BindingMap.<BridgeExternalIdsKey, BridgeExternalIds>orderedBuilder();
317             for (Entry<String, String> entry : externalIds.entrySet()) {
318                 String externalIdKey = entry.getKey();
319                 String externalIdValue = entry.getValue();
320                 if (externalIdKey != null && externalIdValue != null) {
321                     externalIdsList.add(new BridgeExternalIdsBuilder()
322                             .setBridgeExternalIdKey(externalIdKey)
323                             .setBridgeExternalIdValue(externalIdValue)
324                             .build());
325                 }
326             }
327             ovsdbBridgeAugmentationBuilder.setBridgeExternalIds(externalIdsList.build());
328         }
329     }
330
331     @VisibleForTesting
332     static void setProtocol(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
333         List<ProtocolEntry> protocols = SouthboundMapper.createMdsalProtocols(bridge);
334         if (!protocols.isEmpty()) {
335             ovsdbBridgeAugmentationBuilder.setProtocolEntry(BindingMap.of(protocols));
336         }
337     }
338
339     @VisibleForTesting
340     static void setDataPath(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
341         DatapathId dpid = SouthboundMapper.createDatapathId(bridge);
342         if (dpid != null) {
343             ovsdbBridgeAugmentationBuilder.setDatapathId(dpid);
344         }
345     }
346
347     private static void setStpEnalbe(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder,
348                               Bridge bridge) {
349         if (bridge.getStpEnableColumn() != null) {
350             Boolean stpEnable = bridge.getStpEnableColumn().getData();
351             if (stpEnable != null) {
352                 ovsdbBridgeAugmentationBuilder.setStpEnable(stpEnable);
353             }
354         }
355     }
356
357     private void setOpenFlowNodeRef(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder, Bridge bridge) {
358         Map<UUID, Controller> updatedControllerRows =
359                 TyperUtils.extractRowsUpdated(Controller.class, getUpdates(), getDbSchema());
360         LOG.debug("setOpenFlowNodeRef: updatedControllerRows: {}", updatedControllerRows);
361         for (ControllerEntry controllerEntry: SouthboundMapper.createControllerEntries(bridge, updatedControllerRows)) {
362             if (controllerEntry != null
363                 && controllerEntry.getIsConnected() != null && controllerEntry.getIsConnected()) {
364                 String [] controllerTarget = controllerEntry.getTarget().getValue().split(":");
365                 IpAddress bridgeControllerIpAddress = null;
366                 for (String targetElement : controllerTarget) {
367                     if (InetAddresses.isInetAddress(targetElement)) {
368                         bridgeControllerIpAddress = IpAddressBuilder.getDefaultInstance(targetElement);
369                         continue;
370                     }
371                     if (NumberUtils.isCreatable(targetElement)) {
372                         continue;
373                     }
374                 }
375                 try {
376                     Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
377                 networkInterfacesLoop:
378                     while (networkInterfaces.hasMoreElements()) {
379                         NetworkInterface networkInterface = networkInterfaces.nextElement();
380                         Enumeration<InetAddress> networkInterfaceAddresses = networkInterface.getInetAddresses();
381                         while (networkInterfaceAddresses.hasMoreElements()) {
382                             InetAddress networkInterfaceAddress = networkInterfaceAddresses.nextElement();
383                             if (bridgeControllerIpAddress.getIpv4Address().getValue()
384                                     .equals(networkInterfaceAddress.getHostAddress())) {
385                                 ovsdbBridgeAugmentationBuilder.setBridgeOpenflowNodeRef(
386                                         getOvsdbConnectionInstance().getInstanceIdentifier());
387                                 break networkInterfacesLoop;
388                             }
389                         }
390                     }
391                 } catch (SocketException e) {
392                     LOG.warn("Error getting local ip address", e);
393                 }
394             }
395         }
396     }
397
398     private InstanceIdentifier<Node> getInstanceIdentifier(Bridge bridge) {
399         return SouthboundMapper.createInstanceIdentifier(instanceIdentifierCodec, getOvsdbConnectionInstance(),
400                 bridge);
401     }
402
403     private NodeId getNodeId(Bridge bridge) {
404         NodeKey nodeKey = getInstanceIdentifier(bridge).firstKeyOf(Node.class);
405         return nodeKey.getNodeId();
406     }
407
408     @Override
409     public void onSuccess() {
410         for (InstanceIdentifier<Node> updatedBridge : updatedBridges) {
411             LOG.debug("Updated bridge {} in operational datastore", updatedBridge);
412         }
413     }
414
415     @Override
416     public void onFailure(Throwable throwable) {
417         for (InstanceIdentifier<Node> updatedBridge : updatedBridges) {
418             LOG.error("Failed to update bridge {} in operational datastore", updatedBridge);
419         }
420     }
421 }