2 * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
8 package org.opendaylight.vpnservice.interfacemgr;
10 import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
12 import java.util.concurrent.Future;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14 import org.opendaylight.idmanager.IdManager;
15 import java.math.BigInteger;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput;
18 import java.util.List;
19 import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
20 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
21 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
22 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
23 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable, IInterfaceManager {
29 private static final Logger LOG = LoggerFactory.getLogger(InterfacemgrProvider.class);
31 private InterfaceManager interfaceManager;
32 private IfmNodeConnectorListener ifmNcListener;
33 private IdManager idManager;
36 public void onSessionInitiated(ProviderContext session) {
37 LOG.info("InterfacemgrProvider Session Initiated");
39 final DataBroker dataBroker = session.getSALService(DataBroker.class);
40 idManager = new IdManager(dataBroker);
41 interfaceManager = new InterfaceManager(dataBroker, idManager);
42 ifmNcListener = new IfmNodeConnectorListener(dataBroker, interfaceManager);
44 } catch (Exception e) {
45 LOG.error("Error initializing services", e);
47 //TODO: Make this debug
48 LOG.info("Interfacemgr services initiated");
51 private void createIdPool() {
52 CreateIdPoolInput createPool = new CreateIdPoolInputBuilder()
53 .setPoolName("interfaces")
55 .setPoolSize(new BigInteger("65535"))
57 //TODO: Error handling
58 Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
60 // LOG.info("Result2: {}",result.get());
61 // } catch (InterruptedException | ExecutionException e) {
62 // // TODO Auto-generated catch block
63 // LOG.error("Error in result.get");
68 public void close() throws Exception {
69 LOG.info("InterfacemgrProvider Closed");
70 interfaceManager.close();
71 ifmNcListener.close();
75 public Long getPortForInterface(String ifName) {
76 return interfaceManager.getPortForInterface(ifName);
80 public long getDpnForInterface(String ifName) {
81 return interfaceManager.getDpnForInterface(ifName);
85 public String getEndpointIpForDpn(long dpnId) {
86 return interfaceManager.getEndpointIpForDpn(dpnId);
90 public List<MatchInfo> getInterfaceIngressRule(String ifName) {
91 return interfaceManager.getInterfaceIngressRule(ifName);
95 public List<InstructionInfo> getInterfaceEgressActions(String ifName) {
96 return interfaceManager.getInterfaceEgressActions(ifName);