<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-vpnservice-api</feature>
<bundle>mvn:org.opendaylight.vpnservice/bgpmanager-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.vpnservice/bgpmanager-impl/${project.version}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/interfacemgr-impl/${interfacemgr.version}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/idmanager-impl/${idmanager.version}</bundle>
<bundle>mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}</bundle>
- <bundle>mvn:org.opendaylight.vpnservice/bgpmanager-impl/${project.version}</bundle>
+
<!--<bundle>mvn:org.opendaylight.vpnservice.third-party/org.apache.thriftlib/1.0.1-SNAPSHOT</bundle>-->
<bundle>wrap:mvn:org.apache.thrift/libthrift/0.9.1$overwrite=merge&Bundle-Version=0.9.1&Export-Package=*;-noimport:=true;version="0.9.1"</bundle>
<!--<bundle>wrap:mvn:javax.servlet/servlet-api/2.5</bundle>-->
+ <configfile finalname="bgpmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/bgpmanager-impl/${project.version}/xml/config</configfile>
<configfile finalname="vpnmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version}/xml/config</configfile>
<configfile finalname="interfacemgr-impl-default-config.xml">mvn:org.opendaylight.vpnservice/interfacemgr-impl/${interfacemgr.version}/xml/config</configfile>
<configfile finalname="nexthopmgr-impl-default-config.xml">mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}/xml/config</configfile>
<configfile finalname="idmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/idmanager-impl/${idmanager.version}/xml/config</configfile>
<configfile finalname="fibmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}/xml/config</configfile>
- <configfile finalname="bgpmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/bgpmanager-impl/${project.version}/xml/config</configfile>
+
</feature>
<feature name='odl-vpnservice-impl-rest' version='${project.version}' description='OpenDaylight :: vpnservice :: impl :: REST '>
<feature version="${project.version}">odl-vpnservice-impl</feature>
<groupId>${project.groupId}</groupId>
<artifactId>vpnmanager-api</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>bgpmanager-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
</dependency>
<!-- TEST Dependencies -->
<dependency>
<required-capabilities>
<capability>urn:opendaylight:params:xml:ns:yang:vpnservice:impl?module=vpnservice-impl&revision=2015-02-16</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:bgpmanager:api?module=bgpmanager-api&revision=2015-04-20</capability>
</required-capabilities>
<configuration>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
<name>binding-osgi-broker</name>
</broker>
+ <bgpmanager>
+ <type xmlns:bgpmanager="urn:opendaylight:params:xml:ns:yang:bgpmanager:api">bgpmanager:bgpmanager-api</type>
+ <name>bgpmanager</name>
+ </bgpmanager>
</module>
</modules>
</data>
private static final FutureCallback<Void> DEFAULT_CALLBACK =
new FutureCallback<Void>() {
public void onSuccess(Void result) {
- LOG.info("Success in Datastore write operation");
+ LOG.info("Success in Datastore operation");
}
public void onFailure(Throwable error) {
- LOG.error("Error in Datastore write operation", error);
+ LOG.error("Error in Datastore operation", error);
};
};
}
@Override
- protected void remove( InstanceIdentifier<VpnInterface> identifier, VpnInterface del) {
- // TODO Auto-generated method stub
+ protected void remove( InstanceIdentifier<VpnInterface> identifier, VpnInterface vpnInterface) {
+ LOG.info("Remove event - key: {}, value: {}" ,identifier, vpnInterface );
+ final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class, VpnInterfaceKey.class);
+ String interfaceName = key.getName();
+ InstanceIdentifierBuilder<Interface> idBuilder =
+ InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(interfaceName));
+ InstanceIdentifier<Interface> id = idBuilder.build();
+ Optional<Interface> port = read(LogicalDatastoreType.CONFIGURATION, id);
+ if (port.isPresent()) {
+ Interface interf = port.get();
+ unbindServiceOnInterface(interf);
+ removeNextHops(identifier, vpnInterface);
+ } else {
+ LOG.info("No nexthops were available to handle remove event {}", interfaceName);
+ }
+ }
+
+ private void removeNextHops(final InstanceIdentifier<VpnInterface> identifier, VpnInterface intf) {
+ //Read NextHops
+ InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
+ Optional<Adjacencies> adjacencies = read(LogicalDatastoreType.OPERATIONAL, path);
+ String intfName = intf.getName();
+
+ if (adjacencies.isPresent()) {
+ List<Adjacency> nextHops = adjacencies.get().getAdjacency();
+ if (!nextHops.isEmpty()) {
+ LOG.trace("NextHops are " + nextHops);
+ for (Adjacency nextHop : nextHops) {
+ //TODO: Update BGP
+ removePrefixFromBGP(nextHop);
+ }
+ }
+
+ InstanceIdentifier<VpnInterface> interfaceId = VpnUtil.getVpnInterfaceIdentifier(intfName);
+ delete(LogicalDatastoreType.OPERATIONAL, interfaceId);
+ }
+ }
+
+ private <T extends DataObject> void delete(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) {
+ WriteTransaction tx = broker.newWriteOnlyTransaction();
+ tx.delete(datastoreType, path);
+ Futures.addCallback(tx.submit(), DEFAULT_CALLBACK);
+ }
+
+ private void unbindServiceOnInterface(Interface intf) {
+ //TODO: Remove Ingress flow on the interface to unbind the VPN service
+ }
+
+ private void removePrefixFromBGP(Adjacency nextHop) {
+ //TODO: Update the Prefix to BGP
}
@Override
*/
package org.opendaylight.vpnservice;
+import java.util.Collections;
+
+import org.opendaylight.bgpmanager.api.IBgpManager;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(VpnserviceProvider.class);
private VpnInterfaceManager vpnInterfaceManager;
private VpnManager vpnManager;
+ private IBgpManager bgpManager;
@Override
public void onSessionInitiated(ProviderContext session) {
}
}
+ public void setBgpManager(IBgpManager bgpManager) {
+ LOG.debug("BGP Manager reference initialized");
+ this.bgpManager = bgpManager;
+ }
+
@Override
public void close() throws Exception {
vpnManager.close();
public java.lang.AutoCloseable createInstance() {
VpnserviceProvider provider = new VpnserviceProvider();
getBrokerDependency().registerProvider(provider);
+ provider.setBgpManager(getBgpmanagerDependency());
return provider;
}
-
}
import config { prefix config; revision-date 2013-04-05; }
import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+ import bgpmanager-api { prefix bgpmgr-api; revision-date 2015-04-20;}
description
"Service definition for vpnservice project";
}
}
}
+ container bgpmanager {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity bgpmgr-api:bgpmanager-api;
+ }
+ }
+ }
}
}
}