Search in sources :

Example 76 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class QosNeutronUtils method handleQosInterfaceAdd.

public void handleQosInterfaceAdd(Port port, Uuid qosUuid) {
    LOG.debug("Handling Port add and QoS associated: port: {} qos: {}", port.getUuid().getValue(), qosUuid.getValue());
    QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
    jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
        // handle DSCP Mark Rules update
        if (qosPolicy != null && qosPolicy.getDscpmarkingRules() != null && !qosPolicy.getDscpmarkingRules().isEmpty()) {
            setPortDscpMarking(port, qosPolicy.getDscpmarkingRules().get(0));
        }
        return emptyList();
    });
}
Also used : QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Example 77 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class QosNeutronUtils method handleNeutronPortQosUpdate.

public void handleNeutronPortQosUpdate(Port port, Uuid qosUuidNew, Uuid qosUuidOld) {
    LOG.debug("Handling Port QoS update: port: {} qosservice: {}", port.getUuid().getValue(), qosUuidNew.getValue());
    QosPolicy qosPolicyNew = qosPolicyMap.get(qosUuidNew);
    QosPolicy qosPolicyOld = qosPolicyMap.get(qosUuidOld);
    jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
        // handle Bandwidth Limit Rules update
        if (qosPolicyNew != null && qosPolicyNew.getBandwidthLimitRules() != null && !qosPolicyNew.getBandwidthLimitRules().isEmpty()) {
            setPortBandwidthLimits(port, qosPolicyNew.getBandwidthLimitRules().get(0), tx);
        } else {
            if (qosPolicyOld != null && qosPolicyOld.getBandwidthLimitRules() != null && !qosPolicyOld.getBandwidthLimitRules().isEmpty()) {
                BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
                setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(Uint64.ZERO).setMaxKbps(Uint64.ZERO).build(), tx);
            }
        }
        // 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);
            }
        }
    })));
}
Also used : BandwidthLimitRulesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRulesBuilder) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Example 78 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class QosTerminationPointListener method update.

@Override
public void update(InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier, OvsdbTerminationPointAugmentation original, OvsdbTerminationPointAugmentation update) {
    String ifaceId = getIfaceId(update);
    if (ifaceId != null) {
        if (isBandwidthRuleCleared(original, update)) {
            qosAlertManager.removeInterfaceIdFromQosAlertCache(ifaceId);
        } else if (isBandwidthRuleApplied(original, update)) {
            qosAlertManager.addInterfaceIdInQoSAlertCache(ifaceId);
        }
    }
    if (!qosEosHandler.isQosClusterOwner()) {
        return;
    }
    if (ifaceId != null && isBandwidthRuleCleared(original, update)) {
        LOG.debug("update tp augment: iface-id: {}, name: {}, old bw rate, burst = {}, {}, " + "updated bw rate, burst = {}, {}", ifaceId, update.getName(), original.getIngressPolicingRate(), original.getIngressPolicingBurst(), update.getIngressPolicingRate(), update.getIngressPolicingBurst());
        Port port = qosNeutronUtils.getNeutronPort(ifaceId);
        if (port != null) {
            setPortBandwidthRule(instanceIdentifier, update, port);
        }
    }
}
Also used : Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)

Example 79 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class QosTerminationPointListener method setPortBandwidthRule.

private void setPortBandwidthRule(InstanceIdentifier<OvsdbTerminationPointAugmentation> identifier, OvsdbTerminationPointAugmentation update, Port port) {
    QosPolicy qosPolicy = qosNeutronUtils.getQosPolicy(port);
    if (qosPolicy == null || qosPolicy.getBandwidthLimitRules() == null || qosPolicy.getBandwidthLimitRules().isEmpty()) {
        return;
    }
    LOG.debug("setting bandwidth rule for port: {}, {}, qos policy: {}", port.getUuid(), update.getName(), qosPolicy.getName());
    jobCoordinator.enqueueJob("QosPort-" + port.getUuid(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
        BandwidthLimitRules bwRule = qosPolicy.getBandwidthLimitRules().get(0);
        OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
        tpAugmentationBuilder.setName(update.getName());
        tpAugmentationBuilder.setIngressPolicingRate(bwRule.getMaxKbps().longValue());
        tpAugmentationBuilder.setIngressPolicingBurst(bwRule.getMaxBurstKbps().longValue());
        tx.mergeParentStructureMerge(InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, identifier.firstKeyOf(Node.class)).child(TerminationPoint.class, identifier.firstKeyOf(TerminationPoint.class)).augmentation(OvsdbTerminationPointAugmentation.class), tpAugmentationBuilder.build());
    })));
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) 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 80 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class QosPolicyChangeListener method reapplyPolicy.

