diff options
author | lukegleeson <luke.gleeson@est.tech> | 2022-06-27 16:26:21 +0100 |
---|---|---|
committer | lukegleeson <luke.gleeson@est.tech> | 2022-06-30 16:58:52 +0100 |
commit | 884a5a0e8bf08cc47e0e0dbd7e20558212ca82b1 (patch) | |
tree | 0d4539725ebf366a54fcf00e01aa73f2c2e2761e /cps-ncmp-service/src/main/java | |
parent | 02082984687fd6e7c49d23bc1001f882c68b4ebb (diff) |
Allow Module Re-Sync
Allows the Resync of an already synced CmHandle
Currently: Advised -(create schemaset)-> Ready -(manual write)-> Advised -> Locked as schemaset for cmhandle already exists
With this: Advised -(create schemaset)-> Ready -(manual write)-> Advised -(delete schemaset, create schemaset)-> Ready
Included some logging
Renamed ModuleSyncSpec -> ModuleSyncWatchdogSpec to match class
Issue-ID: CPS-1045
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Change-Id: I408fbea698b7926dbf5d0cddc74acf1b00235b1f
Diffstat (limited to 'cps-ncmp-service/src/main/java')
2 files changed, 20 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java index 58e2bf3450..c574aa61d9 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java @@ -32,6 +32,8 @@ import org.onap.cps.api.CpsAdminService; import org.onap.cps.api.CpsModuleService; import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; +import org.onap.cps.spi.CascadeDeleteAllowed; +import org.onap.cps.spi.exceptions.SchemaSetNotFoundException; import org.onap.cps.spi.model.ModuleReference; import org.springframework.stereotype.Service; @@ -83,4 +85,21 @@ public class ModuleSyncService { schemaSetAndAnchorName); } + /** + * Deletes the SchemaSet for provided cmHandle if the SchemaSet Exists. + * + * @param yangModelCmHandle the yang model of cm handle. + */ + public void deleteSchemaSetIfExists(final YangModelCmHandle yangModelCmHandle) { + final String schemaSetAndAnchorName = yangModelCmHandle.getId(); + try { + cpsModuleService.deleteSchemaSet(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetAndAnchorName, + CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED); + log.debug("SchemaSet for {} has been deleted. Ready to be recreated.", schemaSetAndAnchorName); + } catch (final SchemaSetNotFoundException e) { + log.debug("No SchemaSet for {}. Assuming CmHandle has not been previously Module Synced.", + schemaSetAndAnchorName); + } + } + } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java index 402f9f6b4f..9383ac1ef7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java @@ -53,6 +53,7 @@ public class ModuleSyncWatchdog { final String cmHandleId = advisedCmHandle.getId(); final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId); try { + moduleSyncService.deleteSchemaSetIfExists(advisedCmHandle); moduleSyncService.syncAndCreateSchemaSetAndAnchor(advisedCmHandle); compositeState.setCmHandleState(CmHandleState.READY); } catch (final Exception e) { |