Priyanka B
Committed by Gerrit Code Review

[ONOS] Cherry picked from master 1.7 till june 10

Change-Id: Ide60fa5f6bd61fdfbc6ae050b78603cd5f1c78d9
Showing 35 changed files with 497 additions and 188 deletions
......@@ -35,6 +35,7 @@ import org.slf4j.Logger;
description = "Supports querying PCE path.")
public class PceQueryPathCommand extends AbstractShellCommand {
private final Logger log = getLogger(getClass());
public static final String COST_TYPE = "costType";
@Option(name = "-i", aliases = "--id", description = "path-id", required = false,
multiValued = false)
......@@ -71,16 +72,16 @@ public class PceQueryPathCommand extends AbstractShellCommand {
* @param tunnel pce tunnel
*/
void display(Tunnel tunnel) {
print("\npath-id : %d \n" +
print("\npath-id : %s \n" +
"source : %s \n" +
"destination : %s \n" +
"path-type : %d \n" +
"path-type : %s \n" +
"symbolic-path-name : %s \n" +
"constraints: \n" +
" cost : %d \n" +
" bandwidth : %.2f",
" cost : %s \n" +
" bandwidth : %s",
tunnel.tunnelId().id(), tunnel.src().toString(), tunnel.dst().toString(),
tunnel.type(), tunnel.tunnelName(), tunnel.path().cost(),
tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE),
tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
}
}
......
......@@ -86,9 +86,10 @@ public class PceSetupPathCommand extends AbstractShellCommand {
LspType lspType = LspType.values()[type];
// Add bandwidth
// bandwidth default data rate unit is in BPS
// bandwidth default data rate unit is in MBPS, since bandwidth value in network config
//stored in MPBS
if (bandwidth != 0.0) {
listConstrnt.add(BandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS")));
listConstrnt.add(BandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("MBPS")));
}
// Add cost
......
......@@ -893,9 +893,7 @@ public class PceManager implements PceService {
// Check whether device has SR-TE Capability
if (cfg.labelStackCap()) {
if (!srTeHandler.allocateNodeLabel(deviceId, lsrId)) {
log.error("Node label allocation for a device id {} has failed.", deviceId.toString());
}
srTeHandler.allocateNodeLabel(deviceId, lsrId);
}
}
......@@ -974,10 +972,7 @@ public class PceManager implements PceService {
// Check whether device has SR-TE Capability
if (cfg.labelStackCap()) {
if (!srTeHandler.allocateAdjacencyLabel(link)) {
log.error("Unable to allocate adjacency label for a link {}.", link.toString());
return;
}
srTeHandler.allocateAdjacencyLabel(link);
}
return;
......@@ -1209,16 +1204,13 @@ public class PceManager implements PceService {
if (cfg.labelStackCap()) {
if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
// Allocate node-label
if (!srTeHandler.allocateNodeLabel(deviceId, lsrId)) {
log.error("Node label allocation for a device id {} has failed.", deviceId.toString());
}
srTeHandler.allocateNodeLabel(deviceId, lsrId);
// Allocate adjacency label to links which are
// originated from this specific device id
Set<Link> links = linkService.getDeviceEgressLinks(deviceId);
for (Link link : links) {
if (!srTeHandler.allocateAdjacencyLabel(link)) {
log.debug("Unable to allocate adjacency labels for a link {}.", link.toString());
return;
}
}
......@@ -1240,40 +1232,42 @@ public class PceManager implements PceService {
return false;
}
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
if (pceStore.getGlobalNodeLabel(deviceId) != null) {
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
// Convert from DeviceId to TunnelEndPoint
Device srcDevice = deviceService.getDevice(entry.getKey());
// Convert from DeviceId to TunnelEndPoint
Device srcDevice = deviceService.getDevice(entry.getKey());
/*
* If there is a slight difference in timing such that if device subsystem has removed the device but PCE
* store still has it, just ignore such devices.
*/
if (srcDevice == null) {
continue;
}
/*
* If there is a slight difference in timing such that if device subsystem has removed the device but
* PCE store still has it, just ignore such devices.
*/
if (srcDevice == null) {
continue;
}
String srcLsrId = srcDevice.annotations().value(LSRID);
if (srcLsrId == null) {
continue;
}
String srcLsrId = srcDevice.annotations().value(LSRID);
if (srcLsrId == null) {
continue;
}
srTeHandler.advertiseNodeLabelRule(deviceId,
entry.getValue(),
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
srTeHandler.advertiseNodeLabelRule(deviceId,
entry.getValue(),
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
if (entry.getKey().src().deviceId().equals(deviceId)) {
srTeHandler.installAdjLabelRule(deviceId,
entry.getValue(),
entry.getKey().src().port(),
entry.getKey().dst().port(),
Objective.Operation.ADD);
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
if (entry.getKey().src().deviceId().equals(deviceId)) {
srTeHandler.installAdjLabelRule(deviceId,
entry.getValue(),
entry.getKey().src().port(),
entry.getKey().dst().port(),
Objective.Operation.ADD);
}
}
}
......@@ -1281,6 +1275,9 @@ public class PceManager implements PceService {
LabelResourceId.labelResourceId(0),
IpPrefix.valueOf(END_OF_SYNC_IP_PREFIX),
Objective.Operation.ADD, true);
log.debug("End of label DB sync for device {}", deviceId);
if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
// Allocate node-label to this specific device.
allocateNodeLabel(specificDevice);
......@@ -1304,6 +1301,7 @@ public class PceManager implements PceService {
public void process(PacketContext context) {
// Stop processing if the packet has been handled, since we
// can't do any more to it.
log.debug("Received trigger for label DB sync.");
if (context.isHandled()) {
return;
}
......
......@@ -28,7 +28,6 @@ import java.util.Set;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MplsLabel;
import org.onlab.packet.TpPort;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
......@@ -184,7 +183,7 @@ public final class PceccSrTeBeHandler {
// Check whether node-label was already configured for this specific device.
if (pceStore.getGlobalNodeLabel(specificDeviceId) != null) {
log.error("Node label was already configured for device {}.", specificDeviceId.toString());
log.debug("Node label was already configured for device {}.", specificDeviceId.toString());
return false;
}
......@@ -228,12 +227,15 @@ public final class PceccSrTeBeHandler {
// Push to device
// Push label information of specificDeviceId to otherDevId in list and vice versa.
advertiseNodeLabelRule(otherDevId, specificLabelId,
IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
advertiseNodeLabelRule(specificDeviceId, otherLabelId,
IpPrefix.valueOf(IpAddress.valueOf(otherLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
if (!otherDevId.equals(specificDeviceId)) {
advertiseNodeLabelRule(otherDevId, specificLabelId,
IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
advertiseNodeLabelRule(specificDeviceId, otherLabelId,
IpPrefix.valueOf(IpAddress.valueOf(otherLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
}
return true;
......@@ -519,8 +521,8 @@ public final class PceccSrTeBeHandler {
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchTcpSrc(TpPort.tpPort((int) srcPortNum.toLong()));
selectorBuilder.matchTcpDst(TpPort.tpPort((int) dstPortNum.toLong()));
selectorBuilder.matchIPSrc(IpPrefix.valueOf((int) srcPortNum.toLong(), 32));
selectorBuilder.matchIPDst(IpPrefix.valueOf((int) dstPortNum.toLong(), 32));
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
......
......@@ -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()))
......@@ -216,19 +219,19 @@ public class DistributedPceStore implements PceStore {
@Override
public LabelResourceId getGlobalNodeLabel(DeviceId id) {
checkNotNull(id, DEVICE_ID_NULL);
return globalNodeLabelMap.get(id).value();
return globalNodeLabelMap.get(id) == null ? null : globalNodeLabelMap.get(id).value();
}
@Override
public LabelResourceId getAdjLabel(Link link) {
checkNotNull(link, LINK_NULL);
return adjLabelMap.get(link).value();
return adjLabelMap.get(link) == null ? null : adjLabelMap.get(link).value();
}
@Override
public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
return tunnelInfoMap.get(tunnelId).value();
return tunnelInfoMap.get(tunnelId) == null ? null : tunnelInfoMap.get(tunnelId).value();
}
@Override
......
......@@ -431,7 +431,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
lspTypeVal = LspType.SR_WITHOUT_SIGNALLING;
break;
default:
log.error("Invalid LSP type");
break;
}
......@@ -539,7 +538,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
costTypeVal = CostConstraint.Type.TE_COST;
break;
default:
log.error("Invalid cost type");
break;
}
......@@ -660,12 +658,17 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
tunnelSet = tunnelService.queryTunnel(MPLS);
for (Tunnel tunnel : tunnelSet) {
if (tunnel.path() == null) {
log.info("path does not exist");
log.error("path does not exist");
return;
}
paths.add(tunnel.path());
}
if (tunnelSet.size() == 0) {
log.warn("Tunnel does not exist");
return;
}
ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
allPathLinks = buildPaths(builder).build();
hilightAndSendPaths();
......
......@@ -17,18 +17,28 @@
package org.onosproject.pceweb;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.onlab.util.Bandwidth;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.Annotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.ui.UiTopoOverlay;
import org.onosproject.ui.topo.ButtonId;
import org.onosproject.ui.topo.PropertyPanel;
import org.onosproject.net.HostId;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.link.LinkEvent;
import org.onosproject.net.resource.ContinuousResource;
import org.onosproject.net.resource.DiscreteResource;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.Resources;
import org.onosproject.ui.topo.TopoConstants.CoreButtons;
import static org.onosproject.ui.topo.TopoConstants.Properties.*;
import org.onosproject.cli.AbstractShellCommand;
/**
......@@ -42,7 +52,9 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
public static final String AS_NUMBER = "asNumber";
public static final String DOMAIN_IDENTIFIER = "domainIdentifier";
public static final String ROUTING_UNIVERSE = "routingUniverse";
public static final String ABR_BIT = "abrBit";
public static final String ASBR_BIT = "externalBit";
public static final String TE_METRIC = "teCost";
private static final ButtonId SRC_BUTTON = new ButtonId("src");
private static final ButtonId DST_BUTTON = new ButtonId("dst");
......@@ -77,34 +89,75 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
if (deviceService != null) {
Device device = deviceService.getDevice(deviceId);
Annotations annot = device.annotations();
Annotations annots = device.annotations();
String routerId = annot.value(AnnotationKeys.ROUTER_ID);
String type = annot.value(AnnotationKeys.TYPE);
String asNumber = annot.value(AS_NUMBER);
String domain = annot.value(DOMAIN_IDENTIFIER);
String routingUnverse = annot.value(ROUTING_UNIVERSE);
String routerId = annots.value(AnnotationKeys.ROUTER_ID);
String type = annots.value(AnnotationKeys.TYPE);
String asNumber = annots.value(AS_NUMBER);
String domain = annots.value(DOMAIN_IDENTIFIER);
String abrStatus = annots.value(ABR_BIT);
String asbrStatus = annots.value(ASBR_BIT);
if (type != null) {
pp.addProp("Type", type);
}
/* TBD: Router ID need to print
if (routerId != null) {
pp.addProp("Router-ID", routerId);
} */
if (routingUnverse != null) {
pp.addProp("Routing Universe", routingUnverse);
}
if (asNumber != null) {
pp.addProp("AS Number", asNumber);
}
if (domain != null) {
pp.addProp("Domain ID", domain);
}
if (abrStatus != null) {
pp.addProp("ABR Role", abrStatus);
}
if (asbrStatus != null) {
pp.addProp("ASBR Role", asbrStatus);
}
}
}
@Override
public Map<String, String> additionalLinkData(LinkEvent event) {
Map<String, String> map = new HashMap<>();
Link link = event.subject();
map.put("Src port", link.src().port().toString());
map.put("Dst port", link.dst().port().toString());
map.put("Te metric", link.annotations().value(TE_METRIC));
ResourceService resService = AbstractShellCommand.get(ResourceService.class);
DiscreteResource devResource = Resources.discrete(link.src().deviceId(), link.src().port()).resource();
if (resService == null) {
log.warn("resource service does not exist ");
return map;
}
if (devResource == null) {
log.warn("Device resources does not exist ");
return map;
}
Set<Resource> resources = resService.getAvailableResources(devResource.id(), Bandwidth.class);
if (resources.isEmpty()) {
log.warn("Bandwidth resources does not exist ");
return map;
}
if (resources.iterator().next() instanceof ContinuousResource) {
map.put("Bandwidth", ((ContinuousResource) resources.iterator().next()).toString());
}
return map;
}
@Override
public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
}
......
......@@ -96,9 +96,9 @@
addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio');
//Add the LSP type related inputs.
addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type', 'checkbox');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'WITH SIGNALLING', 'radio');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'WITHOUT SR WITHOUT SIGNALLING', 'radio');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'WITH SR WITHOUT SIGNALLING', 'radio');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio');
addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio');
//Add the tunnel name
addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', 'Tunnel Name', 'text');
......@@ -182,12 +182,12 @@
return content;
}
function isChecked(viewId) {
return d3.select('#' + viewId).property('checked');
function isChecked(cboxId) {
return d3.select('#' + cboxId).property('checked');
}
function getCheckedValue(viewId) {
return d3.select('#' + viewId).property('value');
function getCheckedValue(cboxId) {
return d3.select('#' + cboxId).property('value');
}
function showTunnelInformation(data) {
......@@ -198,25 +198,19 @@
var tdString = '' ;
tunnelNameData.a.forEach( function (val, idx) {
var tunnelName = isChecked('tunnel-id-'+idx);
if (tunnelName)
{
if (tunnelName) {
tdString = val;
}
} );
if (tdString) {
constraintsUpdateDialog(tdString);
} else {
$log.debug("No tunnel id is selected.");
}
constraintsUpdateDialog(tdString);
$log.debug('Dialog OK button clicked');
}
tds.openDialog()
.setTitle('Available LSPs with selected device')
.addContent(createUserTextUpdate(data))
.addOkChained(dOkUpdate, 'GOTO Selection of constraints')
.addOkChained(dOkUpdate, 'OK')
.addCancel(dClose, 'Close')
.bindKeys();
}
......@@ -266,7 +260,7 @@
.setTitle('Select constraints for update path')
.addContent(createUserTextUpdatePathEvent())
.addCancel()
.addOk(dOkUpdateEvent, 'Update Path') // NOTE: NOT the "chained" version!
.addOk(dOkUpdateEvent, 'OK') // NOTE: NOT the "chained" version!
.bindKeys();
}
......@@ -278,7 +272,7 @@
tds.openDialog()
.setTitle('Available Tunnels for remove')
.addContent(createUserTextRemove(data))
.addOk(dOkRemove, 'Remove')
.addOk(dOkRemove, 'OK')
.addCancel(dClose, 'Close')
.bindKeys();
}
......
......@@ -168,6 +168,29 @@
},
multi: function (selectOrder) {
selectionCallback(selectOrder);
},
modifylinkdata: function (data, extra) {
$log.debug("Modify link data", data, extra);
function sep() {
data.propOrder.push('-');
}
function add(key) {
var val = extra[key];
if (val !== undefined) {
data.propOrder.push(key);
data.props[key] = val;
}
}
sep();
add('Src port');
add('Dst port');
add('Te metric');
add('Bandwidth');
return data;
}
}
};
......
......@@ -70,7 +70,7 @@ public final class BgpDpid {
/*
* Get iso node ID in specified string format.
*/
private String isoNodeIdString(byte[] isoNodeId) {
public String isoNodeIdString(byte[] isoNodeId) {
if (isoNodeId != null) {
return String.format("%02x%02x.%02x%02x.%02x%02x", isoNodeId[0], isoNodeId[1],
isoNodeId[2], isoNodeId[3],
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller;
/**
* Collection of keys for annotation for PCEP tunnels.
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcep.controller.impl;
package org.onosproject.pcep.controller;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller;
import static org.slf4j.LoggerFactory.getLogger;
......
......@@ -62,6 +62,8 @@ import org.onosproject.pcepio.types.PcepValueType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.onosproject.pcep.controller.PcepSyncStatus.NOT_SYNCED;
/**
* Channel handler deals with the pcc client connection and dispatches
* messages from client to the appropriate locations.
......@@ -177,18 +179,23 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
* The socket IP is stored in channel.
*/
LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
for (PcepValueType optionalTlv : optionalTlvs) {
if (optionalTlv instanceof NodeAttributesTlv) {
List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
.getllNodeAttributesSubTLVs();
for (PcepValueType subTlv : subTlvs) {
if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
h.thispccId = PccId.pccId(IpAddress
.valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
if (optionalTlvs != null) {
for (PcepValueType optionalTlv : optionalTlvs) {
if (optionalTlv instanceof NodeAttributesTlv) {
List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
.getllNodeAttributesSubTLVs();
if (subTlvs == null) {
break;
}
for (PcepValueType subTlv : subTlvs) {
if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
h.thispccId = PccId.pccId(IpAddress
.valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
break;
}
}
break;
}
break;
}
}
......@@ -228,6 +235,11 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
h.pcepPacketStats);
//Get pc instance and set capabilities
h.pc.setCapability(h.capability);
// Initilialize DB sync status.
h.pc.setLspDbSyncStatus(NOT_SYNCED);
h.pc.setLabelDbSyncStatus(NOT_SYNCED);
// set the status of pcc as connected
h.pc.setConnected(true);
h.pc.setChannel(h.channel);
......@@ -253,6 +265,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
log.debug("Keep alive time : " + keepAliveTimer);
//set the state handshake completion.
h.sendKeepAliveMessage();
h.pcepPacketStats.addOutPacket();
h.setHandshakeComplete(true);
......
......@@ -45,6 +45,7 @@ import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepLspStatus;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.PcepSyncStatus;
......@@ -235,8 +236,10 @@ public class PcepClientControllerImpl implements PcepClientController {
ListIterator<PcepStateReport> listIterator = ((PcepReportMsg) msg).getStateReportList().listIterator();
while (listIterator.hasNext()) {
PcepStateReport stateRpt = listIterator.next();
if (stateRpt.getLspObject().getSFlag()) {
PcepLspObject lspObj = stateRpt.getLspObject();
if (lspObj.getSFlag()) {
if (pc.lspDbSyncStatus() != PcepSyncStatus.IN_SYNC) {
log.debug("LSP DB sync started for PCC {}", pc.getPccId().id().toString());
// Initialize LSP DB sync and temporary cache.
pc.setLspDbSyncStatus(PcepSyncStatus.IN_SYNC);
pc.initializeSyncMsgList(pccId);
......@@ -246,13 +249,16 @@ public class PcepClientControllerImpl implements PcepClientController {
// Don't send to provider as of now.
continue;
} else {
if (pc.lspDbSyncStatus() == PcepSyncStatus.IN_SYNC) {
} else if (lspObj.getPlspId() == 0) {
if (pc.lspDbSyncStatus() == PcepSyncStatus.IN_SYNC
|| pc.lspDbSyncStatus() == PcepSyncStatus.NOT_SYNCED) {
// Set end of LSPDB sync.
log.debug("LSP DB sync completed for PCC {}", pc.getPccId().id().toString());
pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
// Call packet provider to initiate label DB sync (only if PCECC capable).
if (pc.capability().pceccCapability()) {
log.debug("Trigger label DB sync for PCC {}", pc.getPccId().id().toString());
pc.setLabelDbSyncStatus(IN_SYNC);
for (PcepPacketListener l : pcepPacketListener) {
l.sendPacketIn(pccId);
......@@ -428,10 +434,16 @@ public class PcepClientControllerImpl implements PcepClientController {
}
List<PcepStateReport> syncStateRptList = pc.getSyncMsgList(pccId);
if (syncStateRptList == null) {
// When there are no LSPs to sync, directly end-of-sync PCRpt will come and the
// list will be null.
syncStateRptList = Collections.EMPTY_LIST;
}
Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
// For every report, fetch PLSP id, local LSP id and symbolic path name from the message.
while (syncStateRptList.iterator().hasNext()) {
while (stateRptListIterator.hasNext()) {
PcepStateReport stateRpt = stateRptListIterator.next();
Tunnel tunnel = null;
......
......@@ -73,7 +73,7 @@ public class PcepClientImpl implements PcepClientDriver {
private byte sessionId;
private PcepPacketStatsImpl pktStats;
private Map<LspKey, Boolean> lspDelegationInfo;
private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
private Map<PccId, List<PcepStateReport>> syncRptCache = new HashMap<>();
@Override
public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
......@@ -267,24 +267,24 @@ public class PcepClientImpl implements PcepClientDriver {
@Override
public void initializeSyncMsgList(PccId pccId) {
List<PcepStateReport> rptMsgList = new LinkedList<>();
sycRptCache.put(pccId, rptMsgList);
syncRptCache.put(pccId, rptMsgList);
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
return sycRptCache.get(pccId);
return syncRptCache.get(pccId);
}
@Override
public void removeSyncMsgList(PccId pccId) {
sycRptCache.remove(pccId);
syncRptCache.remove(pccId);
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
List<PcepStateReport> rptMsgList = syncRptCache.get(pccId);
rptMsgList.add(rptMsg);
sycRptCache.put(pccId, rptMsgList);
syncRptCache.put(pccId, rptMsgList);
}
@Override
......
......@@ -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;
......
......@@ -20,9 +20,10 @@ import static org.onosproject.net.Device.Type.VIRTUAL;
import static org.onosproject.incubator.net.resource.label.LabelResourceId.labelResourceId;
import static java.util.stream.Collectors.toList;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashMap;
import org.onlab.packet.ChassisId;
import org.onlab.packet.Ip4Address;
......@@ -74,6 +75,7 @@ import org.onosproject.net.Link;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.PortNumber;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.BandwidthCapacity;
import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.DeviceDescription;
......@@ -90,7 +92,6 @@ 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.net.config.basics.BandwidthCapacity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -160,6 +161,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
public static final int DELAY = 2;
private LabelResourceId beginLabel = labelResourceId(5122);
private LabelResourceId endLabel = labelResourceId(9217);
private HashMap<DeviceId, List<PortDescription>> portMap = new HashMap<>();
@Activate
public void activate() {
......@@ -243,13 +245,15 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
if (tlv instanceof IsIsPseudonode) {
deviceType = VIRTUAL;
newBuilder.set(AnnotationKeys.ROUTER_ID, new String(((IsIsPseudonode) tlv).getIsoNodeId()));
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfPseudonode) {
deviceType = VIRTUAL;
newBuilder
.set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID()));
} else if (tlv instanceof IsIsNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID, new String(((IsIsNonPseudonode) tlv).getIsoNodeId()));
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID,
Integer.toString(((OspfNonPseudonode) tlv).getrouterID()));
......@@ -284,14 +288,35 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
deviceProviderService.deviceDisconnected(deviceId);
}
private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
PortNumber portNumber) {
List<PortDescription> portList;
if (portMap.containsKey(deviceId)) {
portList = portMap.get(deviceId);
} else {
portList = new ArrayList<>();
}
if (portNumber != null) {
PortDescription portDescriptions = new DefaultPortDescription(portNumber, true);
portList.add(portDescriptions);
}
portMap.put(deviceId, portList);
return portList;
}
@Override
public void addLink(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details) throws BgpParseException {
log.debug("Addlink {}", linkNlri.toString());
if (linkProviderService == null) {
LinkDescription linkDes = buildLinkDes(linkNlri, details, true);
//If already link exists, return
if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
return;
}
LinkDescription linkDes = buildLinkDes(linkNlri, details, true);
/*
* Update link ports and configure bandwidth on source and destination port using networkConfig service
......@@ -302,13 +327,11 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
}
//Updating ports of the link
List<PortDescription> srcPortDescriptions = new LinkedList<>();
srcPortDescriptions.add(new DefaultPortDescription(linkDes.src().port(), true));
deviceProviderService.updatePorts(linkDes.src().deviceId(), srcPortDescriptions);
deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
List<PortDescription> dstPortDescriptions = new LinkedList<>();
dstPortDescriptions.add(new DefaultPortDescription(linkDes.dst().port(), true));
deviceProviderService.updatePorts(linkDes.dst().deviceId(), dstPortDescriptions);
deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
linkProviderService.linkDetected(linkDes);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<app name="org.onosproject.bgpcep" origin="ON.Lab" version="${project.version}"
category="Provider" url="http://onosproject.org" title="BGP PCEP Provider"
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
features="${project.artifactId}">
<description>${project.description}</description>
<artifact>mvn:${project.groupId}/onos-bgpio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
</app>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/onos-bgpio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pce/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
</feature>
</features>
<!--
~ 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-bgpcep-providers</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-bgpcep-app</artifactId>
<packaging>pom</packaging>
<description>BGP PCEP protocol southbound providers</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgpio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-ctl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-provider-cfg</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcepio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcep-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-provider-tunnel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pce</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pceweb</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-provider-packet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgpcep-provider-flow</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......@@ -28,6 +28,7 @@
<modules>
<module>flow</module>
<module>app</module>
</modules>
<dependencies>
......
......@@ -25,4 +25,5 @@
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</artifact>
</app>
......
......@@ -24,5 +24,6 @@
<bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
</feature>
</features>
......
......@@ -58,6 +58,10 @@
<artifactId>onos-pcep-provider-tunnel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-provider-packet</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......
......@@ -107,6 +107,7 @@ public class PcepPacketProvider extends AbstractProvider implements PacketProvid
}
if (pccDeviceId == null) {
log.error("Device not found to perform label DB sync.");
return;
}
......
......@@ -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)
......@@ -141,7 +127,7 @@ public class PcepTopologyProvider extends AbstractProvider
private final ConfigFactory<DeviceId, DeviceCapability> configFactory =
new ConfigFactory<DeviceId, DeviceCapability>(SubjectFactories.DEVICE_SUBJECT_FACTORY,
DeviceCapability.class, "deviceCapability", true) {
DeviceCapability.class, "deviceCapability", false) {
@Override
public DeviceCapability createConfig() {
return new DeviceCapability();
......@@ -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;
......@@ -79,8 +80,9 @@ import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepLspStatus;
import org.onosproject.pcep.controller.PcepLspSyncAction;
import org.onosproject.pcep.controller.impl.PcepLspStatus;
import org.onosproject.pcep.controller.SrpIdGenerators;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
import org.onosproject.pcepio.protocol.PcepAttribute;
......@@ -130,13 +132,13 @@ import static org.onosproject.net.PortNumber.portNumber;
import static org.onosproject.pcep.api.PcepDpid.uri;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.COST_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.COST_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT;
......@@ -306,18 +308,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 +819,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 +907,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();
......
......@@ -23,7 +23,7 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -19,12 +19,12 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
import static org.onosproject.net.Device.Type.ROUTER;
......
......@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -20,7 +20,9 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import java.io.IOException;
import java.util.ArrayList;
......@@ -112,8 +114,8 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
......@@ -173,8 +175,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -233,8 +235,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -293,8 +295,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......