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