Search in sources :

Example 66 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction 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 67 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class QosPolicyChangeListener method update.

private void update(Uuid qosUuid, DscpmarkingRules update) {
    for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
        qosNeutronUtils.handleNeutronNetworkQosUpdate(network, qosUuid);
    }
    for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
        jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            qosNeutronUtils.setPortDscpMarking(port, update);
            futures.add(wrtConfigTxn.submit());
            return futures;
        });
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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)

Example 68 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class QosPolicyChangeListener method remove.

private void remove(InstanceIdentifier<DscpmarkingRules> identifier, DscpmarkingRules input) {
    LOG.trace("Removing DscpMarkingRules : key: {}, value={}", identifier, 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(), () -> {
            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            qosNeutronUtils.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) 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 69 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction 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 70 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyRouteFlowProgrammer method programPolicyClassifierFlows.

public void programPolicyClassifierFlows(String policyClassifierName, List<BigInteger> localDpIds, List<BigInteger> remoteDpIds, int addOrRemove) {
    long policyClassifierId = policyIdManager.getPolicyClassifierId(policyClassifierName);
    if (policyClassifierId == PolicyServiceConstants.INVALID_ID) {
        LOG.error("Failed to get policy classifier id for classifier {}", policyClassifierName);
        return;
    }
    coordinator.enqueueJob(policyClassifierName, () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        remoteDpIds.forEach(remoteDpId -> {
            long groupId = policyIdManager.getPolicyClassifierGroupId(policyClassifierName, remoteDpId);
            if (groupId != PolicyServiceConstants.INVALID_ID) {
                List<InstructionInfo> instructions = policyFlowUtil.getPolicyRouteInstructions(groupId);
                localDpIds.forEach(localDpId -> {
                    if (!remoteDpId.equals(localDpId)) {
                        programPolicyClassifierFlow(policyClassifierName, policyClassifierId, instructions, localDpId, remoteDpId, tx, addOrRemove);
                    }
                });
            } else {
                LOG.error("Failed to get group id for policy classifier {} DPN {}", policyClassifierName, remoteDpId);
            }
        });
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)320 ArrayList (java.util.ArrayList)74 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)60 BigInteger (java.math.BigInteger)43 Test (org.junit.Test)38 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)33 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)28 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)25 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)23 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)22 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)17 List (java.util.List)16 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)16 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)16 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)14