public FabricAcl build() { return new FabricAclImpl(this); }
public FabricAclBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
public FabricAclBuilder(FabricAcl base) { if (base.getKey() == null) { this._key = new FabricAclKey( base.getFabricAclName() ); this._fabricAclName = base.getFabricAclName(); } else { this._key = base.getKey(); this._fabricAclName = _key.getFabricAclName(); } if (base instanceof FabricAclImpl) { FabricAclImpl impl = (FabricAclImpl) 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.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
@Override public Future<RpcResult<Void>> addAcl(AddAclInput input) { String aclName = input.getAclName(); FabricId fabricId = input.getFabricId(); NodeId ldev = input.getLogicalDevice(); TpId tpId = input.getLogicalPort(); final FabricInstance fabricObj = FabricInstanceCache.INSTANCE.retrieveFabric(fabricId); if (fabricObj == null) { return Futures.immediateFailedFuture( new IllegalArgumentException(String.format("fabric %s does not exist", fabricId))); } final InstanceIdentifier<FabricAcl> aclIId = fabricObj.addAcl(ldev, tpId, aclName); if (aclIId == null) { return Futures.immediateFailedFuture( new IllegalArgumentException("Can not add acl, maybe the target is not exists !")); } FabricAclBuilder aclBuilder = new FabricAclBuilder(); aclBuilder.setFabricAclName(aclName); aclBuilder.setKey(new FabricAclKey(aclName)); WriteTransaction trans = dataBroker.newWriteOnlyTransaction(); trans.merge(LogicalDatastoreType.OPERATIONAL,aclIId, aclBuilder.build(), false); return Futures.transform(trans.submit(), new AsyncFunction<Void, RpcResult<Void>>() { @Override public ListenableFuture<RpcResult<Void>> apply(Void submitResult) throws Exception { fabricObj.notifyAclUpdated(aclIId, false); return Futures.immediateFuture(RpcResultBuilder.<Void>success().build()); } }, executor); }
private FabricAclImpl(FabricAclBuilder base) { if (base.getKey() == null) { this._key = new FabricAclKey( base.getFabricAclName() ); this._fabricAclName = base.getFabricAclName(); } else { this._key = base.getKey(); this._fabricAclName = _key.getFabricAclName(); } 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.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.fabric.type.rev150930.acl.list.FabricAcl>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
private InstanceIdentifier<FabricAcl> createAclIId(NodeId deviceid, TpId tpid, String aclName) { FabricId fabricid = fabricCtx.getFabricId(); InstanceIdentifier<FabricAcl> aclIId = null; boolean isLsw = fabricCtx.isValidLogicSwitch(deviceid); boolean isLr = fabricCtx.isValidLogicRouter(deviceid); if (tpid != null) { aclIId = MdSalUtils.createLogicPortIId(fabricid, deviceid, tpid) .augmentation(LogicalPortAugment.class) .child(LportAttribute.class) .child(FabricAcl.class, new FabricAclKey(aclName)); } else { if (isLsw) { aclIId = MdSalUtils.createNodeIId(fabricid, deviceid) .augmentation(LogicalSwitchAugment.class) .child(LswAttribute.class) .child(FabricAcl.class, new FabricAclKey(aclName)); } if (isLr) { aclIId = MdSalUtils.createNodeIId(fabricid, deviceid) .augmentation(LogicalRouterAugment.class) .child(LrAttribute.class) .child(FabricAcl.class, new FabricAclKey(aclName)); } } return aclIId; }
if (!Objects.equals(_fabricAclName, other.getFabricAclName())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
@Override public void aclUpdated(InstanceIdentifier<FabricAcl> iid, boolean isDelete) { InstanceIdentifier<TerminationPoint> tpiid = iid.firstIdentifierOf(TerminationPoint.class); String aclName = iid.firstKeyOf(FabricAcl.class).getFabricAclName(); if (tpiid != null) { if (isDelete) {
void addAcl() throws Exception { Optional<TerminationPoint> optional = readTp(); if (optional.isPresent()) { LogicalPortAugment lpAug = optional.get().getAugmentation(LogicalPortAugment.class); if (lpAug == null) { return; } LportAttribute lattr = lpAug.getLportAttribute(); List<UnderlayerPorts> uports = lattr.getUnderlayerPorts(); if (uports == null || uports.isEmpty()) { return; } WriteTransaction trans = databroker.newWriteOnlyTransaction(); FabricAclBuilder builder = new FabricAclBuilder(); builder.setFabricAclName(aclname); for (UnderlayerPorts uport : uports) { @SuppressWarnings("unchecked") InstanceIdentifier<BdPort> bdPortIid = (InstanceIdentifier<BdPort>) uport.getPortRef(); InstanceIdentifier<FabricAcl> path = bdPortIid.child(FabricAcl.class, new FabricAclKey(aclname)); trans.merge(LogicalDatastoreType.OPERATIONAL, path, builder.build(), true); } MdSalUtils.wrapperSubmit(trans); } }
void rmAcl() throws Exception { Optional<TerminationPoint> optional = readTp(); if (optional.isPresent()) { LogicalPortAugment lpAug = optional.get().getAugmentation(LogicalPortAugment.class); if (lpAug == null) { return; } LportAttribute lattr = lpAug.getLportAttribute(); List<UnderlayerPorts> uports = lattr.getUnderlayerPorts(); if (uports == null || uports.isEmpty()) { return; } WriteTransaction trans = databroker.newWriteOnlyTransaction(); for (UnderlayerPorts uport : uports) { @SuppressWarnings("unchecked") InstanceIdentifier<BdPort> bdPortIid = (InstanceIdentifier<BdPort>) uport.getPortRef(); InstanceIdentifier<FabricAcl> path = bdPortIid.child(FabricAcl.class, new FabricAclKey(aclname)); trans.delete(LogicalDatastoreType.OPERATIONAL, path); } MdSalUtils.wrapperSubmit(trans); } }
public void syncAcl(List<LogicSwitchContext> lswCtxs) { WriteTransaction trans = databroker.newWriteOnlyTransaction(); boolean updated = false; for (LogicSwitchContext lswCtx : lswCtxs) { int vlan = lswCtx.getVlan(); if (!bdifs.containsKey(vlan)) { continue; } else { String bdifid = createBdIfId(vlan); for (String aclName : lswCtx.gtAcls()) { InstanceIdentifier<FabricAcl> aclIid = deviceIId.augmentation(FabricCapableDevice.class) .child(Config.class).child(Bdif.class, new BdifKey(bdifid)) .child(FabricAcl.class, new FabricAclKey(aclName)); FabricAclBuilder builder = new FabricAclBuilder(); builder.setFabricAclName(aclName); trans.merge(LogicalDatastoreType.OPERATIONAL, aclIid, builder.build(), true); updated = true; } } } if (updated) { MdSalUtils.wrapperSubmit(trans); } else { trans.cancel(); } }
.augmentation(LogicalPortAugment.class) .child(LportAttribute.class) .child(FabricAcl.class, new FabricAclKey(aclName)); } else { aclIId = MdSalUtils.createNodeIId(fabricId, ldev) .augmentation(LogicalSwitchAugment.class) .child(LswAttribute.class) .child(FabricAcl.class, new FabricAclKey(aclName));