diff options
author | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2023-11-23 10:23:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2023-11-23 10:23:45 +0000 |
commit | b5d03c741caac8c255e20a1245f709045c238e90 (patch) | |
tree | 43e35935fcd6b5c3e36639bb07527dc9f511ec40 /cps-ncmp-service/src/main | |
parent | c6dfb03f66eb4573c6fcea761e2414aadaaf7878 (diff) | |
parent | 8090317460b8076f128fd8da46873135b007e2fd (diff) |
Merge "Onboard merge subscriptions model"
Diffstat (limited to 'cps-ncmp-service/src/main')
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java | 15 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java) | 34 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang | 49 |
3 files changed, 81 insertions, 17 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java index cb2e15a3ce..fd5f2b0ed6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.time.OffsetDateTime; +import java.util.HashMap; import java.util.Map; import lombok.NonNull; import lombok.RequiredArgsConstructor; @@ -85,10 +86,10 @@ abstract class AbstractModelLoader implements ModelLoader { } } - void createSchemaSet(final String dataspaceName, final String schemaSetName, final String resourceName) { + void createSchemaSet(final String dataspaceName, final String schemaSetName, final String... resourceNames) { try { - final Map<String, String> yangResourceContentMap = createYangResourceToContentMap(resourceName); - cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, yangResourceContentMap); + final Map<String, String> yangResourcesContentMap = createYangResourcesToContentMap(resourceNames); + cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, yangResourcesContentMap); } catch (final AlreadyDefinedException alreadyDefinedException) { log.warn("Creating new schema set failed as schema set already exists"); } catch (final Exception exception) { @@ -140,8 +141,12 @@ abstract class AbstractModelLoader implements ModelLoader { } } - Map<String, String> createYangResourceToContentMap(final String resourceName) { - return Map.of(resourceName, getFileContentAsString("models/" + resourceName)); + Map<String, String> createYangResourcesToContentMap(final String... resourceNames) { + final Map<String, String> yangResourcesToContentMap = new HashMap<>(); + for (final String resourceName: resourceNames) { + yangResourcesToContentMap.put(resourceName, getFileContentAsString("models/" + resourceName)); + } + return yangResourcesToContentMap; } private String getFileContentAsString(final String fileName) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java index 4d1a91ca99..ade31e9ce6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java @@ -31,16 +31,23 @@ import org.springframework.stereotype.Service; @Slf4j @Service -public class SubscriptionModelLoader extends AbstractModelLoader { +public class CmDataSubscriptionModelLoader extends AbstractModelLoader { - private static final String MODEL_FILENAME = "subscription.yang"; - private static final String ANCHOR_NAME = "AVC-Subscriptions"; - private static final String SCHEMASET_NAME = "subscriptions"; - private static final String REGISTRY_DATANODE_NAME = "subscription-registry"; + private static final String MODEL_FILENAME = "cm-data-subscriptions@2023-11-13.yang"; + private static final String SCHEMASET_NAME = "cm-data-subscriptions"; + private static final String ANCHOR_NAME = "cm-data-subscriptions"; + private static final String REGISTRY_DATANODE_NAME = "datastores"; - public SubscriptionModelLoader(final CpsAdminService cpsAdminService, - final CpsModuleService cpsModuleService, - final CpsDataService cpsDataService) { + private static final String DEPRECATED_MODEL_FILENAME = "subscription.yang"; + private static final String DEPRECATED_ANCHOR_NAME = "AVC-Subscriptions"; + private static final String DEPRECATED_SCHEMASET_NAME = "subscriptions"; + private static final String DEPRECATED_REGISTRY_DATANODE_NAME = "subscription-registry"; + + + + public CmDataSubscriptionModelLoader(final CpsAdminService cpsAdminService, + final CpsModuleService cpsModuleService, + final CpsDataService cpsDataService) { super(cpsAdminService, cpsModuleService, cpsDataService); } @@ -51,17 +58,20 @@ public class SubscriptionModelLoader extends AbstractModelLoader { public void onboardOrUpgradeModel() { if (subscriptionModelLoaderEnabled) { waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME); - onboardSubscriptionModel(); - log.info("Subscription Model onboarded successfully"); + onboardSubscriptionModels(); + log.info("Subscription Models onboarded successfully"); } else { log.info("Subscription Model Loader is disabled"); } } - private void onboardSubscriptionModel() { + private void onboardSubscriptionModels() { + createSchemaSet(NCMP_DATASPACE_NAME, DEPRECATED_SCHEMASET_NAME, DEPRECATED_MODEL_FILENAME); + createAnchor(NCMP_DATASPACE_NAME, DEPRECATED_SCHEMASET_NAME, DEPRECATED_ANCHOR_NAME); + createTopLevelDataNode(NCMP_DATASPACE_NAME, DEPRECATED_ANCHOR_NAME, DEPRECATED_REGISTRY_DATANODE_NAME); + createSchemaSet(NCMP_DATASPACE_NAME, SCHEMASET_NAME, MODEL_FILENAME); createAnchor(NCMP_DATASPACE_NAME, SCHEMASET_NAME, ANCHOR_NAME); createTopLevelDataNode(NCMP_DATASPACE_NAME, ANCHOR_NAME, REGISTRY_DATANODE_NAME); } - } diff --git a/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang b/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang new file mode 100644 index 0000000000..de675b117c --- /dev/null +++ b/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang @@ -0,0 +1,49 @@ +module cm-data-subscriptions { + yang-version 1.1; + namespace "org:onap:cps:ncmp"; + + prefix cmds; + + revision "2023-11-13" { + description + "First release of cm data (notification) subscriptions model"; + } + + container datastores { + + list datastore { + key "name"; + + leaf name { + type string; + } + + container cm-handles { + + list cm-handle { + key "id"; + + leaf id { + type string; + } + + container filters { + + list filter { + key "xpath"; + + leaf xpath { + type string; + } + + leaf-list subscribers { + type string; + } + + } + } + } + } + } + } +} |