Add Neutron host-id to RLOC mapping
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / intenthandler / GroupBasedPolicyNeutronIntentHandlerBean.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.lispflowmapping.neutron.intenthandler;
9
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
14 import org.opendaylight.lispflowmapping.neutron.intenthandler.listener.service.VbridgeTopologyListenerService;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 /**
19  * Created by Shakib Ahmed on 1/19/17.
20  */
21
22 /*
23  * This is the bean instantiated when lisp neutron service is installed. This bean
24  * registers and maintain listeners for getting updates of Neutron Topology
25  * maintained by groupbasedpolicy and honeycomb vbd.
26  */
27 public class GroupBasedPolicyNeutronIntentHandlerBean implements AutoCloseable, BindingAwareProvider {
28     private static final Logger LOG = LoggerFactory.getLogger(GroupBasedPolicyNeutronIntentHandlerBean.class);
29
30     private DataBroker dataBroker;
31     private MountPointService mountService;
32
33     private VbridgeTopologyListenerService vbridgeTopologyListenerService;
34
35     private IntentHandlerAsyncExecutorProvider intentHandlerAsyncExecutorProvider =
36             IntentHandlerAsyncExecutorProvider.getInstace();
37
38     public GroupBasedPolicyNeutronIntentHandlerBean(final BindingAwareBroker bindingAwareBroker) {
39         bindingAwareBroker.registerProvider(this);
40     }
41
42
43     @Override
44     public void close() throws Exception {
45         LOG.info("Clustering provider closed for {}", this.getClass().getSimpleName());
46         intentHandlerAsyncExecutorProvider.close();
47     }
48
49     @Override
50     public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
51         LOG.info("LFM neutron handler service registered", this.getClass().getSimpleName());
52         dataBroker = session.getSALService(DataBroker.class);
53         mountService = session.getSALService(MountPointService.class);
54         vbridgeTopologyListenerService = VbridgeTopologyListenerService.initialize(dataBroker, mountService);
55     }
56 }