@Override public Acl build() { return new AclImpl(this); }
private AclImpl(AclBuilder base) { if (base.key() == null) { this.key = new AclKey( base.getAclName(), base.getAclType() ); this._aclName = base.getAclName(); this._aclType = base.getAclType(); } else { this.key = base.key(); this._aclName = key.getAclName(); this._aclType = key.getAclType(); } this._accessListEntries = base.getAccessListEntries(); this._aclOperData = base.getAclOperData(); this.augmentation = ImmutableMap.copyOf(base.augmentation); }
private static void isSupportedAclType(final Acl acl) { checkArgument(SUPPORTED_ACL_TYPES.contains(acl.getAclType()), "Unsupported Acl type %s detected for acl %s, allowed types are %s", acl.getAclType(), acl.getAclName(), SUPPORTED_ACL_TYPES); }
public AclBuilder(Acl base) { if (base.key() == null) { this.key = new AclKey( base.getAclName(), base.getAclType() ); this._aclName = base.getAclName(); this._aclType = base.getAclType(); } else { this.key = base.key(); this._aclName = key.getAclName(); this._aclType = key.getAclType(); } this._accessListEntries = base.getAccessListEntries(); this._aclOperData = base.getAclOperData(); if (base instanceof AclImpl) { AclImpl impl = (AclImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<Acl> casted =(AugmentationHolder<Acl>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
public AclBuilder(Acl base) { if (base.getKey() == null) { this._key = new AclKey( base.getAclName(), base.getAclType() ); this._aclName = base.getAclName(); this._aclType = base.getAclType(); } else { this._key = base.getKey(); this._aclName = _key.getAclName(); this._aclType = _key.getAclType(); } this._accessListEntries = base.getAccessListEntries(); this._aclOperData = base.getAclOperData(); if (base instanceof AclImpl) { AclImpl impl = (AclImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
private AclImpl(AclBuilder base) { if (base.getKey() == null) { this._key = new AclKey( base.getAclName(), base.getAclType() ); this._aclName = base.getAclName(); this._aclType = base.getAclType(); } else { this._key = base.getKey(); this._aclName = _key.getAclName(); this._aclType = _key.getAclType(); } this._accessListEntries = base.getAccessListEntries(); this._aclOperData = base.getAclOperData(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
private static void hasConsistentAceTypeForAclType(final Acl acl) { checkTypesSame(acl.getAccessListEntries().getAce(), acl.getAclName(), checkNotNull(ACL_ACE_PAIRS.get(acl.getAclType()), "Unsupported ACL type %s for ACL %s", acl.getAclType(), acl.getAclName())); }
private static void hasAceList(final Acl acl) { final AccessListEntries accessListEntries = acl.getAccessListEntries(); checkArgument(accessListEntries != null, "The access-list-entries container is not defined."); final List<Ace> ace = accessListEntries.getAce(); checkArgument(ace != null, "The ace list is not defined."); checkArgument(!ace.isEmpty(), "The ace list is empty."); }
private static Stream<Ace> aclToAceStream(@Nonnull final Acl assignedAcl, @Nonnull final WriteContext writeContext) { final String aclName = assignedAcl.getName(); final Class<? extends AclBase> aclType = assignedAcl.getType(); // ietf-acl updates are handled first, so we use writeContext.readAfter final Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl> aclOptional = writeContext.readAfter(AclWriter.ACL_ID.child( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl.class, new AclKey(aclName, aclType))); checkArgument(aclOptional.isPresent(), "Acl lists not configured"); final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl acl = aclOptional.get(); final AccessListEntries accessListEntries = acl.getAccessListEntries(); checkArgument(accessListEntries != null, "access list entries not configured"); return accessListEntries.getAce().stream(); }
default void deleteStandardAcl(@Nonnull final FutureJVppAclFacade futureFacade, @Nonnull final InstanceIdentifier<Acl> id, @Nonnull final Acl acl, @Nonnull final AclContextManager standardAclContext, @Nonnull final MappingContext mappingContext) throws WriteFailedException { final AclDel request = new AclDel(); final String aclName = acl.getAclName(); request.aclIndex = standardAclContext.getAclIndex(aclName, mappingContext); getReplyForDelete(futureFacade.aclDel(request).toCompletableFuture(), id); // removes mapping after successful delete standardAclContext.removeAcl(aclName, mappingContext); }
public AclBuilder addAugmentation(Class<? extends Augmentation<Acl>> augmentationType, Augmentation<Acl> augmentationValue) { if (augmentationValue == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentationValue); return this; }
/** * Convert {@link Acl} tag to byte array in US_ASCII */ default byte[] getAclTag(@Nonnull final Acl acl) { final VppAclAugmentation augmentation = acl.augmentation(VppAclAugmentation.class); if (augmentation != null && augmentation.getTag() != null) { return augmentation.getTag().getBytes(StandardCharsets.US_ASCII); } return new byte[0]; } }
@Nonnull @Override public AclBuilder getBuilder(@Nonnull final InstanceIdentifier<Acl> id) { return new AclBuilder(); }
private void setTag(@Nonnull final AclBuilder builder, @Nullable final byte[] tag) { if (tag != null) { final String strTag = toString(tag); if (strTag.length() > 0) { builder.addAugmentation( VppAclAugmentation.class, new VppAclAugmentationBuilder().setTag(strTag).build() ); } } } }
default List<Ace> getAces(@Nonnull final Acl acl) { return Optional.ofNullable(acl.getAccessListEntries()).orElseThrow(() -> new IllegalArgumentException(String.format("Unable to extract aces from %s", acl))).getAce(); }
default void deleteMacIpAcl(@Nonnull final FutureJVppAclFacade futureFacade, @Nonnull final InstanceIdentifier<Acl> id, @Nonnull final Acl acl, @Nonnull final AclContextManager macIpAclContext, @Nonnull final MappingContext mappingContext) throws WriteFailedException { final MacipAclDel request = new MacipAclDel(); final String aclName = acl.getAclName(); request.aclIndex = macIpAclContext.getAclIndex(aclName, mappingContext); getReplyForDelete(futureFacade.macipAclDel(request).toCompletableFuture(), id); macIpAclContext.removeAcl(aclName, mappingContext); }
public Acl build() { return new AclImpl(this); }
public AclBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
/** * Checks if provided {@link Acl} has aces of type {@link VppAce} */ default boolean isStandardAcl(@Nonnull final Acl acl) { return acl.getAccessListEntries().getAce().stream() .map(Ace::getMatches) .map(Matches::getAceType) .filter(aceType -> aceType instanceof VppAce) .findAny() .isPresent(); }
/** * Checks if provided {@link Acl} has aces of type {@link VppMacipAce} */ default boolean isMacIpAcl(@Nonnull final Acl acl) { return acl.getAccessListEntries().getAce().stream() .map(Ace::getMatches) .map(Matches::getAceType) .filter(aceType -> aceType instanceof VppMacipAce) .findAny() .isPresent(); }