Priyanka B
Committed by Gerrit Code Review

[ONOS-4171] Merge PCEP and BGP providers into common BGPCEP provider.

Change-Id: Ia87f0898e51704ce8d02d877e9f0d57219099a53
......@@ -25,7 +25,7 @@ import org.onosproject.pcep.tools.PcepTools;
*/
public final class PcepDpid {
private static final String SCHEME = "pcep";
private static final String SCHEME = "l3";
private static final long UNKNOWN = 0;
private long nodeId;
......
......@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
public final class BgpDpid {
private static final Logger log = LoggerFactory.getLogger(BgpDpid.class);
private static final String SCHEME = "bgp";
private static final String SCHEME = "l3";
private static final long UNKNOWN = 0;
private StringBuilder stringBuilder;
public static final int NODE_DESCRIPTOR_LOCAL = 1;
......
......@@ -30,7 +30,7 @@ import static com.google.common.base.Preconditions.checkArgument;
*/
public final class BgpId extends Identifier<IpAddress> {
private static final String SCHEME = "bgp";
private static final String SCHEME = "l3";
private static final long UNKNOWN = 0;
/**
......
......@@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument;
*/
public final class PccId extends Identifier<IpAddress> {
private static final String SCHEME = "pcep";
private static final String SCHEME = "l3";
private static final long UNKNOWN = 0;
/**
......
......@@ -25,10 +25,9 @@
<packaging>pom</packaging>
<description>BGP-LS protocol providers root</description>
<modules>
<module>topology</module>
<module>topology</module>
<module>cfg</module>
<module>app</module>
<module>flow</module>
<module>app</module>
</modules>
<dependencies>
......
......@@ -79,8 +79,11 @@ import org.slf4j.LoggerFactory;
@Component(immediate = true)
public class BgpTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
/**
* Creates an instance of BGP topology provider.
*/
public BgpTopologyProvider() {
super(new ProviderId("bgp", "org.onosproject.provider.bgp"));
super(new ProviderId("l3", "org.onosproject.provider.bgp"));
}
private static final Logger log = LoggerFactory.getLogger(BgpTopologyProvider.class);
......
......@@ -70,9 +70,9 @@ import org.onosproject.net.provider.ProviderId;
* Test for BGP topology provider.
*/
public class BgpTopologyProviderTest {
private static final DeviceId DID2 = DeviceId.deviceId("bgp:rd=0::routinguniverse=0:asn=10");
private static final DeviceId DID2 = DeviceId.deviceId("l3:rd=0::routinguniverse=0:asn=10");
private static final String UNKNOWN = new String("unknown");
public static ProviderId providerId = new ProviderId("bgp", "foo");
public static ProviderId providerId = new ProviderId("l3", "foo");
private final BgpTopologyProvider provider = new BgpTopologyProvider();
private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry();
......
SRC = 'src/main/java/org/onosproject/**/'
CURRENT_NAME = 'onos-bgpcep-provider-flow'
CURRENT_TARGET = ':' + CURRENT_NAME
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//protocols/bgp/api:onos-bgp-api',
]
osgi_jar_with_tests (
osgi_jar(
name = CURRENT_NAME,
srcs = glob([SRC + '/*.java']),
deps = COMPILE_DEPS,
visibility = ['PUBLIC'],
)
......
......@@ -21,15 +21,15 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-providers</artifactId>
<artifactId>onos-bgpcep-providers</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-bgp-provider-flow</artifactId>
<artifactId>onos-bgpcep-provider-flow</artifactId>
<packaging>bundle</packaging>
<description>ONOS BGP protocol flow provider</description>
<description>ONOS BGP-PCEP protocol flow provider</description>
<dependencies>
<dependency>
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.bgp.flow.impl;
package org.onosproject.provider.bgpcep.flow.impl;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......@@ -28,18 +28,22 @@ import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.flow.FlowRuleProvider;
import org.onosproject.net.flow.FlowRuleProviderRegistry;
import org.onosproject.net.flow.FlowRuleProviderService;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Bgp Flow provider.
* Implementation of BGP-PCEP flow provider.
*/
@Component(immediate = true)
public class BgpFlowRuleProvider extends AbstractProvider
public class BgpcepFlowRuleProvider extends AbstractProvider
implements FlowRuleProvider {
private final Logger log = getLogger(getClass());
......@@ -53,19 +57,26 @@ public class BgpFlowRuleProvider extends AbstractProvider
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected BgpController bgpController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PcepClientController pcepController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ResourceService resourceService;
private FlowRuleProviderService providerService;
/**
* Creates an BgpFlow host provider.
* Creates a BgpFlow host provider.
*/
public BgpFlowRuleProvider() {
super(new ProviderId("bgp", "org.onosproject.provider.bgp"));
public BgpcepFlowRuleProvider() {
super(new ProviderId("l3", "org.onosproject.provider.bgpcep"));
}
@Activate
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
log.info("Started");
}
@Deactivate
......@@ -73,6 +84,7 @@ public class BgpFlowRuleProvider extends AbstractProvider
cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
}
@Override
......@@ -83,7 +95,29 @@ public class BgpFlowRuleProvider extends AbstractProvider
}
private void applyRule(FlowRule flowRule) {
//TODO
flowRule.selector().criteria()
.forEach(c -> {
// If Criterion type is MPLS_LABEL, push labels through PCEP client
if (c.type() == Criterion.Type.MPLS_LABEL) {
PcepClient pcc;
/** PCC client session is based on LSR ID, get the LSR ID for a specific device to
push the flows */
//TODO: commented code has dependency with other patch
/* Set<TeRouterId> lrsIds = resourceService.getAvailableResourceValues(Resources
.discrete(flowRule.deviceId()).id(), TeRouterId.class);
lrsIds.forEach(lsrId ->
{
if (pcepController.getClient(PccId.pccId(lsrId)) != null) {
pcc = pcepController.getClient(PccId.pccId(lsrId));
}
});*/
// TODO: Build message and send the PCEP label message via PCEP client
} else {
// TODO: Get the BGP peer based on deviceId and send the message
}
});
}
@Override
......@@ -94,7 +128,29 @@ public class BgpFlowRuleProvider extends AbstractProvider
}
private void removeRule(FlowRule flowRule) {
//TODO
flowRule.selector().criteria()
.forEach(c -> {
// If Criterion type is MPLS_LABEL, remove the specified flow rules
if (c.type() == Criterion.Type.MPLS_LABEL) {
PcepClient pcc;
/** PCC client session is based on LSR ID, get the LSR ID for a specific device to
push the flows */
//TODO: commented code has dependency with other patch
/* Set<TeRouterId> lrsIds = resourceService.getAvailableResourceValues(Resources
.discrete(flowRule.deviceId()).id(), TeRouterId.class);
lrsIds.forEach(lsrId ->
{
if (pcepController.getClient(PccId.pccId(lsrId)) != null) {
pcc = pcepController.getClient(PccId.pccId(lsrId));
}
});*/
// TODO: Build message and send the PCEP label message via PCEP client
} else {
// TODO: Get the BGP peer based on deviceId and send the message
}
});
}
@Override
......
......@@ -15,6 +15,6 @@
*/
/**
* Bgp Flow provider.
* Representation of BGP-PCEP flow provider.
*/
package org.onosproject.provider.bgp.flow.impl;
package org.onosproject.provider.bgpcep.flow.impl;
......
<!--
~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-providers</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-bgpcep-providers</artifactId>
<packaging>pom</packaging>
<description>BGPCEP providers root</description>
<modules>
<module>flow</module>
</modules>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......@@ -81,8 +81,11 @@ import static org.onosproject.pcep.api.PcepDpid.uri;
public class PcepTopologyProvider extends AbstractProvider
implements LinkProvider, DeviceProvider {
/**
* Creates instance of PCEP topology provider.
*/
public PcepTopologyProvider() {
super(new ProviderId("pcep", "org.onosproject.provider.pcep"));
super(new ProviderId("l3", "org.onosproject.provider.pcep"));
}
private static final Logger log = LoggerFactory
......
......@@ -40,6 +40,7 @@
<module>pcep</module>
<module>ovsdb</module>
<module>bgp</module>
<module>bgpcep</module>
<module>snmp</module>
<module>rest</module>
<module>lldpcommon</module>
......