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