Priyanka B
Committed by Gerrit Code Review

[ONOS-4843] [ONOS-4815]Tunnels are creating even though bandwidth not satisfied …

…for RSVP in resilience case

Change-Id: Ia119620d285055b85f66815c144bcd22ef27f2e8
......@@ -65,16 +65,13 @@ public class PceUpdatePathCommand extends AbstractShellCommand {
constrntList.add(BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS")));
}
// Assign cost
if (cost != 0) {
// Cost validation
if ((cost < 1) || (cost > 2)) {
error("The cost attribute value is either IGP cost(1) or TE cost(2).");
return;
}
CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
constrntList.add(CostConstraint.of(costType));
// Cost validation
if ((cost < 1) || (cost > 2)) {
error("The cost attribute value is either IGP cost(1) or TE cost(2).");
return;
}
CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
constrntList.add(CostConstraint.of(costType));
if (!service.updatePath(TunnelId.valueOf(id), constrntList)) {
error("Path updation failed.");
......
......@@ -508,7 +508,7 @@ public class PceManager implements PceService {
}
if (existingBwValue != null) {
if (bwConstraintValue == 0) {
if (bwConstraintValue == 0 && bwConstraint != null) {
bwConstraintValue = existingBwValue.bps();
}
//If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
......@@ -862,7 +862,12 @@ public class PceManager implements PceService {
// 1. Release old tunnel's bandwidth.
resourceService.release(pceStore.getTunnelInfo(oldTunnel.tunnelId()).tunnelConsumerId());
// 2. Release new tunnel's bandwidth
// 2. Release new tunnel's bandwidth, if new tunnel bandwidth is allocated
if (pceStore.getTunnelInfo(newTunnel.tunnelId()) == null) {
//If bandwidth for new tunnel is not allocated i,e 0 then no need to allocate
return;
}
ResourceConsumer consumer = pceStore.getTunnelInfo(newTunnel.tunnelId()).tunnelConsumerId();
resourceService.release(consumer);
......@@ -1205,7 +1210,7 @@ public class PceManager implements PceService {
localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID)));
}
// If not zero bandwidth, and delegated (initiated LSPs will also be delegated).
if (Double.parseDouble(tunnel.annotations().value(BANDWIDTH)) != 0.0
if (Float.parseFloat(tunnel.annotations().value(BANDWIDTH)) != 0
&& mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) {
releaseBandwidth(tunnel);
}
......
......@@ -115,8 +115,8 @@ public final class PceccTunnelInfo {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("DeviceLabelInfoList", lspLocalLabelInfoList.toString())
.add("TunnelConsumerId", tunnelConsumerId.toString())
.add("DeviceLabelInfoList", lspLocalLabelInfoList)
.add("TunnelConsumerId", tunnelConsumerId)
.toString();
}
}
......
......@@ -1244,14 +1244,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
llOptionalTlv.add(tlv);
}
boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(DELEGATE));
boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(PCE_INIT));
// build lsp object
PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true)
.setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID)))
......@@ -1260,7 +1258,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
.setOptionalTlv(llOptionalTlv).build();
// build ero object
PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
if (tunnel.annotations().value(BANDWIDTH) != null) {
iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
......@@ -1455,10 +1452,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
}
private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv,
float bandwidth, LspType lspType, String costType, boolean isPceInit) {
String bandwidth, LspType lspType, String costType, boolean isPceInit) {
Builder builder = DefaultAnnotations.builder();
/*
* [RFC 5440] The absence of the METRIC object MUST be interpreted by the PCE as a path computation request
* for which no constraints need be applied to any of the metrics.
......@@ -1471,8 +1466,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
builder.set(PCE_INIT, String.valueOf(isPceInit));
}
if (bandwidth != null) {
builder.set(BANDWIDTH, bandwidth);
}
SparseAnnotations annotations = builder
.set(BANDWIDTH, (new Float(bandwidth)).toString())
.set(LSP_SIG_TYPE, lspType.name())
.set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId()))
.set(PLSP_ID, String.valueOf(lspObj.getPlspId()))
......@@ -1598,6 +1596,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag());
}
Tunnel tunnel = null;
SparseAnnotations oldTunnelAnnotations = null;
// Asynchronous status change message from PCC for LSP reported earlier.
for (Tunnel tunnelObj : tunnelQueryResult) {
if (tunnelObj.annotations().value(PLSP_ID) == null) {
......@@ -1615,13 +1614,17 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
}
continue;
}
if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) && (Integer
.valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) {
tunnel = tunnelObj;
break;
if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId())) {
if ((Integer
.valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) {
tunnel = tunnelObj;
}
if ((Integer
.valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) != ipv4LspIdenTlv.getLspId())) {
oldTunnelAnnotations = (SparseAnnotations) tunnelObj.annotations();
}
}
}
DefaultTunnelDescription td;
SparseAnnotations annotations = null;
State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]);
......@@ -1638,7 +1641,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
log.error("Ingress deviceId not found");
return;
}
annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType, lspObj.getCFlag());
String tempBandwidth = null;
String temoCostType = null;
if (oldTunnelAnnotations != null) {
tempBandwidth = oldTunnelAnnotations.value(BANDWIDTH);
temoCostType = oldTunnelAnnotations.value(COST_TYPE);
}
annotations = getAnnotations(lspObj, ipv4LspIdenTlv, tempBandwidth, lspType,
temoCostType, lspObj.getCFlag());
td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
annotations);
......@@ -1696,15 +1706,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
NetworkResource labelStack,
StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) {
SparseAnnotations annotations = null;
Float bandwidth = 0.0f;
DefaultTunnelDescription td;
if (tunnel.annotations().value(BANDWIDTH) != null) {
bandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
}
boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false :
Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue();
annotations = getAnnotations(lspObj, ipv4LspIdenTlv,
bandwidth, lspType,
tunnel.annotations().value(BANDWIDTH), lspType,
tunnel.annotations().value(COST_TYPE), isPceInit);
td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new DefaultGroupId(
0), tunnel.providerId(), tunnel.tunnelName(),
......
......@@ -89,7 +89,6 @@ import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import com.esotericsoftware.minlog.Log;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
......@@ -225,7 +224,6 @@ public class PcepTunnelAddedTest {
tunnel.path(),
tunnel.resource(),
tunnel.annotations());
Log.info("tunnel.annotations().toString() " + tunnel.annotations().toString());
tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
return id;
}
......@@ -251,7 +249,6 @@ public class PcepTunnelAddedTest {
tunnel.resource(),
tunnel.annotations());
tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
Log.info("tunnelService.tunnelIdAsKeyStore ++ " + tunnelService.tunnelIdAsKeyStore.toString());
}
@Override
......@@ -269,7 +266,6 @@ public class PcepTunnelAddedTest {
public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
tunnelIdAsKeyStore.put(tunnelId, tunnel);
Log.info("tunnelIdAsKeyStore insetup :: " + tunnelIdAsKeyStore.toString());
return tunnelId;
}
......