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, WriteTransaction writeConfigTxn) {
if (!qosEosHandler.isQosClusterOwner()) {
LOG.trace("Not Qos Cluster Owner. Ignoring setting bandwidth limits");
return;
}
LOG.trace("Setting bandwidth limits {} on Port {}", port, bwLimit);
BigInteger dpId = getDpnForInterface(port.getUuid().getValue());
if (dpId.equals(BigInteger.ZERO)) {
LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
return;
}
OvsdbBridgeRef bridgeRefEntry = getBridgeRefEntryFromOperDS(dpId);
Optional<Node> bridgeNode = MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntry.getValue().firstIdentifierOf(Node.class), dataBroker);
TerminationPoint tp = SouthboundUtils.getTerminationPointByExternalId(bridgeNode.get(), port.getUuid().getValue());
OvsdbTerminationPointAugmentation ovsdbTp = tp.getAugmentation(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.setKey(tp.getKey());
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
try {
if (writeConfigTxn != null) {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), 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().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), tpBuilder.build());
}
} catch (Exception e) {
LOG.error("Failure while setting BwLimitRule {} to port {}", bwLimit, port, e);
}
}
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(Network network) {
boolean bwLimitRule = false;
LOG.trace("checking bandwidth limit rule for network: {}", network.getUuid());
if (network.getAugmentation(QosNetworkExtension.class) != null) {
Uuid 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 network: {} return value {}", network.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 handleNeutronPortQosRemove.
public void handleNeutronPortQosRemove(Port port, Uuid qosUuid) {
LOG.debug("Handling Port QoS removal: port: {} qosservice: {}", port.getUuid().getValue(), qosUuid.getValue());
// check for network qosservice to apply
Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
if (network != null && network.augmentation(QosNetworkExtension.class) != null) {
Uuid networkQosUuid = network.augmentation(QosNetworkExtension.class).getQosPolicyId();
if (networkQosUuid != null) {
handleNeutronPortQosUpdate(port, networkQosUuid, qosUuid);
}
} else {
QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
// handle Bandwidth Limit Rules removal
if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(Uint64.ZERO).setMaxKbps(Uint64.ZERO).build(), tx);
}
// handle DSCP MArk Rules removal
if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.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 QosNeutronUtils method handleNeutronNetworkQosBwRuleRemove.
public void handleNeutronNetworkQosBwRuleRemove(Network network, BandwidthLimitRules zeroBwLimitRule) {
LOG.debug("Handling Qos Bandwidth Rule Remove, net: {}", network.getUuid().getValue());
List<Uuid> subnetIds = getSubnetIdsFromNetworkId(network.getUuid());
for (Uuid subnetId : subnetIds) {
List<Uuid> portIds = getPortIdsFromSubnetId(subnetId);
for (Uuid portId : portIds) {
Port port = getNeutronPort(portId);
if (port != null && (port.augmentation(QosPortExtension.class) == null || port.augmentation(QosPortExtension.class).getQosPolicyId() == null)) {
jobCoordinator.enqueueJob("QosPort-" + portId.getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> setPortBandwidthLimits(port, zeroBwLimitRule, tx))));
}
}
}
}
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 displayQosPolicyMap.
private void displayQosPolicyMap(CommandSession session, Gson gson) {
session.getConsole().println("\nQOS Policy Map");
String uuid;
String policyName;
String dscpUuid;
String bandwidthUuid;
Long maxRate;
Long maxBurstRate;
String dscpValue;
Uuid policyUuid;
JsonObject jsonObject;
JsonArray jsonArray = new JsonArray();
for (ConcurrentMap.Entry<Uuid, QosPolicy> policyEntry : qosPolicyMap.entrySet()) {
jsonObject = new JsonObject();
dscpUuid = "null";
bandwidthUuid = "null";
maxRate = 0L;
maxBurstRate = 0L;
dscpValue = "null";
policyUuid = policyEntry.getKey();
uuid = policyEntry.getKey().getValue();
policyName = qosPolicyMap.get(policyUuid).getName();
if (qosPolicyMap.get(policyUuid).getBandwidthLimitRules() != null) {
BandwidthLimitRules bandwidthLimitRules = qosPolicyMap.get(policyUuid).getBandwidthLimitRules().values().iterator().next();
if (bandwidthLimitRules.getUuid() != null) {
bandwidthUuid = bandwidthLimitRules.getUuid().getValue();
}
if (bandwidthLimitRules.getMaxKbps() != null) {
maxRate = bandwidthLimitRules.getMaxKbps().longValue();
}
if (bandwidthLimitRules.getMaxBurstKbps() != null) {
maxBurstRate = bandwidthLimitRules.getMaxBurstKbps().longValue();
}
}
if (qosPolicyMap.get(policyUuid).getDscpmarkingRules() != null) {
DscpmarkingRules dscp = qosPolicyMap.get(policyUuid).getDscpmarkingRules().values().iterator().next();
if (dscp.getUuid() != null) {
dscpUuid = dscp.getUuid().getValue();
}
if (dscp.getDscpMark() != null) {
dscpValue = dscp.getDscpMark().toString();
}
}
jsonObject.addProperty("Policy Uuid", uuid);
jsonObject.addProperty("Policy Name", policyName);
jsonObject.addProperty("Bandwidth Uuid", bandwidthUuid);
jsonObject.addProperty("max kbps", maxRate);
jsonObject.addProperty("max burst kbps", maxBurstRate);
jsonObject.addProperty("Dscp Uuid", dscpUuid);
jsonObject.addProperty("Dscp Value", dscpValue);
jsonArray.add(jsonObject);
}
session.getConsole().println(gson.toJson(jsonArray));
}
Aggregations