use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.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.pcep.types.rev181109.bandwidth.object.Bandwidth in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronPortQosUpdate.
public void handleNeutronPortQosUpdate(Port port, Uuid qosUuidNew, Uuid qosUuidOld) {
LOG.debug("Handling Port QoS update: port: {} qosservice: {}", port.getUuid().getValue(), qosUuidNew.getValue());
QosPolicy qosPolicyNew = qosPolicyMap.get(qosUuidNew);
QosPolicy qosPolicyOld = qosPolicyMap.get(qosUuidOld);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
// handle Bandwidth Limit Rules update
if (qosPolicyNew != null && qosPolicyNew.getBandwidthLimitRules() != null && !qosPolicyNew.getBandwidthLimitRules().isEmpty()) {
setPortBandwidthLimits(port, qosPolicyNew.getBandwidthLimitRules().get(0), tx);
} else {
if (qosPolicyOld != null && qosPolicyOld.getBandwidthLimitRules() != null && !qosPolicyOld.getBandwidthLimitRules().isEmpty()) {
BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(Uint64.ZERO).setMaxKbps(Uint64.ZERO).build(), tx);
}
}
// 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);
}
}
})));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project netvirt by opendaylight.
the class QosTerminationPointListener method setPortBandwidthRule.
private void setPortBandwidthRule(InstanceIdentifier<OvsdbTerminationPointAugmentation> identifier, OvsdbTerminationPointAugmentation update, Port port) {
QosPolicy qosPolicy = qosNeutronUtils.getQosPolicy(port);
if (qosPolicy == null || qosPolicy.getBandwidthLimitRules() == null || qosPolicy.getBandwidthLimitRules().isEmpty()) {
return;
}
LOG.debug("setting bandwidth rule for port: {}, {}, qos policy: {}", port.getUuid(), update.getName(), qosPolicy.getName());
jobCoordinator.enqueueJob("QosPort-" + port.getUuid(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
BandwidthLimitRules bwRule = qosPolicy.getBandwidthLimitRules().get(0);
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(update.getName());
tpAugmentationBuilder.setIngressPolicingRate(bwRule.getMaxKbps().longValue());
tpAugmentationBuilder.setIngressPolicingBurst(bwRule.getMaxBurstKbps().longValue());
tx.mergeParentStructureMerge(InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, identifier.firstKeyOf(Node.class)).child(TerminationPoint.class, identifier.firstKeyOf(TerminationPoint.class)).augmentation(OvsdbTerminationPointAugmentation.class), tpAugmentationBuilder.build());
})));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project netvirt by opendaylight.
the class QosNeutronUtils method setPortBandwidthLimits.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void setPortBandwidthLimits(Port port, BandwidthLimitRules bwLimit, TypedWriteTransaction<Configuration> writeConfigTxn) {
if (!qosEosHandler.isQosClusterOwner()) {
LOG.debug("Not Qos Cluster Owner. Ignoring setting bandwidth limits");
return;
}
Uint64 dpId = getDpnForInterface(port.getUuid().getValue());
if (dpId.equals(Uint64.ZERO)) {
LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
return;
}
LOG.trace("Setting bandwidth limits {} on Port {}", port.getUuid().getValue(), bwLimit);
OvsdbBridgeRef bridgeRefEntry = getBridgeRefEntryFromOperDS(dpId);
Optional<Node> bridgeNode = MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntry.getValue().firstIdentifierOf(Node.class), dataBroker);
if (!bridgeNode.isPresent()) {
LOG.error("bridge not found for dpn {} port {} in operational datastore", dpId, port.getUuid().getValue());
return;
}
LOG.debug("bridgeNode {}", bridgeNode.get().getNodeId().getValue());
TerminationPoint tp = SouthboundUtils.getTerminationPointByExternalId(bridgeNode.get(), port.getUuid().getValue());
if (tp == null) {
LOG.debug("Skipping setting of bandwidth limit rules for subport {}", port.getUuid().getValue());
return;
}
LOG.debug("tp: {}", tp.getTpId().getValue());
OvsdbTerminationPointAugmentation ovsdbTp = tp.augmentation(OvsdbTerminationPointAugmentation.class);
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(ovsdbTp.getName());
tpAugmentationBuilder.setIngressPolicingRate(bwLimit.getMaxKbps().longValue());
tpAugmentationBuilder.setIngressPolicingBurst(bwLimit.getMaxBurstKbps().longValue());
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.withKey(tp.key());
tpBuilder.addAugmentation(tpAugmentationBuilder.build());
try {
if (writeConfigTxn != null) {
writeConfigTxn.mergeParentStructureMerge(InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().key()).child(TerminationPoint.class, new TerminationPointKey(tp.key())), tpBuilder.build());
} else {
MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().key()).child(TerminationPoint.class, new TerminationPointKey(tp.key())), tpBuilder.build());
}
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Failure while setting BwLimitRule {} to port {} exception ", bwLimit, port.getUuid().getValue(), e);
} else {
LOG.error("Failure while setting BwLimitRule {} to port {}", bwLimit, port.getUuid().getValue());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.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();
}
Aggregations