2 * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. 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.elan.l2gw.listeners;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
13 import org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class L2GatewayConnectionListener extends AsyncClusteredDataTreeChangeListenerBase<L2gatewayConnection,
22 L2GatewayConnectionListener> {
23 private static final Logger LOG = LoggerFactory.getLogger(L2GatewayConnectionListener.class);
25 private final DataBroker broker;
26 private final L2GatewayConnectionUtils l2GatewayConnectionUtils;
28 public L2GatewayConnectionListener(final DataBroker db, L2GatewayConnectionUtils l2GatewayConnectionUtils) {
29 super(L2gatewayConnection.class, L2GatewayConnectionListener.class);
31 this.l2GatewayConnectionUtils = l2GatewayConnectionUtils;
35 registerListener(LogicalDatastoreType.CONFIGURATION, broker);
39 protected void add(final InstanceIdentifier<L2gatewayConnection> identifier, final L2gatewayConnection input) {
40 LOG.trace("Adding L2gatewayConnection: {}", input);
42 // Get associated L2GwId from 'input'
43 // Create logical switch in each of the L2GwDevices part of L2Gw
44 // Logical switch name is network UUID
45 // Add L2GwDevices to ELAN
46 l2GatewayConnectionUtils.addL2GatewayConnection(input);
50 protected void remove(InstanceIdentifier<L2gatewayConnection> identifier, L2gatewayConnection input) {
51 LOG.trace("Removing L2gatewayConnection: {}", input);
53 l2GatewayConnectionUtils.deleteL2GatewayConnection(input);
57 protected void update(InstanceIdentifier<L2gatewayConnection> identifier, L2gatewayConnection original,
58 L2gatewayConnection update) {
59 LOG.trace("Updating L2gatewayConnection : original value={}, updated value={}", original, update);
63 protected InstanceIdentifier<L2gatewayConnection> getWildCardPath() {
64 return InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class)
65 .child(L2gatewayConnection.class);
69 protected L2GatewayConnectionListener getDataTreeChangeListener() {