use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules in project netvirt by opendaylight.
the class QosPolicyChangeListener method reapplyPolicy.
public void reapplyPolicy(String entityid) {
Uuid policyUuid = Uuid.getDefaultInstance(entityid);
if (!qosNeutronUtils.getQosPolicyMap().get(policyUuid).getBandwidthLimitRules().isEmpty()) {
BandwidthLimitRules bandwidthLimitRules = qosNeutronUtils.getQosPolicyMap().get(policyUuid).getBandwidthLimitRules().get(0);
update(policyUuid, bandwidthLimitRules);
}
if (!qosNeutronUtils.getQosPolicyMap().get(policyUuid).getDscpmarkingRules().isEmpty()) {
DscpmarkingRules dscpmarkingRules = qosNeutronUtils.getQosPolicyMap().get(policyUuid).getDscpmarkingRules().get(0);
update(policyUuid, dscpmarkingRules);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules in project netvirt by opendaylight.
the class QosPolicyChangeListener method add.
protected void add(InstanceIdentifier<BandwidthLimitRules> identifier, BandwidthLimitRules input) {
LOG.trace("Adding BandwidthlimitRules : key: {}, value={}", identifier, input);
Uuid qosUuid = identifier.firstKeyOf(QosPolicy.class).getUuid();
for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
qosNeutronUtils.handleNeutronNetworkQosUpdate(network, qosUuid);
qosAlertManager.addToQosAlertCache(network);
}
for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
qosAlertManager.addToQosAlertCache(port);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
qosNeutronUtils.setPortBandwidthLimits(port, input, wrtConfigTxn);
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules in project netvirt by opendaylight.
the class QosPolicyChangeListener method remove.
private void remove(InstanceIdentifier<BandwidthLimitRules> identifier, BandwidthLimitRules input) {
LOG.trace("Removing BandwidthLimitRules : key: {}, value={}", identifier, input);
Uuid qosUuid = identifier.firstKeyOf(QosPolicy.class).getUuid();
BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
BandwidthLimitRules zeroBwLimitRule = bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build();
for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
qosAlertManager.removeFromQosAlertCache(network);
qosNeutronUtils.handleNeutronNetworkQosBwRuleRemove(network, zeroBwLimitRule);
}
for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
qosAlertManager.removeFromQosAlertCache(port);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
qosNeutronUtils.setPortBandwidthLimits(port, zeroBwLimitRule, wrtConfigTxn);
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronNetworkQosBwRuleRemove.
public void handleNeutronNetworkQosBwRuleRemove(Network network, BandwidthLimitRules zeroBwLimitRule) {
LOG.trace("Handling Qos Bandwidth Rule Remove, net: {}", network.getUuid());
List<Uuid> subnetIds = getSubnetIdsFromNetworkId(network.getUuid());
for (Uuid subnetId : subnetIds) {
List<Uuid> portIds = getPortIdsFromSubnetId(subnetId);
for (Uuid portId : portIds) {
Port port = neutronVpnManager.getNeutronPort(portId);
if (port != null && (port.getAugmentation(QosPortExtension.class) == null || port.getAugmentation(QosPortExtension.class).getQosPolicyId() == null)) {
jobCoordinator.enqueueJob("QosPort-" + portId.getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
setPortBandwidthLimits(port, zeroBwLimitRule, wrtConfigTxn);
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules 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);
}
}
Aggregations