Search in sources :

Example 1 with BandwidthLimitRules

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);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) DscpmarkingRules(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.DscpmarkingRules) BandwidthLimitRules(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules)

Example 2 with BandwidthLimitRules

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;
        });
    }
}
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) 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)

Example 3 with BandwidthLimitRules

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;
        });
    }
}
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 4 with BandwidthLimitRules

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;
                });
            }
        }
    }
}
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) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) QosPortExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosPortExtension)

Example 5 with BandwidthLimitRules

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);
    }
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) BigInteger(java.math.BigInteger) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) OvsdbBridgeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 ArrayList (java.util.ArrayList)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)4 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)3 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)3 BandwidthLimitRules (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules)2 BigInteger (java.math.BigInteger)1 ExecutionException (java.util.concurrent.ExecutionException)1 QosPortExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosPortExtension)1 BandwidthLimitRulesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder)1 DscpmarkingRules (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.DscpmarkingRules)1 OvsdbBridgeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef)1 OvsdbTerminationPointAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)1 OvsdbTerminationPointAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder)1 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)1 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)1 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)1 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)1