View Javadoc

1   /*
2    * Copyright (c) 2014 Cisco Systems, Inc. and others.  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   
9   package org.opendaylight.lispflowmapping.neutron;
10  
11  
12  import org.slf4j.Logger;
13  import org.slf4j.LoggerFactory;
14  import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15  import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
16  import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
17  import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18  import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
19  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService;
20  
21  
22  public class LispNeutronService implements ILispNeutronService, BindingAwareProvider  {
23  
24  	protected static final Logger LOG = LoggerFactory.getLogger(LispNeutronService.class);
25      private IFlowMapping mappingService;
26      private OdlMappingserviceService lfmDbService;
27      private static ILispNeutronService neutronService;
28  
29  
30      void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
31          LOG.debug("LISP NEUTRON BindingAwareBroker set!");
32          bindingAwareBroker.registerProvider(this);
33          neutronService = this;
34      }
35  
36      void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
37  
38      }
39  
40      public static ILispNeutronService getLispNeutronService() {
41          return neutronService;
42      }
43  
44  
45      public IFlowMapping getMappingService() {
46          return this.mappingService;
47      }
48  
49      public OdlMappingserviceService getMappingDbService() {
50          return this.lfmDbService;
51      }
52  
53      public void setMappingService(IFlowMapping mappingService) {
54          LOG.debug("MappingService set in Lisp Neutron");
55          this.mappingService = mappingService;
56      }
57  
58      public void unsetMappingService(IFlowMapping mappingService) {
59          LOG.debug("MappingService was unset in LISP Neutron");
60          this.mappingService = null;
61      }
62  
63      @Override
64      public void onSessionInitiated(ProviderContext session) {
65          LOG.debug("LFMDBSERVICE IS BEING FILLED! SESSION INITIATED");
66          RpcProviderRegistry rpcRegistry = session.getSALService(RpcProviderRegistry.class);
67          lfmDbService = rpcRegistry.getRpcService(OdlMappingserviceService.class);
68          LOG.debug("LFMDBSERVICE was FILLED! SESSION INITIATED");
69  
70      }
71  
72      public void stop() {
73          LOG.info("LISP Neutron Service is down!");
74      }
75  
76      public void destroy() {
77          LOG.debug("LISP Neutron Service is destroyed!");
78          mappingService = null;
79      }
80  
81  }