Priyanka B
Committed by Gerrit Code Review

[ONOS-4671]PCECC defect fix , bgp pcep provider having same scheme problem

Change-Id: Ibfb18cfa79ec04ec2a62b2139d28b9c7b03d0a07
......@@ -38,6 +38,7 @@ import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.resource.ResourceConsumer;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
import org.onosproject.pce.pceservice.constraint.CostConstraint;
import org.onosproject.pce.pceservice.TunnelConsumerId;
import org.onosproject.pce.pceservice.LspType;
......@@ -132,6 +133,8 @@ public class DistributedPceStore implements PceStore {
CostConstraint.class,
CostConstraint.Type.class,
BandwidthConstraint.class,
CapabilityConstraint.class,
CapabilityConstraint.CapabilityType.class,
LspType.class)
.build()))
......
......@@ -80,7 +80,7 @@ public interface PcepBandwidthObject {
*
* @return bandwidth
*/
int getBandwidth();
float getBandwidth();
/**
* Sets bandwidth value and return its builder.
......@@ -88,7 +88,7 @@ public interface PcepBandwidthObject {
* @param iBandwidth bandwidth value
* @return Builder by setting bandwidth
*/
Builder setBandwidth(int iBandwidth);
Builder setBandwidth(float iBandwidth);
/**
* Sets P flag in Bandwidth object header and returns its builder.
......
......@@ -169,7 +169,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
private PcepObjectHeader bandwidthObjHeader;
private boolean bIsHeaderSet = false;
private int iBandwidth;
private float iBandwidth;
private boolean bIsBandwidthSet = false;
private boolean bPFlag;
......@@ -200,7 +200,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
}
@Override
public int getBandwidth() {
public float getBandwidth() {
return this.iBandwidth;
}
......@@ -216,7 +216,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
}
@Override
public Builder setBandwidth(int iBandwidth) {
public Builder setBandwidth(float iBandwidth) {
this.iBandwidth = iBandwidth;
this.bIsBandwidthSet = true;
return this;
......
......@@ -21,9 +21,6 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.ChassisId;
import org.onosproject.cluster.ClusterService;
import org.onosproject.mastership.MastershipAdminService;
import org.onosproject.mastership.MastershipService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
......@@ -55,7 +52,6 @@ import org.onosproject.net.link.LinkDescription;
import org.onosproject.net.link.LinkProvider;
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.api.DeviceCapability;
......@@ -94,7 +90,9 @@ public class PcepTopologyProvider extends AbstractProvider
* Creates instance of PCEP topology provider.
*/
public PcepTopologyProvider() {
super(new ProviderId("l3", "org.onosproject.provider.pcep"));
//In BGP-PCEP app, since both BGP and PCEP topology provider have same scheme
//so BGP will be primary and PCEP topology provider will be ancillary.
super(new ProviderId("l3", "org.onosproject.provider.pcep", true));
}
private static final Logger log = LoggerFactory
......@@ -113,18 +111,6 @@ public class PcepTopologyProvider extends AbstractProvider
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkService linkService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipAdminService mastershipAdminService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PcepClientController pcepClientController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......@@ -156,6 +142,7 @@ public class PcepTopologyProvider extends AbstractProvider
controller.addLinkListener(listener);
pcepClientController.addNodeListener(listener);
netConfigRegistry.registerConfigFactory(configFactory);
log.info("Started");
}
@Deactivate
......@@ -166,6 +153,7 @@ public class PcepTopologyProvider extends AbstractProvider
controller.removeLinkListener(listener);
pcepClientController.removeNodeListener(listener);
netConfigRegistry.unregisterConfigFactory(configFactory);
log.info("Stopped");
}
private List<PortDescription> buildPortDescriptions(PcepDpid dpid,
......
......@@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpAddress;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.DefaultGroupId;
......@@ -306,18 +307,13 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
return;
}
if (!(srcElement instanceof IpElementId)) {
log.error("Element id is not valid");
return;
}
// check for tunnel end points
if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
log.error("Tunnel source or destination is not valid");
return;
}
PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress()));
PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
if (!(pc instanceof PcepClient)) {
log.error("There is no PCC connected with ip addresss {}"
......@@ -822,21 +818,27 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
IpAddress ipDstAddress = null;
IpAddress ipSrcAddress = null;
PcepValueType subObj = null;
long portNo;
for (Link link : listLink) {
source = link.src();
if (!(source.equals(destination))) {
//set IPv4SubObject for ERO object
ipSrcAddress = source.ipElementId().ipAddress();
portNo = source.port().toLong();
portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
ipSrcAddress = Ip4Address.valueOf((int) portNo);
subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt());
llSubObjects.add(subObj);
}
destination = link.dst();
ipDstAddress = destination.ipElementId().ipAddress();
portNo = destination.port().toLong();
portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
ipDstAddress = Ip4Address.valueOf((int) portNo);
subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt());
llSubObjects.add(subObj);
}
return llSubObjects;
}
......@@ -904,9 +906,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
//build ERO object
PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
int iBandwidth = DEFAULT_BANDWIDTH_VALUE;
float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
if (tunnel.annotations().value(BANDWIDTH) != null) {
iBandwidth = Integer.parseInt(tunnel.annotations().value(BANDWIDTH));
iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
}
// build bandwidth object
PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build();
......