use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project netvirt by opendaylight.
the class QosNeutronUtils method hasBandwidthLimitRule.
public boolean hasBandwidthLimitRule(Port port) {
Uuid qosUuid = null;
boolean bwLimitRule = false;
LOG.trace("checking bandwidth limit rule for port: {}", port.getUuid());
if (port.getAugmentation(QosPortExtension.class) != null) {
qosUuid = port.getAugmentation(QosPortExtension.class).getQosPolicyId();
} else {
Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
if (network.getAugmentation(QosNetworkExtension.class) != null) {
qosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
}
}
if (qosUuid != null) {
QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
bwLimitRule = true;
}
}
LOG.trace("Bandwidth limit rule for port: {} return value {}", port.getUuid(), bwLimitRule);
return bwLimitRule;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronPortQosUpdate.
public void handleNeutronPortQosUpdate(Port port, Uuid qosUuidNew, Uuid qosUuidOld) {
LOG.trace("Handling Port QoS update: port: {} qosservice: {}", port.getUuid(), qosUuidNew);
QosPolicy qosPolicyNew = qosPolicyMap.get(qosUuidNew);
QosPolicy qosPolicyOld = qosPolicyMap.get(qosUuidOld);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
// handle Bandwidth Limit Rules update
if (qosPolicyNew != null && qosPolicyNew.getBandwidthLimitRules() != null && !qosPolicyNew.getBandwidthLimitRules().isEmpty()) {
setPortBandwidthLimits(port, qosPolicyNew.getBandwidthLimitRules().get(0), wrtConfigTxn);
} else {
if (qosPolicyOld != null && qosPolicyOld.getBandwidthLimitRules() != null && !qosPolicyOld.getBandwidthLimitRules().isEmpty()) {
BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build(), wrtConfigTxn);
}
}
// handle DSCP Mark Rules update
if (qosPolicyNew != null && qosPolicyNew.getDscpmarkingRules() != null && !qosPolicyNew.getDscpmarkingRules().isEmpty()) {
setPortDscpMarking(port, qosPolicyNew.getDscpmarkingRules().get(0));
} else {
if (qosPolicyOld != null && qosPolicyOld.getDscpmarkingRules() != null && !qosPolicyOld.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port);
}
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.
the class LinkAttributesParser method parseLinkAttributes.
/**
* Parse Link Attributes.
*
* @param attributes key is the tlv type and value is the value of the tlv
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
static LinkStateAttribute parseLinkAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
final LinkAttributesBuilder builder = new LinkAttributesBuilder();
final List<SrAdjIds> srAdjIds = new ArrayList<>();
final List<SrLanAdjIds> srLanAdjIds = new ArrayList<>();
final List<PeerSetSids> peerSetSids = new ArrayList<>();
for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
LOG.trace("Link attribute TLV {}", entry.getKey());
final int key = entry.getKey();
final ByteBuf value = entry.getValue();
switch(key) {
case TlvUtil.LOCAL_IPV4_ROUTER_ID:
builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
break;
case TlvUtil.LOCAL_IPV6_ROUTER_ID:
builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
break;
case REMOTE_IPV4_ROUTER_ID:
builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
break;
case REMOTE_IPV6_ROUTER_ID:
builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
break;
case ADMIN_GROUP:
builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
break;
case MAX_BANDWIDTH:
builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
break;
case MAX_RESERVABLE_BANDWIDTH:
builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
break;
case UNRESERVED_BANDWIDTH:
parseUnreservedBandwidth(value, builder);
break;
case TE_METRIC:
builder.setTeMetric(new TeMetric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
LOG.debug("Parsed Metric {}", builder.getTeMetric());
break;
case LINK_PROTECTION_TYPE:
builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
break;
case MPLS_PROTOCOL:
final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
break;
case METRIC:
// length can 3, 2 or 1
builder.setMetric(new Metric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
LOG.debug("Parsed Metric {}", builder.getMetric());
break;
case SHARED_RISK_LINK_GROUP:
parseSrlg(value, builder);
break;
case LINK_OPAQUE:
LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
break;
case LINK_NAME:
builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
LOG.debug("Parsed Link Name : {}", builder.getLinkName());
break;
case SR_ADJ_ID:
srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
break;
case SR_LAN_ADJ_ID:
srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
break;
case PEER_NODE_SID_CODE:
builder.setPeerNodeSid(new PeerNodeSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
break;
case PEER_ADJ_SID_CODE:
builder.setPeerAdjSid(new PeerAdjSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
break;
case PEER_SET_SID_CODE:
peerSetSids.add(new PeerSetSidsBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
break;
default:
LOG.warn("TLV {} is not a valid link attribute, ignoring it", key);
}
}
if (!srAdjIds.isEmpty()) {
builder.setSrAdjIds(srAdjIds);
}
if (!srLanAdjIds.isEmpty()) {
builder.setSrLanAdjIds(srLanAdjIds);
}
if (!peerSetSids.isEmpty()) {
builder.setPeerSetSids(peerSetSids);
}
LOG.trace("Finished parsing Link Attributes.");
return new LinkAttributesCaseBuilder().setLinkAttributes(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.
the class NodeChangedListenerTest method createNode.
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId, final String dstIpv4Address) throws TransactionCommitFailedException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.setKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
pathBuilder.addAugmentation(Path1.class, new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4Address(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4Address(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().setKey(new ReportedLspKey(lspName)).setPath(Collections.singletonList(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(Lists.newArrayList(reportedLps)).setIpAddress(new IpAddress(new Ipv4Address(ipv4Address))).build());
nodeBuilder.addAugmentation(Node1.class, node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testBandwidthObject.
@Test
public void testBandwidthObject() throws IOException, PCEPDeserializerException {
final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
final BandwidthBuilder builder = new BandwidthBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations