private boolean putOvsdbBridge(OvsdbBridgeAugmentation ovsdbBridge) { Preconditions.checkNotNull(ovsdbBridge, "Cannot PUT new OVS Bridge into OVS configuration store, OvsdbBridgeAugmentation is null."); return SfcDataStoreAPI.writeMergeTransactionAPI(SfcOvsUtil.buildOvsdbBridgeIID(ovsdbBridge), ovsdbBridge, LogicalDatastoreType.CONFIGURATION); }
@Override public Future<RpcResult<Void>> putServiceFunctionChains(PutServiceFunctionChainsInput input) { printTraceStart(LOG); ServiceFunctionChainsBuilder serviceFunctionChainsBuilder = new ServiceFunctionChainsBuilder(); serviceFunctionChainsBuilder = serviceFunctionChainsBuilder.setServiceFunctionChain(input.getServiceFunctionChain()); ServiceFunctionChains sfcs = serviceFunctionChainsBuilder.build(); if (!SfcDataStoreAPI.writeMergeTransactionAPI(OpendaylightSfc.SFC_IID, sfcs, LogicalDatastoreType.CONFIGURATION)) { LOG.error("Failed to create service function chain: {}", input.getServiceFunctionChain().toString()); } return Futures.immediateFuture(Rpcs.<Void>getRpcResult(true, Collections.<RpcError>emptySet())); }
public static boolean putServiceFunctionPath(ServiceFunctionPath sfp) { boolean ret = false; printTraceStart(LOG); InstanceIdentifier<ServiceFunctionPath> sfpEntryIID = InstanceIdentifier.builder(ServiceFunctionPaths.class) .child(ServiceFunctionPath.class, sfp.getKey()) .build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(sfpEntryIID, sfp, LogicalDatastoreType.CONFIGURATION)) { LOG.debug("Created Service Function Path: {}", sfp.getName()); ret = true; } else { LOG.error("Failed to create Service Function Path: {}", sfp.getName()); } printTraceStop(LOG); return ret; } }
/** * Set the PathId Generate-algorithm in the data-store. * * <p> * @param genAlgorithm enum string value as taken from service-path-id.yang * @return True if successful, otherwise false */ public static boolean setGenerationAlgorithm(GenerationAlgorithmEnum genAlgorithm) { InstanceIdentifier<ServicePathIds> spIID = InstanceIdentifier.builder(ServicePathIds.class).build(); ServicePathIdsBuilder servicePathIdsBuilder = new ServicePathIdsBuilder(); servicePathIdsBuilder.setGenerationAlgorithm(genAlgorithm); return SfcDataStoreAPI. writeMergeTransactionAPI(spIID, servicePathIdsBuilder.build(), LogicalDatastoreType.OPERATIONAL); }
/** * This method creates a SFC from the datastore. * * @param serviceFunctionChain SFC object * @return true if SFC was created, false otherwise */ public static boolean putServiceFunctionChain(ServiceFunctionChain serviceFunctionChain) { boolean ret = false; printTraceStart(LOG); InstanceIdentifier<ServiceFunctionChain> sfcEntryIID = InstanceIdentifier.builder(ServiceFunctionChains.class) .child(ServiceFunctionChain.class, serviceFunctionChain.getKey()) .build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(sfcEntryIID, serviceFunctionChain, LogicalDatastoreType.CONFIGURATION)) { ret = true; } else { LOG.error("Failed to create Service Function Chain: {}", serviceFunctionChain); } printTraceStop(LOG); return ret; } }
/** * This method puts a SF to data store. * <p> * * @param sf Service Function * @return true if SF was added, false otherwise */ public static boolean putServiceFunction(ServiceFunction sf) { boolean ret; printTraceStart(LOG); InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class).child(ServiceFunction.class, sf.getKey()).build(); ret = SfcDataStoreAPI.writeMergeTransactionAPI(sfEntryIID, sf, LogicalDatastoreType.CONFIGURATION); printTraceStop(LOG); return ret; }
public static boolean mergeServiceFunctionState(ServiceFunctionState sfState) { boolean ret; printTraceStart(LOG); ServiceFunctionStateKey serviceFunctionStateKey = new ServiceFunctionStateKey(sfState.getKey()); InstanceIdentifier<ServiceFunctionState> sfStateIID = InstanceIdentifier.builder(ServiceFunctionsState.class) .child(ServiceFunctionState.class, serviceFunctionStateKey) .build(); ret = SfcDataStoreAPI.writeMergeTransactionAPI(sfStateIID, sfState, LogicalDatastoreType.OPERATIONAL); printTraceStop(LOG); return ret; }
/** * We iterate through all service paths that use this service function and if * necessary, remove them. * * @param servicePathName Service Function Path name * @param renderedPathName Rendered Path name * @return Nothing. */ public static boolean addRenderedPathToServicePathState(SfpName servicePathName, RspName renderedPathName) { printTraceStart(LOG); InstanceIdentifier<SfpRenderedServicePath> rspIID; boolean ret = false; SfpRenderedServicePathBuilder sfpRenderedServicePathBuilder = new SfpRenderedServicePathBuilder(); SfpRenderedServicePathKey sfpRenderedServicePathKey = new SfpRenderedServicePathKey(renderedPathName); sfpRenderedServicePathBuilder.setKey(sfpRenderedServicePathKey).setName(renderedPathName); ServiceFunctionPathStateKey serviceFunctionPathStateKey = new ServiceFunctionPathStateKey(servicePathName); rspIID = InstanceIdentifier.builder(ServiceFunctionPathsState.class) .child(ServiceFunctionPathState.class, serviceFunctionPathStateKey) .child(SfpRenderedServicePath.class, sfpRenderedServicePathKey) .build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, sfpRenderedServicePathBuilder.build(), LogicalDatastoreType.OPERATIONAL)) { ret = true; } else { LOG.error("{}: Failed to create Service Function Path {} state. Rendered Service Path: {}", Thread.currentThread().getStackTrace()[1], servicePathName, renderedPathName); } printTraceStop(LOG); return ret; }
/** * Adds Classifier to Access List state * <p> * @param aclName Acl name * @param aclType Acl type * @param serviceClassifierName Service Classifier name * @return true if success. */ public static boolean addClassifierToAccessListState (String aclName, java.lang.Class<? extends AclBase> aclType, String serviceClassifierName) { printTraceStart(LOG); InstanceIdentifier<AclServiceFunctionClassifier> aclIID; boolean ret = false; AclServiceFunctionClassifierBuilder aclServiceClassifierBuilder = new AclServiceFunctionClassifierBuilder(); AclServiceFunctionClassifierKey aclServiceClassifierKey = new AclServiceFunctionClassifierKey(serviceClassifierName); aclServiceClassifierBuilder.setKey(aclServiceClassifierKey).setName(serviceClassifierName); AccessListStateKey accessListStateKey = new AccessListStateKey(aclName, aclType); aclIID = InstanceIdentifier.builder(AccessListsState.class) .child(AccessListState.class, accessListStateKey) .child(AclServiceFunctionClassifier.class, aclServiceClassifierKey) .build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(aclIID, aclServiceClassifierBuilder.build(), LogicalDatastoreType.OPERATIONAL)) { ret = true; } else { LOG.error("{}: Failed to create Access List {}:{} state. Service Function CLassifier: {}", Thread.currentThread().getStackTrace()[1], aclName, aclType, serviceClassifierName); } printTraceStop(LOG); return ret; }
if (SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, revRenderedServicePath, LogicalDatastoreType.OPERATIONAL)) { ret = revRenderedServicePath;
/** * This method gets all necessary information for a system to construct * a NSH header and associated overlay packet to target the first * service hop of a Rendered Service Path by ServiceFunctionTypeIdentity * list * <p> * * @param renderedServicePath RenderedServicePath Object * @param pathId Symmetric Path Id * @return true if symmetric path-id was set, otherwise false */ public static boolean setSymmetricPathId(RenderedServicePath renderedServicePath, long pathId) { RenderedServicePathKey renderedServicePathKey = new RenderedServicePathKey(renderedServicePath.getName()); InstanceIdentifier<RenderedServicePath> rspIID; rspIID = InstanceIdentifier.builder(RenderedServicePaths.class) .child(RenderedServicePath.class, renderedServicePathKey) .build(); RenderedServicePathBuilder renderedServicePathBuilder = new RenderedServicePathBuilder(renderedServicePath); renderedServicePathBuilder.setSymmetricPathId(pathId); return SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, renderedServicePathBuilder.build(), LogicalDatastoreType.OPERATIONAL); } }
if (SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, renderedServicePath, LogicalDatastoreType.OPERATIONAL)) { ret = renderedServicePath; } else {
/** * Allocate Pathid * * <p> * @param pathid Path Id to be allocated * @return True if allocated, otherwise false. */ public static boolean allocate_pathid(long pathid) { ServicePathIdKey servicePathIdKey = new ServicePathIdKey(pathid/Long.SIZE); /* Entry into the bitarray */ long bitEntry = pathid % Long.SIZE; long pathIdBitArray = 0; InstanceIdentifier<ServicePathId> spIID; spIID = InstanceIdentifier.builder(ServicePathIds.class) .child(ServicePathId.class, servicePathIdKey) .build(); ServicePathId servicePathId = SfcDataStoreAPI. readTransactionAPI(spIID, LogicalDatastoreType.OPERATIONAL); if (servicePathId != null) { pathIdBitArray = (servicePathId.getPathIdBitarray() != null) ? servicePathId.getPathIdBitarray() : 0; } ServicePathIdBuilder servicePathIdBuilder = new ServicePathIdBuilder(); servicePathIdBuilder.setPathIdBitarray(pathIdBitArray | (1L << (Long.SIZE - bitEntry))); servicePathIdBuilder.setKey(servicePathIdKey); return SfcDataStoreAPI. writeMergeTransactionAPI(spIID, servicePathIdBuilder.build(), LogicalDatastoreType.OPERATIONAL); }
if (SfcDataStoreAPI.writeMergeTransactionAPI(sftentryIID, sftServiceFunctionName, LogicalDatastoreType.CONFIGURATION)) { ret = true;
writeMergeTransactionAPI(spIID, servicePathIdBuilder.build(), LogicalDatastoreType.OPERATIONAL); } finally { SfcConcurrencyAPI.releasePathIdLock();