Search in sources :

Example 6 with WriteTransaction

use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyNodeListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode flowCapableNode) {
    BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(key.firstKeyOf(Node.class).getId());
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    createTableMissFlow(dpId, NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, NwConstants.EGRESS_POLICY_CLASSIFIER_COOKIE, tx);
    createTableMissFlow(dpId, NwConstants.EGRESS_POLICY_ROUTING_TABLE, NwConstants.EGRESS_POLICY_ROUTING_COOKIE, tx);
    tx.submit();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) BigInteger(java.math.BigInteger)

Example 7 with WriteTransaction

use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyServiceUtil method updateTunnelInterfaceForUnderlayNetwork.

public void updateTunnelInterfaceForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, BigInteger dstDpId, String tunnelInterfaceName, boolean isAdded) {
    coordinator.enqueueJob(underlayNetwork, () -> {
        InstanceIdentifier<TunnelInterface> identifier = getUnderlayNetworkTunnelIdentifier(underlayNetwork, srcDpId, tunnelInterfaceName);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            TunnelInterface tunnelInterface = new TunnelInterfaceBuilder().setInterfaceName(tunnelInterfaceName).setRemoteDpId(dstDpId).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, tunnelInterface, true);
            LOG.info("Add tunnel {} on DPN {} to underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove tunnel {} from DPN {} on underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TunnelInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 8 with WriteTransaction

use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyServiceUtil method updateTunnelInterfacesForUnderlayNetwork.

public void updateTunnelInterfacesForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, List<TunnelInterface> tunnelInterfaces, boolean isAdded) {
    coordinator.enqueueJob(underlayNetwork, () -> {
        InstanceIdentifier<DpnToInterface> identifier = getUnderlayNetworkDpnIdentifier(underlayNetwork, srcDpId);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            DpnToInterface dpnToInterface = new DpnToInterfaceBuilder().setDpId(srcDpId).setTunnelInterface(tunnelInterfaces).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, dpnToInterface, true);
            LOG.info("Add tunnel interfaces {} on DPN {} to underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove tunnel interfaces {} from DPN {} on underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) DpnToInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterfaceBuilder)

Example 9 with WriteTransaction

use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyServiceUtil method updateAclRuleForPolicyClassifier.

public void updateAclRuleForPolicyClassifier(String policyClassifier, String aclName, String ruleName, boolean isAdded) {
    coordinator.enqueueJob(policyClassifier, () -> {
        InstanceIdentifier<AceRule> identifier = getPolicyClassifierAceIdentifier(policyClassifier, aclName, ruleName);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, new AceRuleBuilder().setRuleName(ruleName).build(), true);
            LOG.info("Add ACL {} rule {} to policy classifier {}", aclName, ruleName, policyClassifier);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove ACL {} rule {} from policy classifier {}", aclName, ruleName, policyClassifier);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) AceRule(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.policy.profile.policy.acl.rule.AceRule) AceRuleBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.policy.profile.policy.acl.rule.AceRuleBuilder)

Example 10 with WriteTransaction

use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class PolicyRouteGroupProgrammer method programPolicyClassifierGroups.

public void programPolicyClassifierGroups(String policyClassifier, BigInteger dpId, List<TunnelInterface> tunnelInterfaces, int addOrRemove) {
    if (tunnelInterfaces == null) {
        LOG.debug("No tunnel interfaces found for policy classifier {} DPN {}", policyClassifier, dpId);
        return;
    }
    coordinator.enqueueJob(policyClassifier, () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        tunnelInterfaces.forEach(tunnelInterface -> {
            BigInteger remoteDpId = tunnelInterface.getRemoteDpId();
            programPolicyClassifierGroups(policyClassifier, Collections.singletonList(dpId), remoteDpId, tx, addOrRemove);
        });
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) BigInteger(java.math.BigInteger)

Aggregations

WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)23 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)6 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Optional (java.util.Optional)4 Collectors.toList (java.util.stream.Collectors.toList)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 NonNull (org.eclipse.jdt.annotation.NonNull)4 Nullable (org.eclipse.jdt.annotation.Nullable)4 DataTreeEventCallbackRegistrar (org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)4 ActionNxLoadInPort (org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort)4 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)4 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)4 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)4 Inet4Address (java.net.Inet4Address)3 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3