aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy17
-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/util/OofInfraUtils.java103
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy100
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy63
-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.groovy110
8 files changed, 332 insertions, 185 deletions
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..df3399f1f0 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
@@ -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/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
new file mode 100644
index 0000000000..b62d8be281
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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);
+ Optional <CloudSite> optCloudsite = Optional.empty();
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ optCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/"));
+ } catch (Exception e) {
+ LOGGER.debug("Could not find cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Creating cloudSite: " + cloudSite.toString());
+ }
+ if (optCloudsite.isPresent() && (cloudSite.getId()) != optCloudsite.get().getId()) {
+ client.postCloudSite(cloudSite);
+ }
+ }
+
+ /**
+ * 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/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 34f2f0157d..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
@@ -39,7 +39,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import groovy.json.*
//import javax.ws.rs.core.Response
-import org.onap.so.utils.TargetEntity
+//import org.onap.so.utils.TargetEntity
/**
* This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -272,96 +272,30 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
msoLogger.trace("Started Execute VFC adapter Post Process ")
msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody)
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.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
-
- // Get the Basic Auth credentials for the VFCAdapter (yes... we ARE using the PO adapters credentials)
- String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
-
- msoLogger.debug("basicAuthValuePO: " + basicAuthValuePO)
- if (basicAuthValuePO == null || basicAuthValuePO.isEmpty()) {
- msoLogger.debug("mso:adapters:po:auth URN mapping is not defined")
- }
-
- RESTConfig config = new RESTConfig(urlString)
- RESTClient client = null;
- int statusCode = 0;
- try {
- client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuePO)
-
- apiResponse = client.httpPost(requestBody)
+ 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;
- statusCode = apiResponse.getStatusCode()
+ // 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")
- if(statusCode == 200 || statusCode == 201) {
- return apiResponse
- }
- }catch(Exception e){
- msoLogger.error("VFC Aatpter Post Call Exception using mso.adapters.po.auth:" + e.getMessage());
- }
-
- msoLogger.debug("response code:"+ statusCode +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
-
- msoLogger.debug("VFC Aatpter Post Call using mso.msoKey")
- String basicAuthValue = UrnPropertiesReader.getVariable("mso.msoKey", execution)
- msoLogger.debug("basicAuthValue: " + basicAuthValue)
- if (basicAuthValue == null || basicAuthValue.isEmpty()) {
- msoLogger.debug("mso:msoKey URN mapping is not defined")
- }
- try {
- client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValue)
-
apiResponse = client.httpPost(requestBody)
-
statusCode = apiResponse.getStatusCode()
- if(statusCode == 200 || statusCode == 201) {
- return apiResponse
- }
- }catch(Exception e){
- msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage());
-
- }
-
- msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+ msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
- msoLogger.debug("VFC Aatpter Post Call using mso.db.auth")
- String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution)
- msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
- if (basicAuthValuedb == null || basicAuthValuedb.isEmpty()) {
- msoLogger.debug("mso:db.auth URN mapping is not defined")
- }
- try {
- client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuedb)
-
- apiResponse = client.httpPost(requestBody)
- statusCode = apiResponse.getStatusCode()
-
- if(statusCode == 200 || statusCode == 201) {
- return apiResponse
- }
}catch(Exception e){
- msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage());
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VFC Aatpter Post Call Exception by using mso.msoKey or mso.adapters.po.auth")
+ msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
+ throw new BpmnError("MSOWorkflowException")
}
-
-
- msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
- String auth = "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"
- msoLogger.debug("auth: " + basicAuthValuedb)
- client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(auth)
-
- apiResponse = client.httpPost(requestBody)
-
- msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
msoLogger.trace("Completed Execute VF-C adapter Post Process ")
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 f4a542afe9..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,15 +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.
@@ -138,7 +141,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
"nsOperationKey":${nsOperationKey},
"nsParameters":${nsParameters}
}"""
- Response apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
+ APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String nsInstanceId = "";
@@ -167,7 +170,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
}"""
String nsInstanceId = execution.getVariable("nsInstanceId")
String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate"
- Response apiResponse = postRequest(execution, url, reqBody)
+ APIResponse apiResponse = postRequest(execution, url, reqBody)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = "";
@@ -187,7 +190,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = vfcAdapterUrl + "/jobs/" + jobId
- Response apiResponse = postRequest(execution, url, nsOperationKey)
+ APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
@@ -240,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 e0586163f1..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,16 +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
@@ -136,8 +139,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId")
- Response apiResponse = deleteRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
+ APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
String operationStatus = "error";
if(returnCode== "200" || returnCode== "202"){
operationStatus = "finished"
@@ -148,7 +152,7 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
}
/**
- * instantiate NS task
+ * terminate NS task
*/
public void terminateNetworkService(DelegateExecution execution) {
@@ -156,9 +160,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
String nsOperationKey = execution.getVariable("nsOperationKey")
String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
- Response apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
- String aaiResponseAsString = apiResponse.readEntity(String.class)
+ 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")
@@ -177,9 +181,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = vfcAdapterUrl + "/jobs/" + execution.getVariable("jobId")
- Response apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatus()
- String apiResponseAsString = apiResponse.readEntity(String.class)
+ 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")
@@ -211,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
@@ -239,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
}
}