use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy 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.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy 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.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronPortRemove.
public void handleNeutronPortRemove(Port port, Uuid qosUuid, Interface intrf) {
LOG.trace("Handling Port removal and Qos associated: port: {} qos: {}", port.getUuid(), qosUuid);
QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port, intrf);
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronPortRemove.
public void handleNeutronPortRemove(Port port, Uuid qosUuid) {
LOG.trace("Handling Port removal and Qos associated: port: {} qos: {}", port.getUuid(), qosUuid);
QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
// check if any DSCP rule in the policy
if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port);
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronNetworkQosUpdate.
public void handleNeutronNetworkQosUpdate(Network network, Uuid qosUuid) {
LOG.trace("Handling Network QoS update: net: {} qosservice: {}", network.getUuid(), qosUuid);
QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
if (qosPolicy == null || (qosPolicy.getBandwidthLimitRules() == null || qosPolicy.getBandwidthLimitRules().isEmpty()) && (qosPolicy.getDscpmarkingRules() == null || qosPolicy.getDscpmarkingRules().isEmpty())) {
return;
}
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<>();
if (qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
setPortBandwidthLimits(port, qosPolicy.getBandwidthLimitRules().get(0), wrtConfigTxn);
}
if (qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
setPortDscpMarking(port, qosPolicy.getDscpmarkingRules().get(0));
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
}
}
Aggregations