summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy19
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy43
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java21
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java112
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java25
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy15
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy11
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy108
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy87
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy62
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy19
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy139
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java21
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java11
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java45
20 files changed, 551 insertions, 203 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index 926e09c498..42e9cb6d92 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -321,12 +321,12 @@
<dependency>
<groupId>org.onap.sdc.sdc-tosca</groupId>
<artifactId>sdc-tosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.onap.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index c50ef3530e..b03256b098 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -33,6 +33,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.db.catalog.beans.AuthenticationType
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.beans.HomingInstance
import org.onap.so.db.catalog.beans.ServerType
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
@@ -267,7 +268,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudIdentity.setAdminTenant("service")
cloudIdentity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD)
String msoMulticloudUserName = UrnPropertiesReader
- .getVariable("mso.multicloud.api.password", execution,
+ .getVariable("mso.multicloud.api.username", execution,
"apih")
String msoMulticloudPassword = UrnPropertiesReader
.getVariable("mso.multicloud.api.password", execution,
@@ -293,8 +294,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
+ " *****", "true")
// Set cloudsite in catalog DB here
- // TODO Get cloudsite and compare, set if not present
- oofUtils.createCloudSiteCatalogDb(cloudSite, execution)
+ oofUtils.createCloudSite(cloudSite, execution)
if (oofDirectives != null && oofDirectives != "") {
resource.getHomingSolution().setOofDirectives(oofDirectives)
@@ -303,6 +303,19 @@ class OofHoming extends AbstractServiceTaskProcessor {
" *****", "true")
}
+ // Set Homing Instance
+ String serviceInstanceId = decomposition.getServiceInstance().getInstanceId()
+ HomingInstance homingInstance = new HomingInstance()
+ homingInstance.setServiceInstanceId(serviceInstanceId)
+ homingInstance.setCloudOwner(cloudOwner)
+ homingInstance.setCloudRegionId(cloudRegionId)
+ if (oofDirectives != null && oofDirectives != "") {
+ homingInstance.setOofDirectives(oofDirectives)}
+ else {
+ homingInstance.setOofDirectives("{}")
+ }
+ oofUtils.createHomingInstance(homingInstance, execution)
+
if (inventoryType.equalsIgnoreCase("service")) {
resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean())
VnfResource vnf = new VnfResource()
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 19d19b8cea..f72fc47aa5 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -33,24 +33,16 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.core.domain.Subscriber
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
-import org.onap.so.db.catalog.client.CatalogDbClient
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.springframework.http.HttpEntity
-import org.springframework.http.HttpHeaders
-import org.springframework.web.util.UriComponentsBuilder
-
-import javax.ws.rs.core.MediaType
+import org.onap.so.db.catalog.beans.HomingInstance
import javax.ws.rs.core.UriBuilder
-
+import org.onap.so.bpmn.common.util.OofInfraUtils
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
class OofUtils {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
private AbstractServiceTaskProcessor utils
@@ -491,6 +483,7 @@ class OofUtils {
if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
return candidatesJson
}
+
/**
* This method creates a cloudsite in catalog database.
*
@@ -498,23 +491,19 @@ class OofUtils {
*
* @return void
*/
- Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
- String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
- CloudSite getCloudsite = null
+ Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ oofInfraUtils.createCloudSite(cloudSite, execution)
+ }
- CatalogDbClient catalogDbClient = new CatalogDbClient(endpoint, auth)
- try {
- getCloudsite = catalogDbClient.getCloudSite(cloudSite.getId().toString())
- } catch (Exception e) {
- e = null
- utils.log("DEBUG", "Could not find cloudsite : " + cloudSite.getId(), isDebugEnabled)
- utils.log("DEBUG", "Creating cloudSite: " + cloudSite.toString(), isDebugEnabled)
- }
- if (getCloudsite?.getId() != cloudSite.getId()) {
- catalogDbClient.postCloudSite(cloudSite)
- }
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param HomingInstance homingInstance
+ *
+ * @return void
+ */
+ Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ oofInfraUtils.createHomingInstance(homingInstance, execution)
}
String getMsbHost(DelegateExecution execution) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
index b4851ee7a4..5e05637bca 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
@@ -47,6 +47,9 @@ import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.client.HttpClient;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.rest.APIResponse;
+import org.onap.so.rest.RESTClient;
+import org.onap.so.rest.RESTConfig;
import org.onap.so.utils.TargetEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -261,10 +264,20 @@ public class ResourceRequestBuilder {
private static String getCsarFromUuid(String uuid) throws Exception {
String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
- HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
-
- Response response = client.get();
- String value = response.readEntity(String.class);
+
+ RESTClient restClient = new RESTClient(new RESTConfig(
+ UriBuilder.fromUri(catalogEndPoint)
+ .path(SERVICE_URL_TOSCA_CSAR)
+ .queryParam("serviceModelUuid", uuid)
+ .build().toURL().toString()
+ ));
+
+ restClient.addHeader("Accept", "application/json");
+ restClient.addAuthorizationHeader(UrnPropertiesReader.getVariable("mso.db.auth"));
+
+ APIResponse apiResponse = restClient.httpGet();
+
+ String value = apiResponse.getResponseBodyAsString();
HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
new file mode 100644
index 0000000000..df7b57f3a3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.common.util;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+public class OofInfraUtils {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofInfraUtils.class);
+
+ /**
+ * This method creates a cloudsite in catalog database.
+ *
+ * @param cloudSite
+ *
+ * @return void
+ */
+ public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+ try {
+ CloudSite getCloudsite;
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+
+ getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
+ if (!cloudSite.getId().equals(getCloudsite.getId())) {
+ client.postCloudSite(cloudSite);
+ LOGGER.debug("Did not findd cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will create cloudSite: " + cloudSite.toString());
+ }
+ else {
+ LOGGER.debug("Found cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will not create cloudSite: " + cloudSite.toString());
+ }
+ } catch (Exception e) {
+ LOGGER.debug("Error looking up or creating cloudsite : " + cloudSite.getId());
+ LOGGER.debug("CloudSite Lookup/Creation Error: " + e);
+ }
+
+
+ }
+
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param homingInstance
+ *
+ * @return void
+ */
+ public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ client.postHomingInstance(homingInstance);
+ } catch (Exception exception) {
+ LOGGER.debug("Could not create HomingInstance : " + homingInstance.getServiceInstanceId());
+ LOGGER.debug("HomingInstance Creation Error: " + exception);
+ }
+
+ }
+
+ /**
+ * This method gets a HomingInstance in catalog database.
+ *
+ * @param serviceInstanceId
+ *
+ * @return HomingInstance
+ */
+ public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/");
+ } catch (Exception exception) {
+ LOGGER.debug("Could not get HomingInstance for serviceInstanceId : " + serviceInstanceId);
+ LOGGER.debug("Get HomingInstance Error: " + exception);
+ }
+ return null;
+ }
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
index 9c80548490..52207f2156 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
@@ -25,24 +25,26 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
/**
- * An object that stores data for rollbacks. Data is organized by type. A
- * type is simply a string identifier. Multiple types of data may be stored
- * in the same object for separate rollback operations.
+ * An object that stores data for rollbacks. Data is organized by type. A type is simply a string
+ * identifier. Multiple types of data may be stored in the same object for separate rollback
+ * operations.
*/
public class RollbackData implements Serializable {
private static final long serialVersionUID = 1L;
- private Map<String, Map<String, Serializable>> dictionary =
- new HashMap<>();
+ @JsonProperty
+ private final Map<String, Map<String, Serializable>> dictionary = new HashMap<>();
/**
* Returns true if the specified type is stored in this object.
*
* @param type the data type
*/
- public boolean hasType(String type) {
+ public boolean hasType(final String type) {
return dictionary.containsKey(type);
}
@@ -53,9 +55,8 @@ public class RollbackData implements Serializable {
* @param key the key
* @param value the value
*/
- public void put(String type, String key, String value) {
- Map<String, Serializable> mapForType = dictionary
- .computeIfAbsent(type, k -> new HashMap<>());
+ public void put(final String type, final String key, final String value) {
+ final Map<String, Serializable> mapForType = dictionary.computeIfAbsent(type, k -> new HashMap<>());
mapForType.put(key, value);
}
@@ -67,8 +68,8 @@ public class RollbackData implements Serializable {
* @param key the key
* @return the item or null if there is no item for the specified type and key
*/
- public Serializable get(String type, String key) {
- Map<String, Serializable> mapForType = dictionary.get(type);
+ public Serializable get(final String type, final String key) {
+ final Map<String, Serializable> mapForType = dictionary.get(type);
if (mapForType == null) {
return null;
@@ -83,7 +84,7 @@ public class RollbackData implements Serializable {
* @param type the data type
* @return a map, or null if there are no items associated with the specified data type
*/
- public Map<String, Serializable> get(String type) {
+ public Map<String, Serializable> get(final String type) {
return dictionary.get(type);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
index b912b64145..580416ebd2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
@@ -53,7 +53,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
MsoUtils msoUtils = new MsoUtils()
public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
msoLogger.info(" ***** Started preProcessRequest *****")
try {
@@ -64,7 +63,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String resourceInput = execution.getVariable("resourceInput")
//Get ResourceInput Object
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
- execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
//Deal with recipeParams
String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
@@ -125,8 +124,8 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
- msg = "Exception in preProcessRequest " + ex.getMessage()
- msoLogger.debug( msg)
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
@@ -398,7 +397,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
} catch (Exception ex) {
String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
- msoLogger.debug( exceptionMessage)
+ msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
@@ -415,7 +414,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
}
public void sendSyncResponse(DelegateExecution execution) {
- msoLogger.dubug(" *** sendSyncResponse *** ")
+ msoLogger.info("started sendsyncResp")
try {
String operationStatus = "finished"
@@ -427,9 +426,9 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
} catch (Exception ex) {
String msg = "Exception in sendSyncResponse:" + ex.getMessage()
- msoLogger.debug( msg)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.dubug(" ***** Exit sendSyncResponse *****")
+ msoLogger.info("exited sendsyncResp")
}
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index a505f3ff5e..8e168a3cf1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -203,7 +203,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-ltp-id", inputParameters.get("local-access-ltp-id"))
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-node-id", inputParameters.get("local-access-node-id"))
resourceInputObj.setResourceParameters(uResourceInput)
- execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
}
break
@@ -539,10 +539,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
private def getInstnaceId(DelegateExecution execution) {
def responce = new XmlSlurper().parseText(execution.getVariable("CRENWKI_createSDNCResponse"))
- def data = responce.toString()
- data = data.substring(data.indexOf("<"))
- def resp = new XmlSlurper().parseText(data)
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class)
String modelName = resourceInputObj.getResourceModelInfo().getModelName()
def val = ""
@@ -550,18 +547,18 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
switch (modelName) {
case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ :
case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ :
- val = resp."network-response-information"."instance-id"
+ val = responce."response-data"."RequestData"."output"."network-response-information"."instance-id"
break
case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
case ~/[\w\s\W]*Site[\w\s\W]*/:
- val = resp."vnf-response-information"."instance-id"
+ val = responce."response-data"."RequestData"."output"."vnf-response-information"."instance-id"
break
case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/:
- val = resp."connection-attachment-response-information"."instance-id"
+ val = responce."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id"
break
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
index dabd3517c3..94df0a977a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
@@ -28,13 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
+//import org.onap.so.client.RestRequest
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.bpmn.core.UrnPropertiesReader
import groovy.json.*
-import javax.ws.rs.core.Response
-import org.onap.so.utils.TargetEntity
+//import javax.ws.rs.core.Response
+//import org.onap.so.utils.TargetEntity
/**
* This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -43,11 +48,10 @@ import org.onap.so.utils.TargetEntity
public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVFCNSResource.class);
+// String vfcUrl = "/vfc/rest/v1/vfcadapter"
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+// String host = "http://mso.mso.testlab.openecomp.org:8080"
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -116,6 +120,18 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
execution.setVariable("nsParameters", nsParameters)
execution.setVariable("nsServiceModelUUID", nsServiceModelUUID);
+ String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+
+ if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+ msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+ msoLogger.debug(msg)
+ }
+
+ while (vfcAdapterUrl.endsWith('/')) {
+ vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+ }
+
+ execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
} catch (BpmnError e) {
throw e;
@@ -132,6 +148,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
*/
public void createNetworkService(DelegateExecution execution) {
msoLogger.trace("createNetworkService ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID");
String nsParameters = execution.getVariable("nsParameters");
@@ -149,9 +166,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
"additionalParamForNs":${requestInputs}
}
}"""
- Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
- String returnCode = apiResponse.getStatus()
- String aaiResponseAsString = apiResponse.readEntity(String.class)
+ APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String nsInstanceId = "";
if(returnCode== "200" || returnCode == "201"){
nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
@@ -165,6 +182,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
*/
public void instantiateNetworkService(DelegateExecution execution) {
msoLogger.trace("instantiateNetworkService ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
@@ -176,10 +194,10 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
"nsParameters":${nsParameters}
}"""
String nsInstanceId = execution.getVariable("nsInstanceId")
- String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
- Response apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatus()
- String aaiResponseAsString = apiResponse.readEntity(String.class)
+ String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate"
+ APIResponse apiResponse = postRequest(execution, url, reqBody)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String jobId = "";
if(returnCode== "200"|| returnCode == "201"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -193,12 +211,13 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
*/
public void queryNSProgress(DelegateExecution execution) {
msoLogger.trace("queryNSProgress ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + jobId
- Response apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
- String aaiResponseAsString = apiResponse.readEntity(String.class)
+ String url = vfcAdapterUrl + "/jobs/" + jobId
+ APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String operationStatus = "error"
if(returnCode== "200"|| returnCode == "201"){
operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
@@ -214,7 +233,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
try {
Thread.sleep(5000);
} catch(InterruptedException e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e , "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ msoLogger.error( "Time Delay exception" + e.getMessage());
}
}
@@ -239,7 +258,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
getAAIClient().connect(nsUri,relatedServiceUri)
msoLogger.info("NS relationship to Service added successfully")
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while Creating NS relationship.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage(),e);
+ msoLogger.error("Exception occured while Creating NS relationship."+ e.getMessage());
throw new BpmnError("MSOWorkflowException")
}
}
@@ -249,26 +268,37 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
* url: the url of the request
* requestBody: the body of the request
*/
- private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+ private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process ")
- msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- Response apiResponse = null
- try{
-
- URL url = new URL(urlString);
-
- HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
- httpClient.addAdditionalHeader("Accept", "application/json")
- httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
- apiResponse = httpClient.post(requestBody)
-
- msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
- msoLogger.trace("Completed Execute VF-C adapter Post Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- throw new BpmnError("MSOWorkflowException")
- }
+ msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody)
+ APIResponse apiResponse = null
+ try{
+ // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+ def basicAuthHeaderValue = ""
+ RESTConfig config = new RESTConfig(urlString)
+ RESTClient client = null;
+ int statusCode = 0;
+
+ // user 'bepl' authHeader is the same with mso.db.auth
+ String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution)
+
+ client = new RESTClient(config)
+ client.addHeader("Accept", "application/json")
+ client.addAuthorizationHeader(basicAuthValuedb)
+ client.addHeader("Content-Type", "application/json")
+
+ apiResponse = client.httpPost(requestBody)
+ statusCode = apiResponse.getStatusCode()
+
+ msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
+ }catch(Exception e){
+ msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+ msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+
return apiResponse
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
index 61c88dbb03..f6e4fcc2ba 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -263,15 +263,14 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceModelUUID, requestAction)
if (resourceRecipe != null) {
- String recipeURL = BPMNProperties.getProperty("bpelURL", "http://bpmn-infra:8081") + resourceRecipe.getString("orchestrationUri")
+ String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + resourceRecipe.getString("orchestrationUri")
int recipeTimeOut = resourceRecipe.getInt("recipeTimeout")
String recipeParamXsd = resourceRecipe.get("paramXSD")
BpmnRestClient bpmnRestClient = new BpmnRestClient()
HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput, recipeParamXsd)
} else {
- String exceptionMessage = "Resource receipe is not found for resource modeluuid: " +
- resourceInput.getResourceModelInfo().getModelUuid()
+ String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + resourceModelUUID
msoLogger.trace(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 09f159ecd7..0502f7949a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -28,14 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.utils.TargetEntity
+//import org.onap.so.utils.TargetEntity
import groovy.json.*
-import javax.ws.rs.core.Response
+//import javax.ws.rs.core.Response
/**
* This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -44,9 +48,6 @@ import javax.ws.rs.core.Response
public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVFCNetworkServiceInstance.class);
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -100,6 +101,19 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
execution.setVariable("nsOperationKey", nsOperationKey);
execution.setVariable("nsParameters", nsParameters)
+ String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+
+ if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+ msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+ msoLogger.debug(msg)
+ }
+
+ while (vfcAdapterUrl.endsWith('/')) {
+ vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+ }
+
+ execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
+
} catch (BpmnError e) {
throw e;
@@ -116,6 +130,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
*/
public void createNetworkService(DelegateExecution execution) {
msoLogger.trace("createNetworkService")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
@@ -126,7 +141,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
"nsOperationKey":${nsOperationKey},
"nsParameters":${nsParameters}
}"""
- Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
+ APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String nsInstanceId = "";
@@ -142,6 +157,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
*/
public void instantiateNetworkService(DelegateExecution execution) {
msoLogger.trace("instantiateNetworkService")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
@@ -153,8 +169,8 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
"nsParameters":${nsParameters}
}"""
String nsInstanceId = execution.getVariable("nsInstanceId")
- String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
- Response apiResponse = postRequest(execution, url, reqBody)
+ String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate"
+ APIResponse apiResponse = postRequest(execution, url, reqBody)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = "";
@@ -170,10 +186,11 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
*/
public void queryNSProgress(DelegateExecution execution) {
msoLogger.trace("queryNSProgress")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + jobId
- Response apiResponse = postRequest(execution, url, nsOperationKey)
+ String url = vfcAdapterUrl + "/jobs/" + jobId
+ APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
@@ -226,26 +243,38 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+ private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process")
msoLogger.debug("url:"+urlString +"\nrequestBody:"+ requestBody)
- Response apiResponse = null
- try{
-
- URL url = new URL(urlString);
-
- HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
- httpClient.addAdditionalHeader("Accept", "application/json")
- httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
- apiResponse = httpClient.post(requestBody)
-
- msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
- msoLogger.trace("Completed Execute VF-C adapter Post Process")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
- throw new BpmnError("MSOWorkflowException")
- }
+ APIResponse apiResponse = null
+ try{
+ // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+ def basicAuthHeaderValue = ""
+ RESTConfig config = new RESTConfig(urlString)
+ RESTClient client = null;
+ int statusCode = 0;
+
+ // user 'bepl' authHeader is the same with mso.db.auth
+ String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution)
+ msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+
+ client = new RESTClient(config)
+ client.addHeader("Accept", "application/json")
+ client.addAuthorizationHeader(basicAuthValuedb)
+ client.addHeader("Content-Type", "application/json")
+
+ apiResponse = client.httpPost(requestBody)
+ statusCode = apiResponse.getStatusCode()
+
+ msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
+ }catch(Exception e){
+ msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+ msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+
return apiResponse
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index 58b90a1bf2..74926ce5b7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.db.catalog.beans.HomingInstance
+
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -35,6 +37,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VfModuleBase
+import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
@@ -75,6 +78,7 @@ public class DoCreateVfModule extends VfModuleBase {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
CatalogDbUtils catalog = new CatalogDbUtils()
DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil()
@@ -232,12 +236,37 @@ public class DoCreateVfModule extends VfModuleBase {
String globalSubscriberId = execution.getVariable("globalSubscriberId")
execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId)
msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
- //OofDirectives
- String oofDirectives = execution.getVariable("oofDirectives")
+
+ // Set Homing Info
+ String oofDirectives = null
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+ rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+ msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+ homingInstance.getCloudOwner())
+ oofDirectives = homingInstance.getOofDirectives()
+ execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
+ //OofDirectives to Input Params
Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
- if (oofDirectives != null) {
- vfModuleInputParams.put("oofDirectives", oofDirectives)
- logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+ if (oofDirectives != null && vfModuleInputParams != null) {
+ vfModuleInputParams.put("oof_directives", oofDirectives)
+ vfModuleInputParams.put("sdnc_directives", "{}")
+ msoLogger.debug("OofDirectives are: " + oofDirectives)
+ } else if (vfModuleInputParams != null) {
+ vfModuleInputParams.put("oof_directives", "{}")
+ vfModuleInputParams.put("sdnc_directives", "{}")
}
if (vfModuleInputParams != null) {
execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams)
@@ -464,11 +493,30 @@ public class DoCreateVfModule extends VfModuleBase {
}
//OofDirectives
- String oofDirectives = execution.getVariable("oofDirectives")
+ String oofDirectives = null
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+ rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+ msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+ homingInstance.getCloudOwner())
+ oofDirectives = homingInstance.getOofDirectives()
+ execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
if (oofDirectives != null) {
Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap")
paramsMap.put("oofDirectives", oofDirectives)
- logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+ msoLogger.debug("OofDirectives are: " + oofDirectives)
execution.setVariable("DCVFM_vnfParamsMap", paramsMap)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
index b35aab1176..deb0bffaf9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.db.catalog.beans.HomingInstance
+
import static org.apache.commons.lang3.StringUtils.*
import org.camunda.bpm.engine.delegate.BpmnError
@@ -31,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VidUtils
+import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
@@ -61,6 +64,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
VidUtils vidUtils = new VidUtils(this)
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
/**
* This method gets and validates the incoming
@@ -238,6 +242,21 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
execution.setVariable("DoCVNF_nfFunction", nfFunction)
msoLogger.debug("NF Function is: " + nfFunction)
+ // Set Homing Info
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
+
rollbackData.put("VNF", "rollbackSDNCAssign", "false")
rollbackData.put("VNF", "rollbackSDNCActivate", "false")
rollbackData.put("VNF", "rollbackVnfCreate", "false")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
index bae1349e3b..5ff93363d2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
@@ -25,15 +25,19 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.utils.TargetEntity
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+//import org.onap.so.utils.TargetEntity
+import org.onap.so.bpmn.core.UrnPropertiesReader
-import javax.ws.rs.core.Response
+//import javax.ws.rs.core.Response
/**
* This groovy class supports the <class>DoDeleteVFCNetworkServiceInstance.bpmn</class> process.
* flow for E2E ServiceInstance Delete
@@ -41,11 +45,6 @@ import javax.ws.rs.core.Response
public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVFCNetworkServiceInstance.class);
-
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
-
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -83,6 +82,20 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
}"""
execution.setVariable("nsOperationKey", nsOperationKey);
msoLogger.info("nsOperationKey:" + nsOperationKey)
+
+ String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+
+ if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+ msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+ msoLogger.debug(msg)
+ }
+
+ while (vfcAdapterUrl.endsWith('/')) {
+ vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+ }
+
+ execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
+
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
@@ -123,10 +136,12 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
public void deleteNetworkService(DelegateExecution execution) {
msoLogger.trace("deleteNetworkService start ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId")
- Response apiResponse = deleteRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
+ String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId")
+ APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String operationStatus = "error";
if(returnCode== "200" || returnCode== "202"){
operationStatus = "finished"
@@ -137,16 +152,17 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
}
/**
- * instantiate NS task
+ * terminate NS task
*/
public void terminateNetworkService(DelegateExecution execution) {
msoLogger.trace("terminateNetworkService start ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey")
- String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
- Response apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
- String aaiResponseAsString = apiResponse.readEntity(String.class)
+ String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
+ APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String jobId = "";
if(returnCode== "200" || returnCode== "202"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -161,12 +177,13 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
public void queryNSProgress(DelegateExecution execution) {
msoLogger.trace("queryNSProgress start ")
+ String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + execution.getVariable("jobId")
- Response apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
- String apiResponseAsString = apiResponse.readEntity(String.class)
+ String url = vfcAdapterUrl + "/jobs/" + execution.getVariable("jobId")
+ APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String apiResponseAsString = apiResponse.getResponseBodyAsString()
String operationProgress = "100"
if(returnCode== "200"){
operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress")
@@ -198,25 +215,34 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+ private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process ")
msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody)
- Response apiResponse = null
+ APIResponse apiResponse = null
try{
- URL url = new URL(urlString);
-
- HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
- httpClient.addAdditionalHeader("Accept", "application/json")
- httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
- apiResponse = httpClient.post(requestBody)
-
- msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
-
- msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+ // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+ def basicAuthHeaderValue = ""
+ RESTConfig config = new RESTConfig(urlString)
+ RESTClient client = null;
+ int statusCode = 0;
+
+ // user 'bepl' authHeader is the same with mso.db.auth
+ String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution)
+ msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+
+ client = new RESTClient(config)
+ client.addHeader("Accept", "application/json")
+ client.addAuthorizationHeader(basicAuthValuedb)
+ client.addHeader("Content-Type", "application/json")
+
+ apiResponse = client.httpPost(requestBody)
+ statusCode = apiResponse.getStatusCode()
+
+ msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
throw new BpmnError("MSOWorkflowException")
}
return apiResponse
@@ -226,24 +252,37 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private Response deleteRequest(DelegateExecution execution, String url, String requestBody){
+ private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){
msoLogger.trace("Started Execute VFC adapter Delete Process ")
msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- Response r
- try{
-
- URL Url = new URL(url)
- HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER)
- httpClient.addAdditionalHeader("Accept", "application/json")
- httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
- r = httpClient.delete(requestBody)
-
- msoLogger.trace("Completed Execute VF-C adapter Delete Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
- throw new BpmnError("MSOWorkflowException")
- }
- return r
+
+ APIResponse apiResponse = null
+ try{
+ // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+ def basicAuthHeaderValue = ""
+ RESTConfig config = new RESTConfig(url)
+ RESTClient client = null;
+ int statusCode = 0;
+
+ // user 'bepl' authHeader is the same with mso.db.auth
+ String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution)
+ msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+
+ client = new RESTClient(config)
+ client.addHeader("Accept", "application/json")
+ client.addAuthorizationHeader(basicAuthValuedb)
+ client.addHeader("Content-Type", "application/json")
+
+ apiResponse = client.httpDelete(requestBody)
+ statusCode = apiResponse.getStatusCode()
+
+ msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
+ }catch(Exception e){
+ msoLogger.error("Exception occured while executing VF-C Delete Call. Exception is: \n" + e.getMessage());
+ throw new BpmnError("MSOWorkflowException")
+ }
+ return apiResponse
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
index e753f79ebd..95b826f331 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
@@ -436,14 +436,19 @@ public class ServicePluginFactory {
Map<String, String> keys = uri.getURIKeys();
String uriString = uri.build().toString();
- AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, keys.get("pnf-name"));
-
- AAIResultWrapper wrapper = client.get(parent);
- Optional<Relationships> optRelationships = wrapper.getRelationships();
- if (optRelationships.isPresent()) {
- Relationships relationships = optRelationships.get();
-
- return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
+
+ if (uriString != null) {
+ // get the pnfname
+ String[] token = uriString.split("/");
+ AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, token[4]);
+
+ AAIResultWrapper wrapper = client.get(parent);
+ Optional<Relationships> optRelationships = wrapper.getRelationships();
+ if (optRelationships.isPresent()) {
+ Relationships relationships = optRelationships.get();
+
+ return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
+ }
}
return false;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
index 0a00a61f83..3108adaa53 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
@@ -289,9 +289,8 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
protected boolean isSend2SdncDirectly() {
logger.info("AbstractSdncOperationTask.isSend2SdncDirectly begin!");
- String sdncIp = UrnPropertiesReader.getVariable("sdnc-ip");
- String sdncPort = UrnPropertiesReader.getVariable("sdnc-port");
- if (!StringUtils.isBlank(sdncIp) && isIp(sdncIp) && !StringUtils.isBlank(sdncPort)) {
+ String sdncHost = UrnPropertiesReader.getVariable("sdnc.host");
+ if (!StringUtils.isBlank(sdncHost)) {
logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = true.");
return true;
}
@@ -317,6 +316,12 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
return returnPort;
}
+ protected String getSdncHost() {
+ String sdncHost = UrnPropertiesReader.getVariable("sdnc.host");
+ logger.info("AbstractSdncOperationTask.getSdncPort: returnPort = {}", sdncHost);
+ return sdncHost;
+ }
+
private GenericResourceApi getGenericResourceApiClient() {
logger.info("AbstractSdncOperationTask.getGenericResourceApiClient begin!");
String msbIp = System.getenv().get(ONAP_IP);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
index 8e41d0d88e..dc625d35c3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
@@ -72,7 +72,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
private void send2SdncDirectly(String defaulAuth,
RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException {
sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly begin!");
- String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL;
+ String url = getSdncHost() + URL;
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Authorization", defaulAuth);
httpPost.addHeader("Content-type", "application/json");
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 94eead2d05..acef0cb354 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -84,6 +84,7 @@ public class ExecuteActivity implements JavaDelegate {
variables.put("buildingBlock", executeBuildingBlock);
variables.put("mso-request-id", requestId);
variables.put("retryCount", 1);
+ variables.put("aLaCarte", true);
ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables).executeWithVariablesInReturn();
VariableMap variableMap = buildingBlockResult.getVariables();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
index b0063c1da1..2065dfb71e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
@@ -105,6 +105,10 @@ public class OrchestrationStatusValidator {
org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID));
orchestrationStatus = configuration.getOrchestrationStatus();
break;
+ case NO_VALIDATE:
+ //short circuit and exit method
+ execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
+ return;
default:
// can't currently get here, so not tested. Added in case enum is expanded without a change to this code
throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
new file mode 100644
index 0000000000..4ace2727be
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
@@ -0,0 +1,45 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.db.catalog.beans.BuildingBlockDetail;
+import org.onap.so.db.catalog.beans.OrchestrationAction;
+import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
+import org.onap.so.db.catalog.beans.ResourceType;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OrchestrationStatusValidatorUnitTest {
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @InjectMocks
+ private OrchestrationStatusValidator validator;
+ @Test
+ public void skipValidationTest() {
+ BuildingBlockDetail bbDetail = new BuildingBlockDetail();
+ bbDetail.setBuildingBlockName("customBB");
+ bbDetail.setResourceType(ResourceType.NO_VALIDATE);
+ bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
+ when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ execution.setVariable("flowToBeCalled", "customBB");
+ execution.setVariable("aLaCarte", false);
+ validator.validateOrchestrationStatus(execution);
+
+
+ assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
+ }
+
+}