/*    private void remove(InstanceIdentifier<BandwidthLimitRules> identifier, BandwidthLimitRules input) {
        LOG.debug("Removing BandwidthLimitRules : key: {}, value={}",
                identifier.firstKeyOf(QosPolicy.class).getUuid().getValue(), input);

        Uuid qosUuid = identifier.firstKeyOf(QosPolicy.class).getUuid();
        BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
        BandwidthLimitRules zeroBwLimitRule =
                bwLimitBuilder.setMaxBurstKbps(Uint64.ZERO).setMaxKbps(Uint64.ZERO).build();

        for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
            qosNeutronUtils.handleNeutronNetworkQosBwRuleRemove(network, zeroBwLimitRule);
        }

        for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
            jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(
                    txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
                        tx -> qosNeutronUtils.setPortBandwidthLimits(port, zeroBwLimitRule, tx))));
        }
    }*/
/*    private void remove(InstanceIdentifier<DscpmarkingRules> identifier,DscpmarkingRules input) {
        LOG.debug("Removing DscpMarkingRules : key: {}, value={}",
                identifier.firstKeyOf(QosPolicy.class).getUuid().getValue(), input);

        Uuid qosUuid = identifier.firstKeyOf(QosPolicy.class).getUuid();

        for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
            qosNeutronUtils.handleNeutronNetworkQosDscpRuleRemove(network);
        }

        for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
            jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
                qosNeutronUtils.unsetPortDscpMark(port);
                return Collections.emptyList();
            });
        }
    }*/
public void reapplyPolicy(String entityid) {
    Uuid policyUuid = Uuid.getDefaultInstance(entityid);
    if (qosNeutronUtils.getQosPolicyMap().get(policyUuid) == null) {
        LOG.debug("Policy with Uuid: {} does not exist", entityid);
        return;
    }
    @NonNull List<BandwidthLimitRules> nonnullBandwidthLimitRules = new ArrayList<BandwidthLimitRules>(qosNeutronUtils.getQosPolicyMap().get(policyUuid).nonnullBandwidthLimitRules().values());
    if (!nonnullBandwidthLimitRules.isEmpty()) {
        BandwidthLimitRules bandwidthLimitRules = nonnullBandwidthLimitRules.get(0);
        update(policyUuid, bandwidthLimitRules);
    }
    @NonNull List<DscpmarkingRules> nonnullDscpmarkingRules = new ArrayList<DscpmarkingRules>(qosNeutronUtils.getQosPolicyMap().get(policyUuid).nonnullDscpmarkingRules().values());
    if (!nonnullDscpmarkingRules.isEmpty()) {
        DscpmarkingRules dscpmarkingRules = nonnullDscpmarkingRules.get(0);
        update(policyUuid, dscpmarkingRules);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) NonNull(org.eclipse.jdt.annotation.NonNull) ArrayList(java.util.ArrayList) 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)

Aggregations

ArrayList (java.util.ArrayList)120 Test (org.junit.Test)85 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)71 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)64 ExecutionException (java.util.concurrent.ExecutionException)56 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)47 List (java.util.List)46 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)38 Logger (org.slf4j.Logger)38 LoggerFactory (org.slf4j.LoggerFactory)38 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)37 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)35 Collections (java.util.Collections)35 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)34 Map (java.util.Map)33 Inject (javax.inject.Inject)32 Singleton (javax.inject.Singleton)32 BigInteger (java.math.BigInteger)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29