2 * Copyright (c) 2014, 2015 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
9 package org.opendaylight.ovsdb.openstack.netvirt.providers;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
14 import org.osgi.framework.BundleContext;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * @author Sam Hague (shague@redhat.com)
21 public class NetvirtProvidersProvider implements BindingAwareProvider, AutoCloseable {
22 private static final Logger LOG = LoggerFactory.getLogger(NetvirtProvidersProvider.class);
23 private BundleContext bundleContext = null;
24 private static DataBroker dataBroker = null;
25 private ConfigActivator activator;
26 private static ProviderContext providerContext = null;
28 public NetvirtProvidersProvider(BundleContext bundleContext) {
29 LOG.info("NetvirtProvidersProvider: bundleContext: {}", bundleContext);
30 this.bundleContext = bundleContext;
33 public static DataBroker getDataBroker() {
37 public static ProviderContext getProviderContext() {
38 return providerContext;
42 public void close() throws Exception {
43 LOG.info("NetvirtProvidersProvider closed");
44 activator.stop(bundleContext);
48 public void onSessionInitiated(ProviderContext providerContextRef) {
49 dataBroker = providerContextRef.getSALService(DataBroker.class);
50 providerContext = providerContextRef;
51 LOG.info("NetvirtProvidersProvider: onSessionInitiated dataBroker: {}", dataBroker);
52 this.activator = new ConfigActivator(providerContextRef);
54 activator.start(bundleContext);
55 } catch (Exception e) {
56 LOG.warn("Failed to start Netvirt: ", e);