Merge "HwVTEP JUNITs, and fixing show:vxlan CLI"
[vpnservice.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / vpnservice / utils / hwvtep / HwvtepUtils.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.vpnservice.utils.hwvtep;
10
11 import java.util.List;
12
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsKey;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
31 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
32 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
33 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
34 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
35 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
37 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
38
39 import com.google.common.base.Optional;
40 import com.google.common.util.concurrent.ListenableFuture;
41
42 /**
43  * Utility class to related to Hardware VTEP devices.
44  */
45 public final class HwvtepUtils {
46
47     // TODO: (eperefr) Move this to HwvtepSouthboundUtils when in place.
48     public static InstanceIdentifier<LocalUcastMacs> getWildCardPathForLocalUcastMacs() {
49         return InstanceIdentifier.create(NetworkTopology.class).child(Topology.class).child(Node.class)
50                 .augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class);
51     }
52
53     /**
54      * Adds the logical switch into config DS.
55      *
56      * @param broker
57      *            the broker
58      * @param nodeId
59      *            the node id
60      * @param logicalSwitch
61      *            the logical switch
62      * @return the listenable future
63      */
64     public static ListenableFuture<Void> addLogicalSwitch(DataBroker broker, NodeId nodeId,
65             LogicalSwitches logicalSwitch) {
66         WriteTransaction transaction = broker.newWriteOnlyTransaction();
67         putLogicalSwitch(transaction, nodeId, logicalSwitch);
68         return transaction.submit();
69     }
70
71     /**
72      * Put the logical switches in the transaction.
73      *
74      * @param transaction
75      *            the transaction
76      * @param nodeId
77      *            the node id
78      * @param lstSwitches
79      *            the lst switches
80      */
81     public static void putLogicalSwitches(final WriteTransaction transaction, final NodeId nodeId,
82             final List<LogicalSwitches> lstSwitches) {
83         if (lstSwitches != null) {
84             for (LogicalSwitches logicalSwitch : lstSwitches) {
85                 putLogicalSwitch(transaction, nodeId, logicalSwitch);
86             }
87         }
88     }
89
90     /**
91      * Put logical switch in the transaction.
92      *
93      * @param transaction
94      *            the transaction
95      * @param nodeId
96      *            the node id
97      * @param logicalSwitch
98      *            the logical switch
99      */
100     public static void putLogicalSwitch(final WriteTransaction transaction, final NodeId nodeId,
101             final LogicalSwitches logicalSwitch) {
102         InstanceIdentifier<LogicalSwitches> iid = HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(nodeId,
103                 logicalSwitch.getHwvtepNodeName());
104         transaction.put(LogicalDatastoreType.CONFIGURATION, iid, logicalSwitch, true);
105     }
106
107     /**
108      * Delete logical switch from config DS.
109      *
110      * @param broker
111      *            the broker
112      * @param nodeId
113      *            the node id
114      * @param logicalSwitchName
115      *            the logical switch name
116      * @return the listenable future
117      */
118     public static ListenableFuture<Void> deleteLogicalSwitch(DataBroker broker, NodeId nodeId,
119             String logicalSwitchName) {
120         WriteTransaction transaction = broker.newWriteOnlyTransaction();
121         deleteLogicalSwitch(transaction, nodeId, logicalSwitchName);
122         return transaction.submit();
123     }
124
125     /**
126      * Delete logical switch from the transaction.
127      *
128      * @param transaction
129      *            the transaction
130      * @param nodeId
131      *            the node id
132      * @param logicalSwitchName
133      *            the logical switch name
134      */
135     public static void deleteLogicalSwitch(final WriteTransaction transaction, final NodeId nodeId,
136             final String logicalSwitchName) {
137         transaction.delete(LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils
138                 .createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName)));
139     }
140
141     /**
142      * Gets the logical switch.
143      *
144      * @param nodeId
145      *            the node id
146      * @param logicalSwitchName
147      *            the logical switch name
148      * @return the logical switch
149      */
150     public static LogicalSwitches getLogicalSwitch(DataBroker broker, LogicalDatastoreType datastoreType, NodeId nodeId,
151             String logicalSwitchName) {
152         final InstanceIdentifier<LogicalSwitches> iid = HwvtepSouthboundUtils
153                 .createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName));
154         Optional<LogicalSwitches> optLogicalSwitch = MDSALUtil.read(broker, datastoreType, iid);
155         if (optLogicalSwitch.isPresent()) {
156             return optLogicalSwitch.get();
157         }
158         return null;
159     }
160
161     /**
162      * Get LogicalSwitches for a given hwVtepNodeId.
163      *
164      * @param broker
165      *            the broker
166      * @param hwVtepNodeId
167      *            Hardware VTEP Node Id
168      * @param vni
169      *            virtual network id
170      * @return the logical switches
171      */
172     public static LogicalSwitches getLogicalSwitches(DataBroker broker, String hwVtepNodeId, String vni) {
173         NodeId nodeId = new NodeId(hwVtepNodeId);
174         InstanceIdentifier<LogicalSwitches> logicalSwitchesIdentifier = HwvtepSouthboundUtils
175                 .createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(vni));
176
177         Optional<LogicalSwitches> logicalSwitches = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION,
178                 logicalSwitchesIdentifier);
179         if (!logicalSwitches.isPresent()) {
180             return null;
181         }
182
183         return logicalSwitches.get();
184     }
185
186     /**
187      * Put physical locators in the transaction.
188      *
189      * @param transaction
190      *            the transaction
191      * @param nodeId
192      *            the node id
193      * @param lstPhysicalLocator
194      *            the lst physical locator
195      */
196     public static void putPhysicalLocators(WriteTransaction transaction, NodeId nodeId,
197             List<HwvtepPhysicalLocatorAugmentation> lstPhysicalLocator) {
198         if (lstPhysicalLocator != null) {
199             for (HwvtepPhysicalLocatorAugmentation phyLocator : lstPhysicalLocator) {
200                 putPhysicalLocator(transaction, nodeId, phyLocator);
201             }
202         }
203     }
204
205     /**
206      * Put physical locator in the transaction.
207      *
208      * @param transaction
209      *            the transaction
210      * @param nodeId
211      *            the node id
212      * @param phyLocator
213      *            the phy locator
214      */
215     public static void putPhysicalLocator(final WriteTransaction transaction, final NodeId nodeId,
216             final HwvtepPhysicalLocatorAugmentation phyLocator) {
217         InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId,
218                 phyLocator);
219         TerminationPoint terminationPoint = new TerminationPointBuilder()
220                 .setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocator))
221                 .addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocator).build();
222
223         transaction.put(LogicalDatastoreType.CONFIGURATION, iid, terminationPoint, true);
224     }
225
226     /**
227      * Gets the physical locator.
228      *
229      * @param broker
230      *            the broker
231      * @param datastoreType
232      *            the datastore type
233      * @param nodeId
234      *            the node id
235      * @param phyLocatorIp
236      *            the phy locator ip
237      * @return the physical locator
238      */
239     public static HwvtepPhysicalLocatorAugmentation getPhysicalLocator(DataBroker broker,
240             LogicalDatastoreType datastoreType, NodeId nodeId, final IpAddress phyLocatorIp) {
241         HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils
242                 .createHwvtepPhysicalLocatorAugmentation(String.valueOf(phyLocatorIp.getValue()));
243         InstanceIdentifier<HwvtepPhysicalLocatorAugmentation> iid = HwvtepSouthboundUtils
244                 .createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug)
245                 .augmentation(HwvtepPhysicalLocatorAugmentation.class);
246         Optional<HwvtepPhysicalLocatorAugmentation> optPhyLocator = MDSALUtil.read(broker, datastoreType, iid);
247         if (optPhyLocator.isPresent()) {
248             return optPhyLocator.get();
249         }
250         return null;
251     }
252
253     /**
254      * Adds the remote ucast macs into config DS.
255      *
256      * @param broker
257      *            the broker
258      * @param nodeId
259      *            the node id
260      * @param lstRemoteUcastMacs
261      *            the lst remote ucast macs
262      * @return the listenable future
263      */
264     public static ListenableFuture<Void> addRemoteUcastMacs(DataBroker broker, NodeId nodeId,
265             List<RemoteUcastMacs> lstRemoteUcastMacs) {
266         WriteTransaction transaction = broker.newWriteOnlyTransaction();
267         putRemoteUcastMacs(transaction, nodeId, lstRemoteUcastMacs);
268         return transaction.submit();
269     }
270
271     /**
272      * Put remote ucast macs in the transaction.
273      *
274      * @param transaction
275      *            the transaction
276      * @param nodeId
277      *            the node id
278      * @param lstRemoteUcastMacs
279      *            the lst remote ucast macs
280      */
281     public static void putRemoteUcastMacs(final WriteTransaction transaction, final NodeId nodeId,
282             final List<RemoteUcastMacs> lstRemoteUcastMacs) {
283         if (lstRemoteUcastMacs != null && !lstRemoteUcastMacs.isEmpty()) {
284             for (RemoteUcastMacs remoteUcastMac : lstRemoteUcastMacs) {
285                 putRemoteUcastMac(transaction, nodeId, remoteUcastMac);
286             }
287         }
288     }
289
290     /**
291      * Put remote ucast mac in the transaction.
292      *
293      * @param transaction
294      *            the transaction
295      * @param nodeId
296      *            the node id
297      * @param remoteUcastMac
298      *            the remote ucast mac
299      */
300     public static void putRemoteUcastMac(final WriteTransaction transaction, final NodeId nodeId,
301             RemoteUcastMacs remoteUcastMac) {
302         InstanceIdentifier<RemoteUcastMacs> iid = HwvtepSouthboundUtils.createInstanceIdentifier(nodeId)
303                 .augmentation(HwvtepGlobalAugmentation.class).child(RemoteUcastMacs.class,
304                         new RemoteUcastMacsKey(remoteUcastMac.getLogicalSwitchRef(), remoteUcastMac.getMacEntryKey()));
305         transaction.put(LogicalDatastoreType.CONFIGURATION, iid, remoteUcastMac, true);
306     }
307
308     /**
309      * Delete remote ucast mac from the config DS.
310      *
311      * @param broker
312      *            the broker
313      * @param nodeId
314      *            the node id
315      * @param mac
316      *            the mac
317      * @return the listenable future
318      */
319     public static ListenableFuture<Void> deleteRemoteUcastMac(DataBroker broker, NodeId nodeId,
320             String logicalSwitchName, MacAddress mac) {
321         WriteTransaction transaction = broker.newWriteOnlyTransaction();
322         deleteRemoteUcastMac(transaction, nodeId, logicalSwitchName, mac);
323         return transaction.submit();
324     }
325
326     /**
327      * Delete remote ucast macs from the config DS.
328      *
329      * @param broker
330      *            the broker
331      * @param nodeId
332      *            the node id
333      * @param lstMac
334      *            the lst mac
335      * @return the listenable future
336      */
337     public static ListenableFuture<Void> deleteRemoteUcastMacs(DataBroker broker, NodeId nodeId,
338             String logicalSwitchName, List<MacAddress> lstMac) {
339         WriteTransaction transaction = broker.newWriteOnlyTransaction();
340         deleteRemoteUcastMacs(transaction, nodeId, logicalSwitchName, lstMac);
341         return transaction.submit();
342     }
343
344     /**
345      * Delete remote ucast macs from the transaction.
346      *
347      * @param transaction
348      *            the transaction
349      * @param nodeId
350      *            the node id
351      * @param lstMac
352      *            the lst mac
353      */
354     public static void deleteRemoteUcastMacs(final WriteTransaction transaction, final NodeId nodeId,
355             String logicalSwitchName, final List<MacAddress> lstMac) {
356         if (lstMac != null && !lstMac.isEmpty()) {
357             for (MacAddress mac : lstMac) {
358                 deleteRemoteUcastMac(transaction, nodeId, logicalSwitchName, mac);
359             }
360         }
361     }
362
363     /**
364      * Delete remote ucast mac from the transaction.
365      *
366      * @param transaction
367      *            the transaction
368      * @param nodeId
369      *            the node id
370      * @param mac
371      *            the mac
372      */
373     public static void deleteRemoteUcastMac(final WriteTransaction transaction, final NodeId nodeId,
374             String logialSwitchName, final MacAddress mac) {
375         transaction.delete(LogicalDatastoreType.CONFIGURATION,
376                 HwvtepSouthboundUtils.createRemoteUcastMacsInstanceIdentifier(nodeId, logialSwitchName, mac));
377     }
378
379     /**
380      * Adds the remote mcast macs into config DS.
381      *
382      * @param broker
383      *            the broker
384      * @param nodeId
385      *            the node id
386      * @param lstRemoteMcastMacs
387      *            the lst remote mcast macs
388      * @return the listenable future
389      */
390     public static ListenableFuture<Void> addRemoteMcastMacs(DataBroker broker, NodeId nodeId,
391             List<RemoteMcastMacs> lstRemoteMcastMacs) {
392         WriteTransaction transaction = broker.newWriteOnlyTransaction();
393         putRemoteMcastMacs(transaction, nodeId, lstRemoteMcastMacs);
394         return transaction.submit();
395     }
396
397     /**
398      * Put remote mcast macs in the transaction.
399      *
400      * @param transaction
401      *            the transaction
402      * @param nodeId
403      *            the node id
404      * @param lstRemoteMcastMacs
405      *            the lst remote mcast macs
406      */
407     public static void putRemoteMcastMacs(final WriteTransaction transaction, final NodeId nodeId,
408             final List<RemoteMcastMacs> lstRemoteMcastMacs) {
409         if (lstRemoteMcastMacs != null && !lstRemoteMcastMacs.isEmpty()) {
410             for (RemoteMcastMacs remoteMcastMac : lstRemoteMcastMacs) {
411                 putRemoteMcastMac(transaction, nodeId, remoteMcastMac);
412             }
413         }
414     }
415
416     /**
417      * Put remote mcast mac in the transaction.
418      *
419      * @param transaction
420      *            the transaction
421      * @param nodeId
422      *            the node id
423      * @param remoteMcastMac
424      *            the remote mcast mac
425      */
426     public static void putRemoteMcastMac(final WriteTransaction transaction, final NodeId nodeId,
427             RemoteMcastMacs remoteMcastMac) {
428         InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId,
429                 remoteMcastMac.getKey());
430         transaction.put(LogicalDatastoreType.CONFIGURATION, iid, remoteMcastMac, true);
431     }
432
433     /**
434      * Gets the remote mcast mac.
435      *
436      * @param broker
437      *            the broker
438      * @param datastoreType
439      *            the datastore type
440      * @param nodeId
441      *            the node id
442      * @param remoteMcastMacsKey
443      *            the remote mcast macs key
444      * @return the remote mcast mac
445      */
446     public static RemoteMcastMacs getRemoteMcastMac(DataBroker broker, LogicalDatastoreType datastoreType,
447             NodeId nodeId, RemoteMcastMacsKey remoteMcastMacsKey) {
448         final InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils
449                 .createRemoteMcastMacsInstanceIdentifier(nodeId, remoteMcastMacsKey);
450         Optional<RemoteMcastMacs> optRemoteMcastMac = MDSALUtil.read(broker, datastoreType, iid);
451         if (optRemoteMcastMac.isPresent()) {
452             return optRemoteMcastMac.get();
453         }
454         return null;
455     }
456
457     /**
458      * Delete remote mcast mac from config DS.
459      *
460      * @param broker
461      *            the broker
462      * @param nodeId
463      *            the node id
464      * @param remoteMcastMacsKey
465      *            the remote mcast macs key
466      * @return the listenable future
467      */
468     public static ListenableFuture<Void> deleteRemoteMcastMac(DataBroker broker, NodeId nodeId,
469             RemoteMcastMacsKey remoteMcastMacsKey) {
470         WriteTransaction transaction = broker.newWriteOnlyTransaction();
471         deleteRemoteMcastMac(transaction, nodeId, remoteMcastMacsKey);
472         return transaction.submit();
473     }
474
475     /**
476      * Delete remote mcast macs from config DS.
477      *
478      * @param broker
479      *            the broker
480      * @param nodeId
481      *            the node id
482      * @param lstRemoteMcastMacsKey
483      *            the lst remote mcast macs key
484      * @return the listenable future
485      */
486     public static ListenableFuture<Void> deleteRemoteMcastMacs(DataBroker broker, NodeId nodeId,
487             List<RemoteMcastMacsKey> lstRemoteMcastMacsKey) {
488         WriteTransaction transaction = broker.newWriteOnlyTransaction();
489         deleteRemoteMcastMacs(transaction, nodeId, lstRemoteMcastMacsKey);
490         return transaction.submit();
491     }
492
493     /**
494      * Delete remote mcast macs from the transaction.
495      *
496      * @param transaction
497      *            the transaction
498      * @param nodeId
499      *            the node id
500      * @param lstRemoteMcastMacsKey
501      *            the lst remote mcast macs key
502      */
503     public static void deleteRemoteMcastMacs(final WriteTransaction transaction, final NodeId nodeId,
504             final List<RemoteMcastMacsKey> lstRemoteMcastMacsKey) {
505         if (lstRemoteMcastMacsKey != null && !lstRemoteMcastMacsKey.isEmpty()) {
506             for (RemoteMcastMacsKey mac : lstRemoteMcastMacsKey) {
507                 deleteRemoteMcastMac(transaction, nodeId, mac);
508             }
509         }
510     }
511
512     /**
513      * Delete remote mcast mac from the transaction.
514      *
515      * @param transaction
516      *            the transaction
517      * @param nodeId
518      *            the node id
519      * @param remoteMcastMacsKey
520      *            the remote mcast macs key
521      */
522     public static void deleteRemoteMcastMac(final WriteTransaction transaction, final NodeId nodeId,
523             final RemoteMcastMacsKey remoteMcastMacsKey) {
524         transaction.delete(LogicalDatastoreType.CONFIGURATION,
525                 HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId, remoteMcastMacsKey));
526     }
527
528     /**
529      * Merge vlan bindings in the transaction.
530      *
531      * @param transaction
532      *            the transaction
533      * @param nodeId
534      *            the node id
535      * @param phySwitchName
536      *            the phy switch name
537      * @param phyPortName
538      *            the phy port name
539      * @param vlanBindings
540      *            the vlan bindings
541      */
542     public static void mergeVlanBindings(final WriteTransaction transaction, final NodeId nodeId,
543             final String phySwitchName, final String phyPortName, final List<VlanBindings> vlanBindings) {
544         NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, phySwitchName);
545         mergeVlanBindings(transaction, physicalSwitchNodeId, phyPortName, vlanBindings);
546     }
547
548     /**
549      * Merge vlan bindings in the transaction.
550      *
551      * @param transaction
552      *            the transaction
553      * @param physicalSwitchNodeId
554      *            the physical switch node id
555      * @param phyPortName
556      *            the phy port name
557      * @param vlanBindings
558      *            the vlan bindings
559      */
560     public static void mergeVlanBindings(final WriteTransaction transaction, final NodeId physicalSwitchNodeId,
561             final String phyPortName, final List<VlanBindings> vlanBindings) {
562         HwvtepPhysicalPortAugmentation phyPortAug = new HwvtepPhysicalPortAugmentationBuilder()
563                 .setHwvtepNodeName(new HwvtepNodeName(phyPortName)).setVlanBindings(vlanBindings).build();
564
565         final InstanceIdentifier<HwvtepPhysicalPortAugmentation> iid = HwvtepSouthboundUtils
566                 .createPhysicalPortInstanceIdentifier(physicalSwitchNodeId, phyPortName);
567         transaction.merge(LogicalDatastoreType.CONFIGURATION, iid, phyPortAug, true);
568     }
569
570     /**
571      * Delete vlan binding from transaction.
572      *
573      * @param transaction
574      *            the transaction
575      * @param physicalSwitchNodeId
576      *            the physical switch node id
577      * @param phyPortName
578      *            the phy port name
579      * @param vlanId
580      *            the vlan id
581      */
582     public static void deleteVlanBinding(WriteTransaction transaction, NodeId physicalSwitchNodeId, String phyPortName,
583             Integer vlanId) {
584         InstanceIdentifier<VlanBindings> iid = HwvtepSouthboundUtils
585                 .createVlanBindingInstanceIdentifier(physicalSwitchNodeId, phyPortName, vlanId);
586         transaction.delete(LogicalDatastoreType.CONFIGURATION, iid);
587     }
588
589     /**
590      * Gets the hw vtep node.
591      *
592      * @param dataBroker
593      *            the data broker
594      * @param datastoreType
595      *            the datastore type
596      * @param nodeId
597      *            the node id
598      * @return the hw vtep node
599      */
600     public static Node getHwVtepNode(DataBroker dataBroker, LogicalDatastoreType datastoreType, NodeId nodeId) {
601         Optional<Node> optNode = MDSALUtil.read(dataBroker, datastoreType,
602                 HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
603         if (optNode.isPresent()) {
604             return optNode.get();
605         }
606         return null;
607     }
608 }