Search in sources :

Example 1 with SecurityGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup in project netvirt by opendaylight.

the class NeutronSecurityGroupListener method toAclBuilder.

private AclBuilder toAclBuilder(SecurityGroup securityGroup, Integer aclTag) {
    AclBuilder aclBuilder = new AclBuilder();
    aclBuilder.setAclName(securityGroup.key().getUuid().getValue());
    aclBuilder.setAclType(NeutronSecurityGroupConstants.ACLTYPE);
    aclBuilder.setAccessListEntries(new AccessListEntriesBuilder().setAce(new ArrayList<>()).build());
    if (aclTag != NeutronSecurityGroupConstants.INVALID_ACL_TAG) {
        AclserviceAugmentationBuilder aclserviceAugmentationBuilder = new AclserviceAugmentationBuilder();
        aclserviceAugmentationBuilder.setAclTag(aclTag);
        aclBuilder.addAugmentation(aclserviceAugmentationBuilder.build());
    }
    return aclBuilder;
}
Also used : AccessListEntriesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntriesBuilder) AclBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclBuilder) AclserviceAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.AclserviceAugmentationBuilder)

Example 2 with SecurityGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup in project netvirt by opendaylight.

the class NeutronSecurityRuleListener method remove.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void remove(InstanceIdentifier<SecurityRule> instanceIdentifier, SecurityRule securityRule) {
    LOG.trace("removed securityRule: {}", securityRule);
    InstanceIdentifier<Ace> identifier = getAceInstanceIdentifier(securityRule);
    try {
        Ace ace = toAceBuilder(securityRule, true).build();
        String jobKey = securityRule.getSecurityGroupId().getValue();
        jobCoordinator.enqueueJob(jobKey, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(identifier, ace))), NeutronSecurityGroupConstants.DJC_MAX_RETRIES);
    } catch (Exception ex) {
        /*
            If there are out of sequence events where-in Sg-Rule delete could occur after SecurityGroup delete.
            we would hit with exception here, trying to delete a child-node, after it's parent has got deleted.
            Logging it as Warn, because if such event occur we are handling it in the AclEventListeners' Remove method.
             */
        LOG.warn("Exception occured while removing acl for security rule: {}. ", securityRule, ex);
    }
}
Also used : Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace)

Example 3 with SecurityGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup in project netvirt by opendaylight.

the class NeutronSecurityGroupListener method add.

@Override
public void add(InstanceIdentifier<SecurityGroup> instanceIdentifier, SecurityGroup securityGroup) {
    LOG.trace("Adding securityGroup: {}", securityGroup);
    String securityGroupId = securityGroup.key().getUuid().getValue();
    InstanceIdentifier<Acl> identifier = getAclInstanceIdentifier(securityGroup);
    jobCoordinator.enqueueJob(securityGroupId, () -> {
        Integer aclTag = neutronSecurityGroupUtils.allocateAclTag(securityGroupId);
        Acl acl = toAclBuilder(securityGroup, aclTag).build();
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructurePut(identifier, acl)));
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SecurityGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroup) AclserviceAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.AclserviceAugmentationBuilder) Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) AccessListEntriesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntriesBuilder) Singleton(javax.inject.Singleton) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) SecurityGroups(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.SecurityGroups) AclKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclKey) AccessLists(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists) Logger(org.slf4j.Logger) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AclBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclBuilder) Objects(java.util.Objects) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl)

Aggregations

AclBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclBuilder)2 AccessListEntriesBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntriesBuilder)2 AclserviceAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.AclserviceAugmentationBuilder)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Objects (java.util.Objects)1 PreDestroy (javax.annotation.PreDestroy)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)1 Executors (org.opendaylight.infrautils.utils.concurrent.Executors)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)1 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)1 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)1 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)1 AbstractAsyncDataTreeChangeListener (org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener)1 AccessLists (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists)1 Acl (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl)1 AclKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclKey)1