import org.json.JSONObject
import org.onap.aai.domain.yang.Relationship
import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.domain.ServiceInfo
import org.onap.so.bpmn.core.domain.ServiceProxy
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.aaiclient.client.aai.AAIObjectType
-import org.onap.aaiclient.client.aai.AAIResourcesClient
-import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
-import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.so.db.request.beans.OperationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import org.springframework.util.StringUtils
import org.springframework.web.util.UriUtils
import static org.apache.commons.lang3.StringUtils.isBlank
Map<String, ?> csInputMap = new HashMap<>()
for (String csInput : csInputs) {
- def value
- if (jsonUtil.getJsonValue(csInput, "type") == "integer") {
- value = jsonUtil.getJsonValue(csInput, "default")
- csInputMap.put(jsonUtil.getJsonValue(csInput, "name"), isBlank(value) ? 0 : (value as Integer))
- } else if (jsonUtil.getJsonValue(csInput, "type") == "string") {
- csInputMap.put(jsonUtil.getJsonValue(csInput, "name"),
- jsonUtil.getJsonValue(csInput, "default"))
- }
+ String key = jsonUtil.getJsonValue(csInput, "name")
+ def value = jsonUtil.getJsonValue(csInput, "default")
+ csInputMap.put(key, getDefaultPropertiesByType(value, key))
}
csInputMap.put("expDataRateDL", expDataRateDL)
csInputMap.put("expDataRateUL", expDataRateUL)
csInputMap.put("useInterval", useInterval)
execution.setVariable("csInputMap", csInputMap)
+ logger.debug(Prefix + "csInputMap is = " + csInputMap.toString())
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
/**
* get E2EST id through CST id and change communication profile to E2E service profile
* 1. get E2EST id from cst
- * 1.1 查source service id
+ * 1.1 source service id
* 1.2 source service
* 1.3 source service input, init e2e profile
*/
Map<String, ?> csInputMap = execution.getVariable("csInputMap") as Map
Map<String, ?> e2eInputMap = new HashMap<>()
- String key
- def value
-
for (String e2eInput in e2eInputs) {
- key = jsonUtil.getJsonValue(e2eInput, "name")
+ String key = jsonUtil.getJsonValue(e2eInput, "name")
String type = jsonUtil.getJsonValue(e2eInput, "type")
- if (type == "integer") {
- def temp
- value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp)
-
- e2eInputMap.put(key, value as Integer)
- } else if(type == "string") {
- e2eInputMap.put(key, csInputMap.containsKey(key)
- ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default")))
+ def value
+ if (csInputMap.containsKey(key)) {
+ value = csInputMap.get(key)
+ } else {
+ value = jsonUtil.getJsonValue(e2eInput, "default")
}
+ e2eInputMap.put(key, getDefaultPropertiesByType(value, type))
}
- //TODO
+ //TODO temp solution
e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id"))
e2eInputMap.put("sST", execution.getVariable("csServiceType"))
+
+ Integer activityFactor = Integer.parseInt(e2eInputMap.get("activityFactor").toString())
+ Integer random = new Random().nextInt(5) + 2
+ Integer dLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateDL").toString())
+ Integer uLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateUL").toString())
+ Integer maxNumberofUEs = Integer.parseInt(e2eInputMap.get("maxNumberofUEs").toString())
+ Integer dLThptPerSlice = dLThptPerUE * maxNumberofUEs * activityFactor * random
+ Integer uLThptPerSlice = uLThptPerUE * maxNumberofUEs * activityFactor * random
+ Integer maxNumberofConns = maxNumberofUEs * activityFactor * 3
+
+ e2eInputMap.put("jitter", 10)
+ e2eInputMap.put("dLThptPerUE", dLThptPerUE)
+ e2eInputMap.put("uLThptPerUE", uLThptPerUE)
+ e2eInputMap.put("dLThptPerSlice", dLThptPerSlice)
+ e2eInputMap.put("uLThptPerSlice", uLThptPerSlice)
+ e2eInputMap.put("maxNumberofConns", maxNumberofConns)
+
execution.setVariable("e2eInputMap", e2eInputMap)
execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType())
execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid())
execution.setVariable("e2eModelUuid", e2eServiceDecomposition.getModelInfo().getModelUuid())
-
+ logger.debug(Prefix + "e2eInputMap is = " + e2eInputMap.toString())
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
logger.debug(Prefix + "generateE2EServiceProfile Exit")
}
+ static def getDefaultPropertiesByType(def value, String type) {
+
+ def defaultValue
+ switch (type) {
+ case "string":
+ defaultValue = ""
+ break
+ case "integer":
+ defaultValue = 0
+ break
+ case "float":
+ defaultValue = 0.0
+ break
+ default:
+ defaultValue = null
+ break
+ }
+ return StringUtils.isEmpty(value) ? defaultValue : value
+ }
/**
* call createE2EService get operation id,
}
"""
execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", ""))
-
+ logger.debug(Prefix + "Sent to NSMF Request = " + payload)
} catch (BpmnError e) {
throw e
} catch (Exception ex) {
String msg
try {
String serviceInstanceId = execution.getVariable("serviceInstanceId")
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- execution.getVariable("globalSubscriberId"),
- execution.getVariable("subscriptionServiceType"),
- serviceInstanceId).relationshipAPI()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(serviceInstanceId)).relationshipAPI()
client.create(uri, relationship)
} catch (BpmnError e) {
// create service
ServiceInstance csi = new ServiceInstance()
csi.setOrchestrationStatus(orchestrationStatus)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId))
client.update(uri, csi)
logger.debug(Prefix + "updateFinishStatusInAAI update communication service status to deactivated")