From: egernug Date: Thu, 25 Sep 2025 14:42:50 +0000 (+0100) Subject: Include a dmi-properties value at the top level X-Git-Tag: 3.7.2~17^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=7a1817819f43a0d3165f5f2bf7ec46be7bb05b6e;p=cps.git Include a dmi-properties value at the top level - Added dmi-properties to YangModelCmHandle - Amended tests to include new property Issue-ID: CPS-2987 Change-Id: Ib1b8bc99389afff55d4ab93f2a435fb86769e43e Signed-off-by: egernug --- diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml index 74543e698e..002dca19ee 100644 --- a/cps-ncmp-rest/docs/openapi/components.yaml +++ b/cps-ncmp-rest/docs/openapi/components.yaml @@ -155,6 +155,9 @@ components: cmHandleStatus: type: string example: "READY" + dmiProperties: + type: string + example: my-dmi-property #Module upgrade schema UpgradedCmHandles: required: @@ -285,6 +288,9 @@ components: cmHandleStatus: type: string example: "READY" + dmiProperties: + type: string + example: my-dmi-property CmHandleCompositeState: type: object properties: diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java index 8d58946f56..d035c488bc 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java @@ -60,6 +60,7 @@ public class RestOutputCmHandleMapper { restOutputCmHandle.setAlternateId(ncmpServiceCmHandle.getAlternateId()); restOutputCmHandle.setDataProducerIdentifier(ncmpServiceCmHandle.getDataProducerIdentifier()); restOutputCmHandle.setCmHandleStatus(ncmpServiceCmHandle.getCmHandleStatus()); + restOutputCmHandle.setDmiProperties(ncmpServiceCmHandle.getDmiProperties()); return restOutputCmHandle; } } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy index b467e0c2e0..8f46513c2b 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy @@ -49,6 +49,7 @@ class RestOutputCmHandleMapperSpec extends Specification { assert result.alternateId == 'alt-1' assert result.cmHandle == 'ch-1' assert result.cmHandleStatus == 'REPORTED STATE' + assert result.dmiProperties == 'dmi property' where: scenario | includeAdditionalProperties || trustLevel 'without additional properties' | false || null @@ -60,6 +61,7 @@ class RestOutputCmHandleMapperSpec extends Specification { return new NcmpServiceCmHandle(cmHandleId: 'ch-1', additionalProperties: ['additional property key': 'some value'], currentTrustLevel: trustLevel, publicProperties: ['public property key': 'public property value'], - alternateId: 'alt-1', compositeState: new CompositeState(cmHandleState: 'ADVISED'), cmHandleStatus: 'REPORTED STATE') + alternateId: 'alt-1', compositeState: new CompositeState(cmHandleState: 'ADVISED'), cmHandleStatus: 'REPORTED STATE', + dmiProperties: 'dmi property') } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java index 09ed1c3453..2f571f1c3d 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java @@ -77,4 +77,7 @@ public class NcmpServiceCmHandle { @JsonSetter(nulls = Nulls.AS_EMPTY) private String cmHandleStatus; + @JsonSetter(nulls = Nulls.AS_EMPTY) + private String dmiProperties; + } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java index 361559290e..f6f751e051 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java @@ -408,7 +408,8 @@ public class CmHandleRegistrationService { ncmpServiceCmHandle.getModuleSetTag(), ncmpServiceCmHandle.getAlternateId(), ncmpServiceCmHandle.getDataProducerIdentifier(), - ncmpServiceCmHandle.getCmHandleStatus()); + ncmpServiceCmHandle.getCmHandleStatus(), + ncmpServiceCmHandle.getDmiProperties()); } void removeAlternateIdsFromCache(final Collection yangModelCmHandles) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java index fc62c6931e..40009bd695 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java @@ -80,6 +80,9 @@ public class YangModelCmHandle { @JsonProperty("cm-handle-state") private String cmHandleStatus; + @JsonProperty("dmi-properties") + private String dmiProperties; + /** * Creates a deep copy of Yang Model Cm Handle. * @@ -102,6 +105,7 @@ public class YangModelCmHandle { copy.alternateId = original.getAlternateId(); copy.dataProducerIdentifier = original.getDataProducerIdentifier(); copy.cmHandleStatus = original.getCmHandleStatus(); + copy.dmiProperties = original.getDmiProperties(); return copy; } @@ -116,6 +120,7 @@ public class YangModelCmHandle { * @param alternateId alternateId * @param dataProducerIdentifier dataProducerIdentifier * @param cmHandleStatus cm handle status + * @param dmiProperties dmi properties * @return instance of yangModelCmHandle */ public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName, @@ -125,7 +130,8 @@ public class YangModelCmHandle { final String moduleSetTag, final String alternateId, final String dataProducerIdentifier, - final String cmHandleStatus) { + final String cmHandleStatus, + final String dmiProperties) { final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle(); yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId()); yangModelCmHandle.setDmiServiceName(dmiServiceName); @@ -139,6 +145,8 @@ public class YangModelCmHandle { yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getPublicProperties())); yangModelCmHandle.setCompositeState(ncmpServiceCmHandle.getCompositeState()); yangModelCmHandle.setCmHandleStatus(cmHandleStatus); + yangModelCmHandle.setDmiProperties(dmiProperties); + return yangModelCmHandle; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java index ce65f588c4..12b223a2be 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java @@ -60,6 +60,7 @@ public class YangDataConverter { ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId()); ncmpServiceCmHandle.setDataProducerIdentifier(yangModelCmHandle.getDataProducerIdentifier()); ncmpServiceCmHandle.setCmHandleStatus(yangModelCmHandle.getCmHandleStatus()); + ncmpServiceCmHandle.setDmiProperties(yangModelCmHandle.getDmiProperties()); setAdditionalProperties(additionalProperties, ncmpServiceCmHandle); setPublicProperties(publicProperties, ncmpServiceCmHandle); @@ -97,7 +98,8 @@ public class YangDataConverter { safeGetLeafValue(cmHandleDataNode, "module-set-tag"), safeGetLeafValue(cmHandleDataNode, "alternate-id"), safeGetLeafValue(cmHandleDataNode, "data-producer-identifier"), - safeGetLeafValue(cmHandleDataNode, "cm-handle-state") + safeGetLeafValue(cmHandleDataNode, "cm-handle-state"), + safeGetLeafValue(cmHandleDataNode, "dmi-properties") ); } @@ -140,6 +142,7 @@ public class YangDataConverter { ncmpServiceCmHandle.setAdditionalProperties(additionalProperties); ncmpServiceCmHandle.setPublicProperties(publicProperties); ncmpServiceCmHandle.setCompositeState(compositeState); + ncmpServiceCmHandle.setDmiProperties(ncmpServiceCmHandle.getDmiProperties()); } private static void addProperty(final DataNode propertyDataNode, final Map propertiesAsMap) { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy index f9b6a32de0..c1fe4f6bd8 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy @@ -39,6 +39,7 @@ class YangModelCmHandleSpec extends Specification { ncmpServiceCmHandle.cmHandleId = 'cm-handle-id01' ncmpServiceCmHandle.additionalProperties = [myAdditionalProperty:'value1'] ncmpServiceCmHandle.publicProperties = [myPublicProperty:'value2'] + ncmpServiceCmHandle.dmiProperties = [myDmiProperty:'value3'] and: 'with a composite state' def compositeState = new CompositeStateBuilder() .withCmHandleState(CmHandleState.LOCKED) @@ -47,7 +48,7 @@ class YangModelCmHandleSpec extends Specification { .withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, 'some-sync-time').build() ncmpServiceCmHandle.setCompositeState(compositeState) when: 'it is converted to a yang model cm handle' - def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier', 'ADVISED') + def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier', 'ADVISED', 'my-dmi-property') then: 'the result has the right size' assert objectUnderTest.additionalProperties.size() == 1 and: 'the result has the correct values for module set tag, alternate ID, and data producer identifier' @@ -65,12 +66,14 @@ class YangModelCmHandleSpec extends Specification { objectUnderTest.getCompositeState() == ncmpServiceCmHandle.getCompositeState() and: 'the cm-handle-state is correct' assert objectUnderTest.cmHandleStatus == 'ADVISED' + and: 'the dmi-properties are correct' + assert objectUnderTest.dmiProperties == 'my-dmi-property' } def 'Resolve DMI service name: #scenario and #requiredService service require.'() { given: 'a yang model cm handle' def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName, - dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '', '') + dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '', '', '') expect: assert objectUnderTest.resolveDmiServiceName(requiredService) == expectedService where: diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy index 8659718ff9..af2c7b759d 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy @@ -139,7 +139,7 @@ class ModuleSyncServiceSpec extends Specification { ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, '').build()) def dmiServiceName = 'some service name' ncmpServiceCmHandle.cmHandleId = 'upgraded-ch' - def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'', '', '', '') + def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'', '', '', '', '') and: 'DMI operations returns some module references for upgraded cm handle' def moduleReferences = [ new ModuleReference('module1','1') ] mockDmiModelOperations.getModuleReferences(yangModelCmHandle, NO_MODULE_SET_TAG) >> moduleReferences @@ -159,7 +159,7 @@ class ModuleSyncServiceSpec extends Specification { def ncmpServiceCmHandle = new NcmpServiceCmHandle() ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: ' + tagTo).build()) ncmpServiceCmHandle.setCmHandleId('cmHandleId-1') - def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, tagFrom, '', '', '') + def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, tagFrom, '', '', '', '') mockCmHandleQueries.cmHandleHasState('cmHandleId-1', CmHandleState.READY) >> true and: 'the module tag (schemaset) exists is #schemaExists' mockCpsModuleService.schemaSetExists(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, tagTo) >> schemaExists @@ -186,7 +186,7 @@ class ModuleSyncServiceSpec extends Specification { def ncmpServiceCmHandle = new NcmpServiceCmHandle() ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).build()) ncmpServiceCmHandle.cmHandleId = 'ch-1' - return YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '', '') + return YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '', '', '') } } diff --git a/docs/api/swagger/ncmp/openapi-inventory.yaml b/docs/api/swagger/ncmp/openapi-inventory.yaml index 7a77fe091f..61f666701e 100644 --- a/docs/api/swagger/ncmp/openapi-inventory.yaml +++ b/docs/api/swagger/ncmp/openapi-inventory.yaml @@ -323,6 +323,7 @@ components: key: my-property moduleSetTag: my-module-set-tag trustLevel: COMPLETE + dmiProperties: my-dmi-property - cmHandle: my-cm-handle alternateId: "Subnetwork=Europe,ManagedElement=X123" dataProducerIdentifier: my-data-producer-identifier @@ -333,6 +334,7 @@ components: key: my-property moduleSetTag: my-module-set-tag trustLevel: COMPLETE + dmiProperties: my-dmi-property createdCmHandles: - cmHandle: my-cm-handle alternateId: "Subnetwork=Europe,ManagedElement=X123" @@ -344,6 +346,7 @@ components: key: my-property moduleSetTag: my-module-set-tag trustLevel: COMPLETE + dmiProperties: my-dmi-property - cmHandle: my-cm-handle alternateId: "Subnetwork=Europe,ManagedElement=X123" dataProducerIdentifier: my-data-producer-identifier @@ -354,6 +357,7 @@ components: key: my-property moduleSetTag: my-module-set-tag trustLevel: COMPLETE + dmiProperties: my-dmi-property dmiPlugin: my-dmi-plugin dmiModelPlugin: my-dmi-model-plugin upgradedCmHandles: @@ -411,6 +415,7 @@ components: key: my-property moduleSetTag: my-module-set-tag trustLevel: COMPLETE + dmiProperties: my-dmi-property properties: cmHandle: example: my-cm-handle @@ -443,6 +448,9 @@ components: cmHandleStatus: example: READY type: string + dmiProperties: + example: my-dmi-property + type: string required: - cmHandle type: object @@ -643,6 +651,7 @@ components: lastUpdateTime: 2022-12-31T20:30:40.000+0000 trustLevel: COMPLETE moduleSetTag: my-module-set-tag + dmiProperties: my-dmi-property properties: cmHandle: example: my-cm-handle1 @@ -678,6 +687,9 @@ components: cmHandleStatus: example: READY type: string + dmiProperties: + example: my-dmi-property + type: string title: CM handle Details type: object CmHandleCompositeState: diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml index 5b0b0d6493..9d7d9794aa 100644 --- a/docs/api/swagger/ncmp/openapi.yaml +++ b/docs/api/swagger/ncmp/openapi.yaml @@ -1956,6 +1956,7 @@ components: lastUpdateTime: 2022-12-31T20:30:40.000+0000 trustLevel: COMPLETE moduleSetTag: my-module-set-tag + dmiProperties: my-dmi-property properties: cmHandle: example: my-cm-handle1 @@ -1991,6 +1992,9 @@ components: cmHandleStatus: example: READY type: string + dmiProperties: + example: my-dmi-property + type: string title: CM handle Details type: object CmHandleCompositeState: