2 * Copyright (c) 2015 - 2016 HPE and others. All rights reserved.
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
8 package org.opendaylight.netvirt.neutronvpn;
10 import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.BridgeRefInfo;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class BridgeRefEntryToTransportZoneListener extends AsyncDataTreeChangeListenerBase<BridgeRefEntry,
21 BridgeRefEntryToTransportZoneListener> implements ClusteredDataTreeChangeListener<BridgeRefEntry>, AutoCloseable {
23 private static final Logger LOG = LoggerFactory.getLogger(BridgeRefEntryToTransportZoneListener.class);
24 private TransportZoneNotificationUtil ism;
25 private DataBroker dbx;
27 public BridgeRefEntryToTransportZoneListener(DataBroker dbx, NeutronvpnManager nvManager) {
28 super(BridgeRefEntry.class, BridgeRefEntryToTransportZoneListener.class);
30 ism = new TransportZoneNotificationUtil(dbx, nvManager);
34 LOG.info("{} start", getClass().getSimpleName());
35 if (ism.isAutoTunnelConfigEnabled()) {
36 registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
41 protected InstanceIdentifier<BridgeRefEntry> getWildCardPath() {
42 InstanceIdentifier.InstanceIdentifierBuilder<BridgeRefEntry> bridgeRefEntryInstanceIdentifierBuilder =
43 InstanceIdentifier.builder(BridgeRefInfo.class)
44 .child(BridgeRefEntry.class);
45 return bridgeRefEntryInstanceIdentifierBuilder.build();
50 protected void remove(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry del) {
51 // once the TZ is declared it will stay forever
55 protected void update(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry original,
56 BridgeRefEntry update) {
57 LOG.debug("handle BridgeRefEntry update notification {}", update);
58 ism.updateTransportZone(update);
62 protected void add(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry add) {
63 LOG.debug("handle BridgeRefEntry add notification {}", add);
64 ism.updateTransportZone(add);
68 protected BridgeRefEntryToTransportZoneListener getDataTreeChangeListener() {
69 return BridgeRefEntryToTransportZoneListener.this;