Search in sources :

Example 1 with AceRule

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.policy.profile.policy.acl.rule.AceRule 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.controller.md.sal.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)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 AceRule (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.policy.profile.policy.acl.rule.AceRule)1 AceRuleBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.policy.profile.policy.acl.rule.AceRuleBuilder)1