@Override public boolean cancel() { return delegate.cancel(); }
private void removeFlow(DataBroker dataBroker, InstanceIdentifier<Flow> path) { WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); modification.delete(LogicalDatastoreType.CONFIGURATION, path); CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit(); try { commitFuture.get(); // TODO: Make it async (See bug 1362) LOG.debug("Transaction success for deletion of Flow {}", path); } catch (Exception e) { LOG.error("Failed to remove flow {}", path, e); modification.cancel(); } } }
public static <T extends DataObject> boolean writeData(DataBroker dataBroker, LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<T> iid, T dataObject, boolean isAdd) { Preconditions.checkNotNull(dataBroker); WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); if (isAdd) { if (dataObject == null) { logger.warn("Invalid attempt to add a non-existent object to path {}", iid); return false; } modification.merge(logicalDatastoreType, iid, dataObject, true /*createMissingParents*/); } else { modification.delete(LogicalDatastoreType.CONFIGURATION, iid); } CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit(); try { commitFuture.checkedGet(); logger.debug("Transaction success for {} of object {}", (isAdd) ? "add" : "delete", dataObject); return true; } catch (Exception e) { logger.error("Transaction failed with error {} for {} of object {}", e.getMessage(), (isAdd) ? "add" : "delete", dataObject); modification.cancel(); return false; } }
protected void removeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) { if (NetvirtProvidersProvider.isMasterProviderInstance()) { WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); modification.delete(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder)); CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit(); try { commitFuture.get(); // TODO: Make it async (See bug 1362) LOG.debug("Transaction success for deletion of Flow : {}", flowBuilder.getFlowName()); } catch (Exception e) { LOG.error("Failed to remove flow : {}", flowBuilder.getFlowName(), e); modification.cancel(); } } }
protected void writeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) { if (NetvirtProvidersProvider.isMasterProviderInstance()) { LOG.debug("writeFlow: flowBuilder: {}, nodeBuilder: {}", flowBuilder.build(), nodeBuilder.build()); WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); //modification.put(LogicalDatastoreType.CONFIGURATION, createNodePath(nodeBuilder), // nodeBuilder.build(), true /*createMissingParents*/); modification.put(LogicalDatastoreType.CONFIGURATION, createFlowPath(flowBuilder, nodeBuilder), flowBuilder.build(), true /*createMissingParents*/); CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit(); try { commitFuture.checkedGet(); // TODO: Make it async (See bug 1362) LOG.debug("Transaction success for write of Flow : {}", flowBuilder.getFlowName()); } catch (Exception e) { LOG.error("Failed to write flow : {}", flowBuilder.getFlowName(), e); modification.cancel(); } } }
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(); } }