Search in sources :

Example 1 with BandwidthLimitRulesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder 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;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) BandwidthLimitRulesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Example 2 with BandwidthLimitRulesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder 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;
        });
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) BandwidthLimitRulesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy) BandwidthLimitRules(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules)

Example 3 with BandwidthLimitRulesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder in project netvirt by opendaylight.

the class QosNeutronUtils method handleNeutronNetworkQosRemove.

public void handleNeutronNetworkQosRemove(Network network, Uuid qosUuid) {
    LOG.trace("Handling Network QoS removal: net: {} qosservice: {}", network.getUuid(), qosUuid);
    QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
    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 != null && qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
                        BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
                        setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build(), null);
                    }
                    if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
                        unsetPortDscpMark(port);
                    }
                    futures.add(wrtConfigTxn.submit());
                    return futures;
                });
            }
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) BandwidthLimitRulesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) QosPortExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosPortExtension) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Example 4 with BandwidthLimitRulesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder in project netvirt by opendaylight.

the class QosNeutronUtils method handleNeutronPortQosRemove.

public void handleNeutronPortQosRemove(Port port, Uuid qosUuid) {
    LOG.trace("Handling Port QoS removal: port: {} qosservice: {}", port.getUuid(), qosUuid);
    // check for network qosservice to apply
    Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
    if (network != null && network.getAugmentation(QosNetworkExtension.class) != null) {
        Uuid networkQosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
        if (networkQosUuid != null) {
            handleNeutronPortQosUpdate(port, networkQosUuid, qosUuid);
        }
    } else {
        QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
        jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            // handle Bandwidth Limit Rules removal
            if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
                BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
                setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build(), wrtConfigTxn);
            }
            // handle DSCP MArk Rules removal
            if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
                unsetPortDscpMark(port);
            }
            futures.add(wrtConfigTxn.submit());
            return futures;
        });
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) QosNetworkExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ArrayList(java.util.ArrayList) BandwidthLimitRulesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Aggregations

ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 ArrayList (java.util.ArrayList)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)4 BandwidthLimitRulesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder)4 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)3 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)2 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)2 QosNetworkExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension)1 QosPortExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosPortExtension)1 BandwidthLimitRules (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules)1