use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthBuilder in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method createEdgeAttributes.
/**
* Create Edge Attributes from Link attributes.
*
* @param la Linkstate Attributes
* @param linkDesc Linkstate Descriptors
*
* @return EdgeAttributes
*/
private static EdgeAttributes createEdgeAttributes(final LinkAttributes la, final LinkDescriptors linkDesc) {
EdgeAttributesBuilder builder = new EdgeAttributesBuilder();
if (linkDesc.getIpv4InterfaceAddress() != null) {
builder.setLocalAddress(new IpAddress(linkDesc.getIpv4InterfaceAddress()));
}
if (linkDesc.getIpv6InterfaceAddress() != null) {
builder.setLocalAddress(new IpAddress(linkDesc.getIpv6InterfaceAddress()));
}
if (linkDesc.getIpv4NeighborAddress() != null) {
builder.setRemoteAddress(new IpAddress(linkDesc.getIpv4NeighborAddress()));
}
if (linkDesc.getIpv6NeighborAddress() != null) {
builder.setRemoteAddress(new IpAddress(linkDesc.getIpv6NeighborAddress()));
}
if (linkDesc.getLinkLocalIdentifier() != null) {
builder.setLocalIdentifier(linkDesc.getLinkLocalIdentifier());
}
if (linkDesc.getLinkRemoteIdentifier() != null) {
builder.setRemoteIdentifier(linkDesc.getLinkRemoteIdentifier());
}
if (la.getMetric() != null) {
builder.setMetric(la.getMetric().getValue());
}
if (la.getTeMetric() != null) {
builder.setTeMetric(la.getTeMetric().getValue());
}
if (la.getMaxLinkBandwidth() != null) {
builder.setMaxLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxLinkBandwidth()));
}
if (la.getMaxReservableBandwidth() != null) {
builder.setMaxResvLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxReservableBandwidth()));
}
if (la.getUnreservedBandwidth() != null) {
int upperBound = Math.min(la.getUnreservedBandwidth().size(), MAX_PRIORITY);
final List<UnreservedBandwidth> unRsvBw = new ArrayList<>(upperBound);
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.UnreservedBandwidth bandwidth : la.nonnullUnreservedBandwidth().values()) {
unRsvBw.add(new UnreservedBandwidthBuilder().setBandwidth(bandwithToDecimalBandwidth(bandwidth.getBandwidth())).withKey(new UnreservedBandwidthKey(bandwidth.getPriority())).build());
}
builder.setUnreservedBandwidth(unRsvBw);
}
if (la.getAdminGroup() != null) {
builder.setAdminGroup(la.getAdminGroup().getValue());
}
if (la.getLinkDelay() != null) {
builder.setDelay(new Delay(la.getLinkDelay().getValue()));
}
if (la.getLinkMinMaxDelay() != null && la.getLinkMinMaxDelay() != null) {
MinMaxDelay mmDelay = new MinMaxDelayBuilder().setMaxDelay(new Delay(la.getLinkMinMaxDelay().getMaxDelay().getValue())).setMinDelay(new Delay(la.getLinkMinMaxDelay().getMinDelay().getValue())).build();
builder.setMinMaxDelay(mmDelay);
}
if (la.getDelayVariation() != null) {
builder.setJitter(new Delay(la.getDelayVariation().getValue()));
}
if (la.getLinkLoss() != null) {
builder.setLoss(new Loss(la.getLinkLoss().getValue()));
}
if (la.getAvailableBandwidth() != null) {
builder.setAvailableBandwidth(bandwithToDecimalBandwidth(la.getAvailableBandwidth()));
}
if (la.getResidualBandwidth() != null) {
builder.setResidualBandwidth(bandwithToDecimalBandwidth(la.getResidualBandwidth()));
}
if (la.getUtilizedBandwidth() != null) {
builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
List<Uint32> srlgs = new ArrayList<>();
for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
srlgs.add(srlg.getValue());
}
builder.setSrlgs(srlgs);
}
for (SrAdjIds adj : la.nonnullSrAdjIds()) {
if (adj.getSidLabelIndex() instanceof LocalLabelCase) {
boolean backup = false;
if (adj.getFlags() instanceof OspfAdjFlags) {
backup = ((OspfAdjFlags) adj.getFlags()).getBackup();
}
if (adj.getFlags() instanceof IsisAdjFlags) {
backup = ((IsisAdjFlags) adj.getFlags()).getBackup();
}
if (!backup) {
builder.setAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
} else {
builder.setBackupAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
}
}
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthBuilder in project bgpcep by opendaylight.
the class LinkAttributesParser method parseUnreservedBandwidth.
private static void parseUnreservedBandwidth(final ByteBuf value, final LinkAttributesBuilder builder) {
final var unreservedBandwidth = BindingMap.<UnreservedBandwidthKey, UnreservedBandwidth>orderedBuilder(UNRESERVED_BW_COUNT);
for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(new Bandwidth(ByteArray.readAllBytes(v))).setPriority(Uint8.valueOf(i)).build());
}
builder.setUnreservedBandwidth(unreservedBandwidth.build());
LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
}
Aggregations