2 * Copyright (c) 2016, 2017 Red Hat, Inc. 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.ipv6service;
10 import javax.annotation.PostConstruct;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 public class NeutronRouterChangeListener extends AsyncClusteredDataTreeChangeListenerBase<Router,
25 NeutronRouterChangeListener> {
26 private static final Logger LOG = LoggerFactory.getLogger(NeutronRouterChangeListener.class);
27 private final DataBroker dataBroker;
28 private final IfMgr ifMgr;
31 public NeutronRouterChangeListener(final DataBroker dataBroker, IfMgr ifMgr) {
32 this.dataBroker = dataBroker;
38 LOG.info("{} init", getClass().getSimpleName());
39 registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
43 protected InstanceIdentifier<Router> getWildCardPath() {
44 return InstanceIdentifier.create(Neutron.class).child(Routers.class).child(Router.class);
48 protected void add(InstanceIdentifier<Router> identifier, Router input) {
49 LOG.info("Add Router notification handler is invoked {}.", input.getUuid());
50 ifMgr.addRouter(input.getUuid(), input.getName(), input.getTenantId());
54 protected void remove(InstanceIdentifier<Router> identifier, Router input) {
55 LOG.info("Remove Router notification handler is invoked {}.", input.getUuid());
56 ifMgr.removeRouter(input.getUuid());
60 protected void update(InstanceIdentifier<Router> identifier, Router original, Router update) {
61 LOG.debug("Update Router notification handler is invoked. Original: {}, Updated: {}.", original, update);
65 protected NeutronRouterChangeListener getDataTreeChangeListener() {
66 return NeutronRouterChangeListener.this;