Fix for VID-927: Generated service instance name is not visible in Instantiation status table.
If user not provide Instance Name during set a new service instance, vid generate name base on service model name
(if the name is not unique, it will append the suffix)
Issue-ID: VID-927
Signed-off-by: marcinrzepeckiwroc <marcin.rzepecki@nokia.com>
Change-Id: I7d51c0d4b0b2c0765ba9f3a7302c591f19438dc4
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
index 17948d4..b69f76d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
@@ -189,11 +189,13 @@
}
private fun generateServiceName(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String): String? {
- var serviceInstanceName: String? = null
- if (StringUtils.isNotEmpty(optimisticUniqueServiceInstanceName)) {
- serviceInstanceName = peekServiceName(jobId, payload, optimisticUniqueServiceInstanceName)
+ var serviceInstanceName: String
+ if (StringUtils.isEmpty(optimisticUniqueServiceInstanceName)) {
+ serviceInstanceName = payload.modelInfo.modelName
+ } else {
+ serviceInstanceName = optimisticUniqueServiceInstanceName
}
- return serviceInstanceName
+ return peekServiceName(jobId, payload, serviceInstanceName)
}
private fun peekServiceName(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String): String {
@@ -202,7 +204,7 @@
if (isNameFreeInAai(optimisticUniqueServiceInstanceName, ResourceType.SERVICE_INSTANCE)) {
serviceInstanceName = optimisticUniqueServiceInstanceName
} else {
- serviceInstanceName = asyncInstantiationBL.getUniqueName(payload.instanceName, ResourceType.SERVICE_INSTANCE)
+ serviceInstanceName = asyncInstantiationBL.getUniqueName(optimisticUniqueServiceInstanceName, ResourceType.SERVICE_INSTANCE)
}//otherwise we used the original service instance name (from payload) to get a new unique name from DB and AAI
//update serviceInfo with new name if needed
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_no_homing.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_no_homing.json
index 4c8b4cd..967a464 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_no_homing.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_no_homing.json
@@ -18,6 +18,7 @@
"globalSubscriberId": "{some subscriber id}"
},
"requestInfo": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
"source": "VID",
"suppressRollback": false,
@@ -28,6 +29,7 @@
"aLaCarte": false,
"userParams": [{
"service": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"modelInfo": {
"modelType": "service",
"modelName": "MOW AVPN vMX BV vPE 1 Service",
@@ -97,4 +99,4 @@
]
}
}
-}
\ No newline at end of file
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
index 8676d53..1d5188e 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
@@ -18,6 +18,7 @@
"globalSubscriberId": "{some subscriber id}"
},
"requestInfo": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
"source": "VID",
"suppressRollback": false,
@@ -28,6 +29,7 @@
"aLaCarte": false,
"userParams": [{
"service": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"modelInfo": {
"modelType": "service",
"modelName": "MOW AVPN vMX BV vPE 1 Service",
@@ -95,4 +97,4 @@
}]
}
}
-}
\ No newline at end of file
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
index 22ac895..8345efa 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
@@ -18,6 +18,7 @@
"globalSubscriberId": "{some subscriber id}"
},
"requestInfo": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
"source": "VID",
"suppressRollback": false,
@@ -28,6 +29,7 @@
"aLaCarte": false,
"userParams": [{
"service": {
+ "instanceName": "MOW AVPN vMX BV vPE 1 Service",
"modelInfo": {
"modelType": "service",
"modelName": "MOW AVPN vMX BV vPE 1 Service",
@@ -66,4 +68,4 @@
}]
}
}
-}
\ No newline at end of file
+}