X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2Fso-bpmn-infrastructure-common%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fonap%2Fso%2Fbpmn%2Finfrastructure%2Fscripts%2FCreateCommunicationService.groovy;h=bb6fe212b35c91ba45a37609d27e5bd08f280bb3;hb=73416d2bebe39643e30c91d0ce5a6f4d3f91ce62;hp=f8eafe7e98572e3b738b5624c2e14e3c454f9769;hpb=27d9076c191384779c76151c119c69e763bc6c35;p=so.git diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index f8eafe7e98..bb6fe212b3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -26,6 +26,10 @@ import org.camunda.bpm.engine.delegate.DelegateExecution 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 @@ -36,13 +40,10 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition 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 @@ -317,14 +318,9 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { Map 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) @@ -336,6 +332,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { csInputMap.put("useInterval", useInterval) execution.setVariable("csInputMap", csInputMap) + logger.debug(Prefix + "csInputMap is = " + csInputMap.toString()) } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -350,7 +347,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { /** * 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 */ @@ -365,33 +362,45 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { Map csInputMap = execution.getVariable("csInputMap") as Map Map 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) { @@ -403,6 +412,25 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { 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, @@ -433,7 +461,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { } """ execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", "")) - + logger.debug(Prefix + "Sent to NSMF Request = " + payload) } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -538,10 +566,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { 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) { @@ -633,8 +658,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { // 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")