2 * Copyright (c) 2016 Cisco Systems, 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
9 package org.opendaylight.groupbasedpolicy.sxp_ise_adapter.impl;
11 import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.gbp.sxp.ise.adapter.model.rev160630.GbpSxpIseAdapter;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.gbp.sxp.ise.adapter.model.rev160630.gbp.sxp.ise.adapter.IseSourceConfig;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 import com.google.common.base.Preconditions;
27 * Purpose: main provider of gbp-ise adapter (for reading sgts and generating EndpointPolicyTemplates)
29 public class GbpIseAdapterProvider implements AutoCloseable, BindingAwareProvider {
31 private static final Logger LOG = LoggerFactory.getLogger(GbpIseAdapterProvider.class);
33 private final DataBroker dataBroker;
34 private ListenerRegistration<ClusteredDataTreeChangeListener<IseSourceConfig>> registration;
36 public GbpIseAdapterProvider(final DataBroker dataBroker, final BindingAwareBroker brokerDependency) {
37 this.dataBroker = Preconditions.checkNotNull(dataBroker, "provided dataBroker must not be null");
38 brokerDependency.registerProvider(this);
43 if (registration != null) {
44 LOG.info("closing GbpIseAdapterProvider");
51 public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
52 LOG.info("Starting GbpIseAdapterProvider ..");
54 // setup harvesting and processing pipeline
55 final SgtInfoProcessor epgGenerator = new SgtToEpgGeneratorImpl(dataBroker);
56 final SgtInfoProcessor templateGenerator = new SgtToEPTemplateGeneratorImpl(dataBroker);
57 final GbpIseSgtHarvester gbpIseSgtHarvester = new GbpIseSgtHarvesterImpl(epgGenerator, templateGenerator);
58 final GbpIseConfigListenerImpl gbpIseConfigListener = new GbpIseConfigListenerImpl(dataBroker, gbpIseSgtHarvester);
60 // build data-tree path
61 final DataTreeIdentifier<IseSourceConfig> dataTreePath = new DataTreeIdentifier<>(
62 LogicalDatastoreType.CONFIGURATION,
63 InstanceIdentifier.create(GbpSxpIseAdapter.class).child(IseSourceConfig.class));
65 // register config listener
66 registration = dataBroker.registerDataTreeChangeListener(dataTreePath,
67 gbpIseConfigListener);