SfcPotRspProcessor { public static boolean enableSfcPot (RenderedServicePath rsp, final java.lang.Class<? extends TimeResolution> refreshPeriodTimeUnits, Long refreshPeriodValue, BitMaskOptions ioamPotProfileBitMask, Long ioamPotNumProfiles) { ServiceFunctionPath sfp; SfcName serviceFunctionChainNameObj; SfpName sfpName; ServiceFunctionChain serviceFunctionChain; RenderedServicePathBuilder renderedServicePathBuilder; RspIoamPotAugmentationBuilder rspIoamPotAugmentationBuilder; rspIoamPotAugmentationBuilder = new RspIoamPotAugmentationBuilder(); renderedServicePathBuilder = new RenderedServicePathBuilder(rsp); sfpName = rsp.getParentServiceFunctionPath(); if (sfpName == null) { LOG.warn("iOAM:PoT:Enable:ServiceFunctionPath is invalid."); return false; } sfp = SfcProviderServicePathAPI.readServiceFunctionPath(sfpName); serviceFunctionChainNameObj = sfp.getServiceChainName(); serviceFunctionChain = serviceFunctionChainNameObj != null ? SfcProviderServiceChainAPI.readServiceFunctionChain(serviceFunctionChainNameObj) : null; if (serviceFunctionChain == null) { LOG.error("iOAM:PoT:Enable:ServiceFunctionChain for Path:{} is invalid.", sfp.getName()); return false; } rspIoamPotAugmentationBuilder.setIoamPotEnable(true); rspIoamPotAugmentationBuilder.setRefreshPeriodTimeUnits(refreshPeriodTimeUnits); rspIoamPotAugmentationBuilder.setRefreshPeriodValue(refreshPeriodValue); rspIoamPotAugmentationBuilder.setIoamPotBitMask(ioamPotProfileBitMask); rspIoamPotAugmentationBuilder.setIoamPotNumProfiles(ioamPotNumProfiles); renderedServicePathBuilder.removeAugmentation(RspIoamPotAugmentation.class); renderedServicePathBuilder.addAugmentation(RspIoamPotAugmentation.class, rspIoamPotAugmentationBuilder.build()); RenderedServicePathKey renderedServicePathKey = new RenderedServicePathKey(renderedServicePathBuilder.getName()); InstanceIdentifier<RenderedServicePath> rspIID; rspIID = InstanceIdentifier.builder(RenderedServicePaths.class) .child(RenderedServicePath.class, renderedServicePathKey) .build(); RenderedServicePath renderedServicePath = renderedServicePathBuilder.build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, renderedServicePath, LogicalDatastoreType.OPERATIONAL)) { LOG.debug("iOAM:PoT:Enable:Updated RSP: {}", sfp.getName()); } else { LOG.warn("iOAM:PoT:Enable:{}:Failed to update Rendered Service Path:{}", Thread.currentThread().getStackTrace()[1], sfp.getName()); return false; } return true; } SfcPotRspProcessor(); static boolean enableSfcPot(RenderedServicePath rsp,
                            final java.lang.Class<? extends TimeResolution> refreshPeriodTimeUnits,
                            Long refreshPeriodValue, BitMaskOptions ioamPotProfileBitMask,
                            Long ioamPotNumProfiles); static boolean enableSfcPot(RspName rspName,
                        final java.lang.Class<? extends TimeResolution> refreshPeriodTimeUnits,
                        Long refreshPeriodValue, BitMaskOptions ioamPotProfileBitMask,
                        Long ioamPotNumProfiles); static boolean disableSfcPot(RspName rspName); static boolean disableSfcPot(RenderedServicePath rsp);  }
@Test public void enableSfcPot() { boolean ret; long numprofiles=2; RenderedServicePathKey renderedServicePathKey = new RenderedServicePathKey(RSP_NAME); RenderedServicePath renderedServicePath = createTestRenderedServicePath(); InstanceIdentifier<RenderedServicePath> rspIID; rspIID = InstanceIdentifier.builder(RenderedServicePaths.class) .child(RenderedServicePath.class, renderedServicePathKey) .build(); ret = SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, renderedServicePath, LogicalDatastoreType.OPERATIONAL); assertTrue(ret); ret = SfcPotRspProcessor.enableSfcPot(renderedServicePath, null, 1000L, null, numprofiles); assertTrue(ret); LOG.info("enableSfcPot returned success for :{}", RSP_NAME); RenderedServicePath rsp = SfcDataStoreAPI.readTransactionAPI(rspIID, LogicalDatastoreType.OPERATIONAL); assertNotNull(rsp); RspIoamPotAugmentation potAugmentation = null; potAugmentation = rsp.getAugmentation(RspIoamPotAugmentation.class); assertNotNull(potAugmentation); assertTrue(potAugmentation.isIoamPotEnable()); ret = SfcPotRspProcessor.disableSfcPot(renderedServicePath); assertTrue(ret); LOG.info("disableSfcPot returned success for :{}", RSP_NAME); rsp = SfcDataStoreAPI.readTransactionAPI(rspIID, LogicalDatastoreType.OPERATIONAL); assertNotNull(rsp); potAugmentation = rsp.getAugmentation(RspIoamPotAugmentation.class); assertNotNull(potAugmentation); assertFalse(potAugmentation.isIoamPotEnable()); DeleteRenderedPathInputBuilder inputBuilder = new DeleteRenderedPathInputBuilder(); inputBuilder.setName(RSP_NAME.getValue()); DeleteRenderedPathInput input = inputBuilder.build(); sfcProviderRpc.deleteRenderedPath(input); }