-/*\r
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.vpnservice;\r
-\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;\r
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;\r
-import org.opendaylight.yangtools.concepts.ListenerRegistration;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance;\r
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class VpnManager extends AbstractDataChangeListener<VpnInstance> implements AutoCloseable {\r
- private static final Logger LOG = LoggerFactory.getLogger(VpnManager.class);\r
- private ListenerRegistration<DataChangeListener> listenerRegistration;\r
- private final DataBroker broker;\r
-\r
- /**\r
- * Listens for data change related to VPN Instance\r
- * Informs the BGP about VRF information\r
- * \r
- * @param db - dataBroker reference\r
- */\r
- public VpnManager(final DataBroker db) {\r
- super(VpnInstance.class);\r
- broker = db;\r
- registerListener(db);\r
- }\r
-\r
- private void registerListener(final DataBroker db) {\r
- try {\r
- listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,\r
- getWildCardPath(), VpnManager.this, DataChangeScope.SUBTREE);\r
- } catch (final Exception e) {\r
- LOG.error("VPN Service DataChange listener registration fail!", e);\r
- throw new IllegalStateException("VPN Service registration Listener failed.", e);\r
- }\r
- }\r
-\r
- @Override\r
- protected void remove(InstanceIdentifier<VpnInstance> identifier,\r
- VpnInstance del) {\r
- // TODO Auto-generated method stub\r
- }\r
-\r
- @Override\r
- protected void update(InstanceIdentifier<VpnInstance> identifier,\r
- VpnInstance original, VpnInstance update) {\r
- // TODO Auto-generated method stub\r
- }\r
-\r
- @Override\r
- protected void add(InstanceIdentifier<VpnInstance> identifier,\r
- VpnInstance value) {\r
- LOG.info("key: " + identifier + ", value=" + value);\r
- //TODO: Generate VPN ID for this instance, where to store in model ... ?\r
-\r
- //TODO: Add VRF to BGP\r
- }\r
-\r
- private InstanceIdentifier<?> getWildCardPath() {\r
- return InstanceIdentifier.create(VpnInstances.class).child(VpnInstance.class);\r
- }\r
-\r
- @Override\r
- public void close() throws Exception {\r
- if (listenerRegistration != null) {\r
- try {\r
- listenerRegistration.close();\r
- } catch (final Exception e) {\r
- LOG.error("Error when cleaning up DataChangeListener.", e);\r
- }\r
- listenerRegistration = null;\r
- }\r
- LOG.info("VPN Manager Closed");\r
- }\r
-}\r
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VpnManager extends AbstractDataChangeListener<VpnInstance> implements AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(VpnManager.class);
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+ private final DataBroker broker;
+
+ /**
+ * Listens for data change related to VPN Instance
+ * Informs the BGP about VRF information
+ *
+ * @param db - dataBroker reference
+ */
+ public VpnManager(final DataBroker db) {
+ super(VpnInstance.class);
+ broker = db;
+ registerListener(db);
+ }
+
+ private void registerListener(final DataBroker db) {
+ try {
+ listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ getWildCardPath(), VpnManager.this, DataChangeScope.SUBTREE);
+ } catch (final Exception e) {
+ LOG.error("VPN Service DataChange listener registration fail!", e);
+ throw new IllegalStateException("VPN Service registration Listener failed.", e);
+ }
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<VpnInstance> identifier,
+ VpnInstance del) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<VpnInstance> identifier,
+ VpnInstance original, VpnInstance update) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<VpnInstance> identifier,
+ VpnInstance value) {
+ LOG.info("key: " + identifier + ", value=" + value);
+ //TODO: Generate VPN ID for this instance, where to store in model ... ?
+
+ //TODO: Add VRF to BGP
+ }
+
+ private InstanceIdentifier<?> getWildCardPath() {
+ return InstanceIdentifier.create(VpnInstances.class).child(VpnInstance.class);
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (final Exception e) {
+ LOG.error("Error when cleaning up DataChangeListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ LOG.info("VPN Manager Closed");
+ }
+}