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.groovy62
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy61
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java134
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java134
-rw-r--r--bpmn/so-bpmn-infrastructure-common/pom.xml5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy11
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy1
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/pom.xml5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java615
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java101
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java123
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java95
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java97
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java149
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java)48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java115
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java123
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofCallbackInfraVnf.json50
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml6
27 files changed, 2341 insertions, 102 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 35e68bb79f..70f91671a8 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
@@ -24,8 +24,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.bpmn.core.domain.CloudFlavor
+
import org.onap.so.bpmn.core.domain.InventoryType
import org.onap.so.bpmn.core.domain.Resource
import org.onap.so.bpmn.core.domain.ResourceType
@@ -33,7 +32,8 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition
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.logger.MsoLogger
+import org.onap.so.db.catalog.beans.CloudIdentity
+import org.onap.so.db.catalog.beans.CloudSite
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
@@ -52,7 +52,6 @@ import static org.onap.so.bpmn.common.scripts.GenericUtils.*
*/
class OofHoming extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofHoming.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
OofUtils oofUtils = new OofUtils(this)
@@ -114,10 +113,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
def authHeader = ""
String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
-
-
-
String basicAuthValue = utils.encrypt(basicAuth, msokey)
if (basicAuthValue != null) {
utils.log("DEBUG", "Obtained BasicAuth username and password for OOF Adapter: " + basicAuthValue,
@@ -156,8 +152,8 @@ class OofHoming extends AbstractServiceTaskProcessor {
execution.setVariable("oofRequest", oofRequest)
utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled)
- String endpoint = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.endpoint", execution);
- String host = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.host", execution);
+ String endpoint = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.endpoint", execution)
+ String host = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.host", execution)
String url = host + endpoint
utils.log("DEBUG", "Posting to OOF Url: " + url, isDebugEnabled)
@@ -240,30 +236,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
}
resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
- // TODO Deal with Placement Solutions & Assignment Info here
JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
- Integer arrayIndex = 0
- Integer flavorsIndex = null
- Boolean foundFlavors = false
- String flavors = null
- Map<String, String> flavorsMap = null
- ArrayList<CloudFlavor> flavorsArrayList = new ArrayList<CloudFlavor>()
+ String oofDirectives = null
assignmentArr.each { element ->
JSONObject jsonObject = new JSONObject(element.toString())
- if (jsonUtil.getJsonRawValue(jsonObject.toString(), "key") == "flavors") {
- flavors = jsonUtil.getJsonRawValue(jsonObject.toString(), "value")
- foundFlavors = true
- flavorsIndex = arrayIndex
- } else {
- arrayIndex += 1
- }
- }
- if (foundFlavors) {
- assignmentArr.remove(flavorsIndex)
- flavorsMap = jsonUtil.jsonStringToMap(execution, flavors.toString())
- flavorsMap.each { label, flavor ->
- CloudFlavor cloudFlavor = new CloudFlavor(label, flavor)
- flavorsArrayList.add(cloudFlavor)
+ if (jsonUtil.getJsonRawValue(jsonObject.toString(), "key") == "oof_directives") {
+ oofDirectives = jsonUtil.getJsonRawValue(jsonObject.toString(), "value")
}
}
Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
@@ -272,10 +250,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
String cloudRegionId = assignmentMap.get("locationId")
resource.getHomingSolution().setCloudOwner(cloudOwner)
resource.getHomingSolution().setCloudRegionId(cloudRegionId)
- if (flavorsArrayList != null && flavorsArrayList.size != 0) {
- resource.getHomingSolution().setFlavors(flavorsArrayList)
- execution.setVariable(cloudRegionId + "_flavorList", flavorsArrayList)
- utils.log("DEBUG", "***** _flavorList is: " + flavorsArrayList.toString() +
+
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId(cloudRegionId)
+ cloudSite.setRegionId(cloudRegionId)
+ String orchestrator = execution.getVariable("orchestrator")
+ if ((orchestrator != null) || (orchestrator != "")) {
+ cloudSite.setOrchestrator(orchestrator)
+ }
+
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setId(cloudRegionId);
+ cloudIdentity.setIdentityUrl("/api/multicloud /v1/" + cloudOwner + "/" + cloudRegionId + "/infra_workload")
+ cloudSite.setIdentityService(cloudIdentity);
+
+ // Set cloudsite in catalog DB here
+ oofUtils.createCloudSiteCatalogDb(cloudSite)
+
+ if (oofDirectives != null && oofDirectives != "") {
+ resource.getHomingSolution().setOofDirectives(oofDirectives)
+ utils.log("DEBUG", "***** OofDirectives is: " + oofDirectives +
" *****", "true")
}
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 8ce633845b..d95795906f 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
@@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts
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.common.scripts.MsoUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.HomingSolution
import org.onap.so.bpmn.core.domain.ModelInfo
import org.onap.so.bpmn.core.domain.Resource
@@ -33,22 +33,32 @@ 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.logger.MsoLogger
-
-import java.lang.reflect.Array
+import org.onap.so.db.catalog.beans.CloudSite
+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.http.HttpMethod
+import org.springframework.http.ResponseEntity
+import org.springframework.http.client.BufferingClientHttpRequestFactory
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
+import org.springframework.web.client.RestTemplate
+import org.springframework.web.util.UriComponentsBuilder
+
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
+import javax.xml.ws.http.HTTPException
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
class OofUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofUtils.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
private AbstractServiceTaskProcessor utils
- public MsoUtils msoUtils = new MsoUtils()
-
- public OofUtils(AbstractServiceTaskProcessor taskProcessor) {
+ OofUtils(AbstractServiceTaskProcessor taskProcessor) {
this.utils = taskProcessor
}
@@ -466,4 +476,39 @@ class OofUtils {
if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
return candidatesJson
}
+ /**
+ * This method creates a cloudsite in catalog database.
+ *
+ * @param CloudSite cloudSite
+ *
+ * @return void
+ */
+ Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
+
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
+ String uri = "/cloudSite"
+
+ HttpHeaders headers = new HttpHeaders()
+
+ headers.set(HttpHeaders.AUTHORIZATION, auth)
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(endpoint + uri)
+ HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers)
+ RESTConfig config = new RESTConfig(endpoint + uri)
+ RESTClient client = new RESTClient(config).addAuthorizationHeader(auth).
+ addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ APIResponse response = client.httpPost(request.getBody().toString())
+
+ int responseCode = response.getStatusCode()
+ logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled)
+ String syncResponse = response.getResponseBodyAsString()
+ logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled)
+
+ if(responseCode != 202){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
+ }
+ }
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index 57e6864943..e4eb01e7fb 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -45,7 +45,7 @@ public class HomingSolution extends JsonWrapper implements Serializable {
private String aicVersion;
private String tenant;
private VnfResource vnf;
- private List<CloudFlavor> flavors;
+ private String oofDirectives;
private License license = new License();
@@ -130,12 +130,12 @@ public class HomingSolution extends JsonWrapper implements Serializable {
/**
* @return a map<string, string> key is label name, value is any flavor
*/
- public List<CloudFlavor> getFlavors() {
- return flavors;
+ public String getOofDirectives() {
+ return oofDirectives;
}
- public void setFlavors(List<CloudFlavor> flavors) {
- this.flavors = flavors;
+ public void setOofDirectives(String oofDirectives) {
+ this.oofDirectives = oofDirectives;
}
public License getLicense() {
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
index 9bcc5593e2..d2dbde4843 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
@@ -38,7 +38,6 @@ import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.core.domain.AllottedResource;
-import org.onap.so.bpmn.core.domain.CloudFlavor;
import org.onap.so.bpmn.core.domain.HomingSolution;
import org.onap.so.bpmn.core.domain.ModelInfo;
import org.onap.so.bpmn.core.domain.NetworkResource;
@@ -122,12 +121,133 @@ public class OofHomingIT extends BaseIntegrationTest {
VnfResource vnf = new VnfResource();
vnf.setResourceId("testResourceIdVNF");
vnf.setNfFunction("testVnfFunctionName");
- ArrayList<CloudFlavor> flavors = new ArrayList<>();
- CloudFlavor flavor1 = new CloudFlavor("flavorLabel1xxx", "vimFlavorxxx");
- CloudFlavor flavor2 = new CloudFlavor("flavorLabel2xxx", "vimFlavorxxx");
- flavors.add(flavor1);
- flavors.add(flavor2);
- vnf.getHomingSolution().setFlavors(flavors);
+ vnf.getHomingSolution().setOofDirectives(
+ "{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_id\":\"<ID of VNFC>\",\n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
+ " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
+ " \"attribute_value\":\"<value such as direct/normal>\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
+ " \"attribute_value\":\"<value such as physnet>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"vnf_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"sdnc_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_id\":\"<ID of VNFC>\",\n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
+ " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
+ " \"attribute_value\":\"<value such as direct/normal>\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
+ " \"attribute_value\":\"<value such as physnet>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"vnf_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " }");
ModelInfo vnfModel = new ModelInfo();
vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
index 33e444310f..748552623e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
@@ -26,7 +26,6 @@ import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.core.domain.AllottedResource;
-import org.onap.so.bpmn.core.domain.CloudFlavor;
import org.onap.so.bpmn.core.domain.HomingSolution;
import org.onap.so.bpmn.core.domain.ModelInfo;
import org.onap.so.bpmn.core.domain.NetworkResource;
@@ -126,12 +125,133 @@ public class OofHomingTestIT extends BaseIntegrationTest {
VnfResource vnf = new VnfResource();
vnf.setResourceId("testResourceIdVNF");
vnf.setResourceInstanceName("testVnfInstanceName");
- ArrayList<CloudFlavor> flavors = new ArrayList<>();
- CloudFlavor flavor1 = new CloudFlavor("flavorLabel1xxx", "vimFlavorxxx");
- CloudFlavor flavor2 = new CloudFlavor("flavorLabel2xxx", "vimFlavorxxx");
- flavors.add(flavor1);
- flavors.add(flavor2);
- vnf.getHomingSolution().setFlavors(flavors);
+ vnf.getHomingSolution().setOofDirectives(
+ "{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_id\":\"<ID of VNFC>\",\n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
+ " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
+ " \"attribute_value\":\"<value such as direct/normal>\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
+ " \"attribute_value\":\"<value such as physnet>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"vnf_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"sdnc_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_directives\":[ \n" +
+ " { \n" +
+ " \"vnfc_id\":\"<ID of VNFC>\",\n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
+ " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
+ " \"attribute_value\":\"<value such as direct/normal>\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
+ " \"attribute_value\":\"<value such as physnet>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"vnf_directives\":{ \n" +
+ " \"directives\":[ \n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value>\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " { \n" +
+ " \"directive_name\":\"<Name of directive>\",\n" +
+ " \"attributes\":[ \n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " },\n" +
+ " { \n" +
+ " \"attribute_name\":\"<name of attribute>\",\n" +
+ " \"attribute_value\":\"<value >\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " }");
ModelInfo vnfModel = new ModelInfo();
vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml
index ad51b3f69e..3523703ee8 100644
--- a/bpmn/so-bpmn-infrastructure-common/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-common/pom.xml
@@ -197,11 +197,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
-
- </dependency>
- <dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
</dependency>
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 59d38bfe86..0f50ae6c27 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
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.scripts
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
-import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
@@ -38,7 +37,7 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.core.domain.CloudFlavor
+
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.DecomposeJsonUtil
import org.onap.so.bpmn.core.json.JsonUtils
@@ -174,8 +173,8 @@ public class DoCreateVfModule extends VfModuleBase {
execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId)
rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId)
msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
- //flavorList
- ArrayList<CloudFlavor> flavorList = execution.getVariable(cloudSiteId + "_flavorList")
+ //OofDirectives
+ String oofDirectives = execution.getVariable(cloudSiteId + "_oofDirectives")
if (flavorList != null) {
execution.setVariable("DCVFM_flavorList", flavorList)
logDebug("flavorList is: " + flavorList, isDebugLogEnabled)
@@ -921,8 +920,8 @@ public class DoCreateVfModule extends VfModuleBase {
def serviceId = execution.getVariable("DCVFM_serviceId")
//serviceInstanceId
def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId")
- //flavorList
- ArrayList<CloudFlavor> flavorList = execution.getVariable("DCVFM_flavorList")
+ //OofDirectives
+ String oofDirectives = execution.getVariable("DCVFM_oofDirectives")
//backoutOnFailure
def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure")
//volumeGroupId
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
index 86c5f65e8c..dd135f3af5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
@@ -232,6 +232,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
}
if ("Homing_Solution".equals(userParam?.name)) {
execution.setVariable("homingService", userParam.value)
+ execution.setVariable("callHoming", true)
inputMap.put("Homing_Solution", userParam.value)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml
index 4db7b3ff66..63b66cafe5 100644
--- a/bpmn/so-bpmn-infrastructure-flows/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml
@@ -168,11 +168,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
-
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java
new file mode 100644
index 0000000000..f65dde1af5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java
@@ -0,0 +1,615 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.buildingblock;
+
+import org.apache.commons.lang.SerializationUtils;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import java.util.ArrayList;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.License;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate;
+import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType;
+import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionCandidates;
+import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoMetadata;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.oof.OofClient;
+import org.onap.so.client.oof.OofValidator;
+import org.onap.so.client.oof.beans.ModelInfo;
+import org.onap.so.client.oof.beans.OofRequest;
+import org.onap.so.client.oof.beans.OofRequestParameters;
+import org.onap.so.client.oof.beans.PlacementDemand;
+import org.onap.so.client.oof.beans.PlacementInfo;
+import org.onap.so.client.oof.beans.RequestInfo;
+import org.onap.so.client.oof.beans.ResourceModelInfo;
+import org.onap.so.client.oof.beans.ServiceInfo;
+import org.onap.so.client.oof.beans.SubscriberInfo;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+import org.springframework.web.util.UriUtils;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+
+/**
+ * The oof homing building block obtains licensing and homing solutions for a given
+ * resource or set of resources.
+ *
+ */
+@Component("OofHoming")
+public class OofHomingV2 {
+
+ private static final Logger logger = LoggerFactory.getLogger(OofHomingV2.class);
+ private JsonUtils jsonUtils = new JsonUtils();
+ @Autowired
+ private Environment env;
+ @Autowired
+ private OofClient client;
+ @Autowired
+ private OofValidator oofValidator;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ private static final String MODEL_NAME = "modelName";
+ private static final String MODEL_INVARIANT_ID = "modelInvariantId";
+ private static final String MODEL_VERSION_ID = "modelVersionId";
+ private static final String MODEL_VERSION = "modelVersion";
+ private static final String SERVICE_RESOURCE_ID = "serviceResourceId";
+ private static final String RESOURCE_MODULE_NAME = "resourceModuleName";
+ private static final String RESOURCE_MODEL_INFO = "resourceModelInfo";
+ private static final String IDENTIFIER_TYPE = "identifierType";
+ private static final String INVENTORY_TYPE = "inventoryType";
+ private static final String SOLUTIONS = "solutions";
+ private static final String RESOURCE_MISSING_DATA = "Resource does not contain: ";
+ private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: ";
+ private static final String UNPROCESSABLE = "422";
+ private static final int INTERNAL = 500;
+
+ /**
+ * Generates the request payload then sends to Oof to perform homing and
+ * licensing for the provided demands
+ *
+ * @param execution
+ */
+ public void callOof(BuildingBlockExecution execution){
+ logger.trace("Started Sniro Homing Call Sniro");
+ try{
+ GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
+
+ RequestContext requestContext = bb.getRequestContext();
+ RequestParameters requestParams = requestContext.getRequestParameters();
+ String requestId = requestContext.getMsoRequestId();
+
+ ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
+ Customer customer = bb.getCustomer();
+
+ String timeout = execution.getVariable("timeout");
+ if(isBlank(timeout)){
+ timeout = env.getProperty("oof.timeout", "PT30M");
+ }
+
+ OofRequest request = new OofRequest();
+
+ RequestInfo requestInfo = (RequestInfo)buildRequestInfo(requestId, timeout);
+ request.setRequestInformation(requestInfo);
+
+ ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
+ request.setServiceInformation(serviceInfo);
+
+ PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams);
+
+ ArrayList<PlacementDemand> placementDemands = buildPlacementDemands(serviceInstance);
+ placementInfo.setPlacementDemands(placementDemands);
+ request.setPlacementInformation(placementInfo);
+
+ JSONObject licenseInfo = new JSONObject();
+
+ JSONArray licenseDemands = buildLicenseDemands(serviceInstance);
+ licenseInfo.put("licenseDemands", licenseDemands);
+ request.setLicenseInformation(licenseInfo.toString());
+
+ if(placementDemands.size() > 0 || licenseDemands.length() > 0){
+ client.postDemands(request);
+ }else{
+ logger.debug(SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
+ }
+
+ //Variables for ReceiveWorkflowMessage subflow
+ execution.setVariable("asyncCorrelator", requestId);
+ execution.setVariable("asyncMessageType", "OofResponse");
+ execution.setVariable("asyncTimeout", timeout);
+
+ logger.trace("Completed Oof Homing Call Oof");
+ }catch(BpmnError e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
+ }catch(BadResponseException e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing oof request: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Validates, processes, and sets the homing and licensing solutions that are returned by
+ * Oof
+ *
+ * @param execution
+ * @param asyncResponse
+ */
+ public void processSolution(BuildingBlockExecution execution, String asyncResponse){
+ logger.trace("Started Oof Homing Process Solution");
+ try{
+ oofValidator.validateSolution(asyncResponse);
+ ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ logger.debug("Processing Oof asyncronous response");
+ JSONObject response = new JSONObject(asyncResponse);
+ if(response.has(SOLUTIONS)){
+ JSONObject allSolutions = response.getJSONObject(SOLUTIONS);
+ if(allSolutions.has("placementSolutions")){
+ JSONArray placementSolutions = allSolutions.getJSONArray("placementSolutions");
+ for(int i = 0; i < placementSolutions.length(); i++){
+ JSONArray placements = placementSolutions.getJSONArray(i);
+ processPlacementSolution(serviceInstance, placements, i);
+ }
+ }
+ if(allSolutions.has("licenseSolutions")){
+ JSONArray licenseSolutions = allSolutions.getJSONArray("licenseSolutions");
+ if(licenseSolutions.length() > 0){
+ processLicenseSolution(serviceInstance, licenseSolutions);
+ }
+ }
+ }else{
+ throw new BpmnError(UNPROCESSABLE, "Oof response does not contain: " + SOLUTIONS);
+ }
+
+ execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock());
+
+ logger.trace("Completed Oof Homing Process Solution");
+ }catch(BpmnError e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
+ }catch(BadResponseException e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while processing Oof asynchronous response: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Builds the request information section for the homing/licensing request
+ *
+ * @throws Exception
+ */
+ private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception{
+ logger.trace("Building request information");
+ RequestInfo requestInfo = new RequestInfo();
+ if(requestId != null){
+ String host = env.getProperty("mso.workflow.message.endpoint");
+ String callbackUrl = host + "/" + UriUtils.encodePathSegment("OofResponse", "UTF-8") + "/" + UriUtils.encodePathSegment(requestId, "UTF-8");
+
+ Duration d = Duration.parse(timeout);
+ long timeoutSeconds = d.getSeconds();
+
+ requestInfo.setTransactionId(requestId);
+ requestInfo.setRequestId(requestId);
+ requestInfo.setCallbackUrl(callbackUrl);
+ requestInfo.setSourceId("mso");
+ requestInfo.setRequestType("create");
+ requestInfo.setTimeout(timeoutSeconds);
+ } else{
+ throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId");
+ }
+ return requestInfo;
+ }
+
+ /**
+ * Builds the request information section for the homing/licensing request
+ *
+ */
+ private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance){
+ logger.trace("Building service information");
+ ServiceInfo info = new ServiceInfo();
+ ModelInfoServiceInstance modelInfo = serviceInstance.getModelInfoServiceInstance();
+ if(isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())){
+ info.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ if(modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0){ //temp solution
+ info.setServiceName(modelInfo.getServiceType());
+ }
+ info.setModelInfo(buildModelInfo(serviceInstance.getModelInfoServiceInstance()));
+ }else{
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID);
+ }
+ return info;
+ }
+
+ /**
+ * Builds initial section of placement info for the homing/licensing request
+ *
+ */
+ private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams){
+ PlacementInfo placementInfo = new PlacementInfo();
+ if(customer != null){
+ logger.debug("Adding subscriber to placement information");
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId(customer.getGlobalCustomerId());
+ subscriberInfo.setSubscriberName(customer.getSubscriberName());
+ subscriberInfo.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId());
+ placementInfo.setSubscriberInfo(subscriberInfo);
+ if(requestParams != null){
+ logger.debug("Adding request parameters to placement information");
+ OofRequestParameters oofRequestParams = new OofRequestParameters();
+ for (Map requestParam : requestParams.getUserParams()){
+ if (requestParam.containsKey("customerLatitude")){
+ oofRequestParams.setCustomerLatitude(requestParam.get("customerLatitude").toString());
+ }
+ if (requestParam.containsKey("customerLongitude")){
+ oofRequestParams.setCustomerLongitude(requestParam.get("customerLongitude").toString());
+ }
+ if (requestParam.containsKey("customerName")){
+ oofRequestParams.setCustomerName(requestParam.get("customerName").toString());
+ }
+ }
+ placementInfo.setRequestParameters(oofRequestParams);
+ }
+ }else{
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer");
+ }
+ return placementInfo;
+
+ }
+
+ /**
+ * Builds the placement demand list for the homing/licensing request
+ *
+ */
+ private ArrayList<PlacementDemand> buildPlacementDemands(ServiceInstance serviceInstance){
+ logger.trace("Building placement information demands");
+ ArrayList<PlacementDemand> placementDemands = new ArrayList();
+
+ List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
+ if(!allottedResourceList.isEmpty()){
+ logger.debug("Adding allotted resources to placement demands list");
+ for(AllottedResource ar : allottedResourceList){
+ if(isBlank(ar.getId())){
+ ar.setId(UUID.randomUUID().toString());
+ }
+ PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
+ //addCandidates(ar, demand);
+ placementDemands.add(demand);
+ }
+ }
+ List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
+ if(!vpnBondingLinkList.isEmpty()){
+ logger.debug("Adding vpn bonding links to placement demands list");
+ for(VpnBondingLink vbl:vpnBondingLinkList){
+ List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
+ for(ServiceProxy sp : serviceProxyList){
+ if(isBlank(sp.getId())){
+ sp.setId(UUID.randomUUID().toString());
+ }
+ PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
+ //addCandidates(sp, demand);
+ placementDemands.add(demand);
+ }
+ }
+ }
+ return placementDemands;
+ }
+
+ /**
+ * Builds the license demand list for the homing/licensing request
+ *
+ */
+ private JSONArray buildLicenseDemands(ServiceInstance serviceInstance){
+ logger.trace("Building license information");
+ JSONArray licenseDemands = new JSONArray();
+ List<GenericVnf> vnfList = serviceInstance.getVnfs();
+ if(!vnfList.isEmpty()){
+ logger.debug("Adding vnfs to license demands list");
+ for(GenericVnf vnf : vnfList){
+ JSONObject demand = buildLicenseDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf());
+ licenseDemands.put(demand);
+ }
+ }
+ return licenseDemands;
+ }
+
+ /**
+ * Builds a single license demand object
+ *
+ */
+ private JSONObject buildLicenseDemand(String id, ModelInfoMetadata metadata){
+ logger.debug("Building demand for service or resource: " + id);
+ JSONObject demand = new JSONObject();
+ if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){
+ demand.put(SERVICE_RESOURCE_ID, id);
+ demand.put(RESOURCE_MODULE_NAME, metadata.getModelInstanceName());
+ demand.put(RESOURCE_MODEL_INFO, buildModelInfo(metadata));
+ }else{
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
+ }
+ return demand;
+ }
+
+ /**
+ * Builds a single demand object
+ *
+ */
+ private PlacementDemand buildDemand(String id, ModelInfoMetadata metadata){
+ logger.debug("Building demand for service or resource: " + id);
+ PlacementDemand placementDemand = new PlacementDemand();
+ if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){
+ placementDemand.setServiceResourceId(id);
+ placementDemand.setResourceModuleName(metadata.getModelInstanceName());
+ placementDemand.setResourceModelInfo((ResourceModelInfo) buildModelInfo(metadata));
+ }else{
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
+ }
+ return placementDemand;
+ }
+
+ /**
+ * Builds the resource model info section
+ *
+ */
+ private ModelInfo buildModelInfo(ModelInfoMetadata metadata){
+ ModelInfo modelInfo = new ModelInfo();
+ String invariantUuid = metadata.getModelInvariantUuid();
+ String modelUuid = metadata.getModelUuid();
+ if(isNotBlank(invariantUuid) && isNotBlank(modelUuid)){
+ modelInfo.setModelInvariantId(invariantUuid);
+ modelInfo.setModelVersionId(modelUuid);
+ modelInfo.setModelName(metadata.getModelName());
+ modelInfo.setModelVersion(metadata.getModelVersion());
+ }else if(isNotBlank(invariantUuid)){
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_VERSION_ID);
+ }else{
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_INVARIANT_ID);
+ }
+ return modelInfo;
+ }
+
+ /**
+ * Adds required, excluded, and existing candidates to a demand
+ *
+ */
+ private void addCandidates(SolutionCandidates candidates, JSONObject demand){
+ List<Candidate> required = candidates.getRequiredCandidates();
+ List<Candidate> excluded = candidates.getExcludedCandidates();
+ if(!required.isEmpty()){
+ demand.put("requiredCandidates", required);
+ }
+ if(!excluded.isEmpty()){
+ demand.put("excludedCandidates", excluded);
+ }
+ //TODO support existing candidates
+ }
+
+ /**
+ * Processes the license solutions and sets to the corresponding generic vnf
+ *
+ */
+ private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions){
+ List<GenericVnf> vnfs = serviceInstance.getVnfs();
+
+ logger.debug("Processing the license solution");
+ for(int i = 0; i < licenseSolutions.length(); i++){
+ JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
+ for(GenericVnf vnf:vnfs){
+ if(licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
+ License license = new License();
+ JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
+ List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
+ license.setEntitlementPoolUuids(entitlementPoolsList);
+ JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID");
+ List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys);
+ license.setLicenseKeyGroupUuids(licenseKeysList);
+
+ vnf.setLicense(license);
+ }
+ }
+ }
+ }
+
+ /**
+ * Processes a placement solution list then correlates and sets each placement solution
+ * to its corresponding resource
+ *
+ */
+ private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i){
+ List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks();
+ List<AllottedResource> allottes = serviceInstance.getAllottedResources();
+ List<GenericVnf> vnfs = serviceInstance.getVnfs();
+
+ logger.debug("Processing placement solution " + i+1);
+ for(int p = 0; p < placements.length(); p++){
+ JSONObject placement = placements.getJSONObject(p);
+ SolutionInfo solutionInfo = new SolutionInfo();
+ solutionInfo.setSolutionId(i + 1);
+ search: {
+ for(VpnBondingLink vbl:links){
+ List<ServiceProxy> proxies = vbl.getServiceProxies();
+ for(ServiceProxy sp:proxies){
+ if(placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())){
+ if(i > 0){
+ if(p % 2 == 0){
+ VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl);
+ vblNew.setVpnBondingLinkId(UUID.randomUUID().toString());
+ links.add(vblNew);
+ }
+ links.get(links.size() - 1).getServiceProxy(sp.getId()).setServiceInstance(setSolution(solutionInfo, placement));
+ }else{
+ sp.setServiceInstance(setSolution(solutionInfo, placement));
+ }
+ break search;
+ }
+ }
+ }
+ for(AllottedResource ar:allottes){
+ if(placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())){
+ ar.setParentServiceInstance(setSolution(solutionInfo, placement));
+ break search;
+ }
+ }
+ for(GenericVnf vnf:vnfs){
+ if(placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
+ ServiceInstance si = setSolution(solutionInfo, placement);
+ serviceInstance.setSolutionInfo(si.getSolutionInfo());
+ serviceInstance.getVnfs().add(si.getVnfs().get(0));
+ break search;
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Creates and sets necessary pojos with placement solution data for a given demand
+ *
+ */
+ private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement){
+ logger.debug("Mapping placement solution");
+ String invalidMessage = "Oof Response contains invalid: ";
+
+ JSONObject solution = placement.getJSONObject("solution");
+ String identifierType = solution.getString(IDENTIFIER_TYPE);
+ List<String> identifiersList = jsonUtils.StringArrayToList(solution.getJSONArray("identifiers").toString());
+ String identifierValue = identifiersList.get(0);
+
+ JSONArray assignments = placement.getJSONArray("assignmentInfo");
+ Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value");
+ solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome")));
+ String type = placement.getString(INVENTORY_TYPE);
+
+ ServiceInstance si = new ServiceInstance();
+ CloudRegion cloud = setCloud(assignmentsMap);
+ if(type.equals("service")){
+ if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){
+ solutionInfo.setHomed(true);
+ si.setServiceInstanceId(identifierValue);
+ si.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId"));
+ if(assignmentsMap.containsKey("vnfHostName")){
+ logger.debug("Resources has been homed to a vnf");
+ GenericVnf vnf = setVnf(assignmentsMap);
+ vnf.setCloudRegion(cloud);
+ si.getVnfs().add(vnf);
+
+ }else if(assignmentsMap.containsKey("primaryPnfName")){
+ logger.debug("Resources has been homed to a pnf");
+ Pnf priPnf = setPnf(assignmentsMap, "primary");
+ priPnf.setCloudRegion(cloud);
+ si.getPnfs().add(priPnf);
+ if(assignmentsMap.containsKey("secondaryPnfName")){
+ Pnf secPnf = setPnf(assignmentsMap, "secondary");
+ secPnf.setCloudRegion(cloud);
+ si.getPnfs().add(secPnf);
+ }
+ }
+ }else{
+ logger.debug(invalidMessage + IDENTIFIER_TYPE);
+ throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
+ }
+ }else if(type.equals("cloud")){
+ if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){
+ logger.debug("Resources has been homed to a cloud region");
+ cloud.setLcpCloudRegionId(identifierValue);
+ solutionInfo.setHomed(false);
+ solutionInfo.setTargetedCloudRegion(cloud);
+ si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ }else{
+ logger.debug(invalidMessage + IDENTIFIER_TYPE);
+ throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
+ }
+ }else{
+ logger.debug(invalidMessage + INVENTORY_TYPE);
+ throw new BpmnError(UNPROCESSABLE, invalidMessage + INVENTORY_TYPE);
+ }
+ si.setSolutionInfo(solutionInfo);
+ return si;
+ }
+
+ /**
+ * Sets the cloud data to a cloud region object
+ *
+ */
+ private CloudRegion setCloud(Map<String, String> assignmentsMap){
+ CloudRegion cloud = new CloudRegion();
+ cloud.setCloudOwner(assignmentsMap.get("cloudOwner"));
+ cloud.setCloudRegionVersion(assignmentsMap.get("aicVersion"));
+ cloud.setComplex(assignmentsMap.get("aicClli"));
+ return cloud;
+ }
+
+ /**
+ * Sets the vnf data to a generic vnf object
+ *
+ */
+ private GenericVnf setVnf(Map<String, String> assignmentsMap){
+ GenericVnf vnf = new GenericVnf();
+ vnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ vnf.setVnfName(assignmentsMap.get("vnfHostName"));
+ vnf.setVnfId(assignmentsMap.get("vnfId"));
+ return vnf;
+ }
+
+ /**
+ * Sets the pnf data to a pnf object
+ *
+ */
+ private Pnf setPnf(Map<String, String> assignmentsMap, String role){
+ Pnf pnf = new Pnf();
+ pnf.setRole(role);
+ pnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ pnf.setPnfName(assignmentsMap.get(role + "PnfName"));
+ return pnf;
+ }
+
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 02459d789d..2d5638c2b7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -103,6 +103,7 @@ public class WorkflowAction {
private static final String CREATEINSTANCE = "createInstance";
private static final String USERPARAMSERVICE = "service";
private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances";
+ private static final String HOMINGSOLUTION = "Homing_Solution";
private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
@Autowired
@@ -160,6 +161,18 @@ public class WorkflowAction {
execution.setVariable("resourceId", resourceId);
execution.setVariable("resourceType", resourceType);
+ if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters()
+ .getUserParams();
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(HOMINGSOLUTION)) {
+ execution.setVariable("homing", true);
+ execution.setVariable("callHoming", true);
+ execution.setVariable("homingSolution", params.get(HOMINGSOLUTION));
+ }
+ }
+ }
+
if (aLaCarte) {
if (orchFlows == null || orchFlows.isEmpty()) {
orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
new file mode 100644
index 0000000000..fa039c235c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.client.oof;
+
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.onap.so.bpmn.common.baseclient.BaseClient;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.oof.beans.OofProperties;
+import org.onap.so.client.oof.beans.OofRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.LinkedHashMap;
+
+@Component
+public class OofClient {
+
+ private static final Logger logger = LoggerFactory.getLogger(OofClient.class);
+ public static final String X_MINOR_VERSION = "X-MinorVersion";
+ public static final String X_PATCH_VERSION = "X-PatchVersion";
+ public static final String X_LATEST_VERSION = "X-LatestVersion";
+
+ @Autowired
+ private OofProperties oofProperties;
+
+ @Autowired
+ private OofValidator validator;
+
+
+ /**
+ * Makes a rest call to oof to perform homing and licensing for a
+ * list of demands
+ *
+ * @param homingRequest
+ * @return
+ * @throws JsonProcessingException
+ * @throws BpmnError
+ */
+ public void postDemands(OofRequest homingRequest) throws BadResponseException, JsonProcessingException{
+ logger.trace("Started oof Client Post Demands");
+ String url = oofProperties.getHost() + oofProperties.getUri();
+ logger.debug("Post demands url: " + url);
+ logger.debug("Post demands payload: " + homingRequest.toJsonString());
+
+ HttpHeaders header = new HttpHeaders();
+ header.setContentType(MediaType.APPLICATION_JSON);
+ header.set(HttpHeaders.AUTHORIZATION, oofProperties.getHeaders().get("auth"));
+ header.set(X_PATCH_VERSION, oofProperties.getHeaders().get("patchVersion"));
+ header.set(X_MINOR_VERSION, oofProperties.getHeaders().get("minorVersion"));
+ header.set(X_LATEST_VERSION, oofProperties.getHeaders().get("latestVersion"));
+ BaseClient<String, LinkedHashMap<?, ?>> baseClient = new BaseClient<>();
+
+ baseClient.setTargetUrl(url);
+ baseClient.setHttpHeader(header);
+
+ LinkedHashMap<?, ?> response = baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {});
+ validator.validateDemandsResponse(response);
+ logger.trace("Completed OOF Client Post Demands");
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java
new file mode 100644
index 0000000000..252ff0d6a6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java
@@ -0,0 +1,101 @@
+/*-
+ * ============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.client.oof;
+
+
+import org.json.JSONObject;
+import org.onap.so.client.exception.BadResponseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.LinkedHashMap;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+
+@Component
+public class OofValidator {
+
+ private static final Logger logger = LoggerFactory.getLogger(OofValidator.class);
+
+ /**
+ * Validates the synchronous homing response from oof
+ *
+ * @throws BadResponseException
+ */
+ public void validateDemandsResponse(LinkedHashMap<?, ?> response) throws BadResponseException {
+ logger.debug("Validating oofs synchronous response");
+ if(!response.isEmpty()){
+ JSONObject jsonResponse = new JSONObject(response);
+ if(jsonResponse.has("requestStatus")){
+ String status = jsonResponse.getString("requestStatus");
+ if(status.equals("accepted")){
+ logger.debug("oofs synchronous response indicates accepted");
+ }else{
+ String message = jsonResponse.getString("statusMessage");
+ if(isNotBlank(message)){
+ logger.debug("oofs response indicates failed: " + message);
+ }else{
+ logger.debug("oofs response indicates failed: no status message provided");
+ message = "error message not provided";
+ }
+ throw new BadResponseException("oofs synchronous response indicates failed: " + message);
+ }
+ }else{
+ logger.debug("oofs synchronous response does not contain: request status");
+ throw new BadResponseException("oofs synchronous response does not contain: request status");
+ }
+ }else{
+ logger.debug("oofs synchronous response is empty");
+ throw new BadResponseException("oofs synchronous response i is empty");
+ }
+ }
+
+ /**
+ * Validates the asynchronous/callback response from oof which
+ * contains the homing and licensing solutions
+ *
+ * @throws BadResponseException
+ */
+ public void validateSolution(String response) throws BadResponseException{
+ logger.debug("Validating oofs asynchronous callback response");
+ if(isNotBlank(response)) {
+ JSONObject jsonResponse = new JSONObject(response);
+ if(!jsonResponse.has("serviceException")){
+ logger.debug("oofs asynchronous response is valid");
+ }else{
+ String message = jsonResponse.getJSONObject("serviceException").getString("text");
+ if(isNotBlank(message)){
+ logger.debug("oofs response contains a service exception: " + message);
+ }else{
+ logger.debug("oofs response contains a service exception: no service exception text provided");
+ message = "error message not provided";
+ }
+ throw new BadResponseException("oofs asynchronous response contains a service exception: " + message);
+ }
+ }else{
+ logger.debug("oofs asynchronous response is empty");
+ throw new BadResponseException("oofs asynchronous response is empty");
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
new file mode 100644
index 0000000000..8e136e9f18
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
@@ -0,0 +1,123 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "modelType",
+ "modelInvariantId",
+ "modelVersionId",
+ "modelName",
+ "modelVersion",
+ "modelCustomizationName"
+})
+@JsonRootName("modelInfo")
+public class ModelInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("modelType")
+ private String modelType;
+ @JsonProperty("modelInvariantId")
+ private String modelInvariantId;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelVersion")
+ private String modelVersion;
+ @JsonProperty("modelCustomizationName")
+ private String modelCustomizationName;
+
+ @JsonProperty("modelType")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("modelType")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("modelName")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("modelName")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("modelVersion")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("modelVersion")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("modelType", modelType).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java
new file mode 100644
index 0000000000..507eaeaf5e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.client.oof.beans;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Map;
+
+@Configuration
+@ConfigurationProperties(prefix = "oof")
+public class OofProperties {
+
+ private String host;
+ private String uri;
+
+ private Map<String, String> headers;
+
+
+ public String getHost() {
+ return host;
+ }
+ public void setHost(String host) {
+ this.host = host;
+ }
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+ public Map<String, String> getHeaders() {
+ return headers;
+ }
+ public void setHeaders(Map<String, String> headers) {
+ this.headers = headers;
+ }
+
+
+
+
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
new file mode 100644
index 0000000000..7dfd6849a6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRawValue;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+
+
+public class OofRequest implements Serializable{
+
+ private static final long serialVersionUID = -1541132882892163132L;
+ private static final Logger logger = LoggerFactory.getLogger(OofRequest.class);
+
+ @JsonRawValue
+ @JsonProperty("requestInfo")
+ private RequestInfo requestInformation;
+ @JsonRawValue
+ @JsonProperty("serviceInfo")
+ private ServiceInfo serviceInformation;
+ @JsonRawValue
+ @JsonProperty("placementInfo")
+ private PlacementInfo placementInformation;
+ @JsonRawValue
+ @JsonProperty("licenseInfo")
+ private String licenseInformation;
+
+
+ public RequestInfo getRequestInformation() {
+ return requestInformation;
+ }
+ public void setRequestInformation(RequestInfo requestInformation) {
+ this.requestInformation = requestInformation;
+ }
+ public ServiceInfo getServiceInformation() {
+ return serviceInformation;
+ }
+ public void setServiceInformation(ServiceInfo serviceInformation) {
+ this.serviceInformation = serviceInformation;
+ }
+ public PlacementInfo getPlacementInformation() {
+ return placementInformation;
+ }
+ public void setPlacementInformation(PlacementInfo placementInformation) {
+ this.placementInformation = placementInformation;
+ }
+ public String getLicenseInformation() {
+ return licenseInformation;
+ }
+ public void setLicenseInformation(String licenseInformation) {
+ this.licenseInformation = licenseInformation;
+ }
+
+
+ @JsonInclude(Include.NON_NULL)
+ public String toJsonString(){
+ String json = "";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
+ try{
+ json = ow.writeValueAsString(this);
+ }catch (Exception e){
+ logger.error("Unable to convert oofRequest to string", e);
+ }
+ return json.replaceAll("\\\\", "");
+ }
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
new file mode 100644
index 0000000000..34b05e2f0f
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
@@ -0,0 +1,85 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "customerLatitude",
+ "customerLongitude",
+ "customerName"
+})
+@JsonRootName("requestParameters")
+public class OofRequestParameters implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+
+ @JsonProperty("customerLatitude")
+ private String customerLatitude;
+ @JsonProperty("customerLongitude")
+ private String customerLongitude;
+ @JsonProperty("customerName")
+ private String customerName;
+
+ @JsonProperty("customerLatitude")
+ public String getCustomerLatitude() {
+ return customerLatitude;
+ }
+
+ @JsonProperty("customerLatitude")
+ public void setCustomerLatitude(String customerLatitude) {
+ this.customerLatitude = customerLatitude;
+ }
+
+ @JsonProperty("customerLongitude")
+ public String getCustomerLongitude() {
+ return customerLongitude;
+ }
+
+ @JsonProperty("customerLongitude")
+ public void setCustomerLongitude(String customerLongitude) {
+ this.customerLongitude = customerLongitude;
+ }
+
+ @JsonProperty("customerName")
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ @JsonProperty("customerName")
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("customerLatitude", customerLatitude).append("customerLongitude", customerLongitude).append("customerName", customerName).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
new file mode 100644
index 0000000000..a213723f76
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
@@ -0,0 +1,97 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "resourceModuleName",
+ "serviceResourceId",
+ "tenantId",
+ "resourceModelInfo"
+})
+@JsonRootName("placementDemand")
+public class PlacementDemand implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("resourceModuleName")
+ private String resourceModuleName;
+ @JsonProperty("serviceResourceId")
+ private String serviceResourceId;
+ @JsonProperty("tenantId")
+ private String tenantId;
+ @JsonProperty("resourceModelInfo")
+ private ResourceModelInfo resourceModelInfo;
+
+ @JsonProperty("resourceModuleName")
+ public String getResourceModuleName() {
+ return resourceModuleName;
+ }
+
+ @JsonProperty("resourceModuleName")
+ public void setResourceModuleName(String resourceModuleName) {
+ this.resourceModuleName = resourceModuleName;
+ }
+
+ @JsonProperty("serviceResourceId")
+ public String getServiceResourceId() {
+ return serviceResourceId;
+ }
+
+ @JsonProperty("serviceResourceId")
+ public void setServiceResourceId(String serviceResourceId) {
+ this.serviceResourceId = serviceResourceId;
+ }
+
+ @JsonProperty("tenantId")
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ @JsonProperty("tenantId")
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ @JsonProperty("resourceModelInfo")
+ public ResourceModelInfo getResourceModelInfo() {
+ return resourceModelInfo;
+ }
+
+ @JsonProperty("resourceModelInfo")
+ public void setResourceModelInfo(ResourceModelInfo resourceModelInfo) {
+ this.resourceModelInfo = resourceModelInfo;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("resourceModuleName", resourceModuleName).append("serviceResourceId", serviceResourceId).append("tenantId", tenantId).append("resourceModelInfo", resourceModelInfo).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
new file mode 100644
index 0000000000..5bda42fefe
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.client.oof.beans;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "requestParameters",
+ "subscriberInfo",
+ "placementDemands"
+})
+@JsonRootName("placementInfo")
+public class PlacementInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("requestParameters")
+ private OofRequestParameters requestParameters;
+ @JsonProperty("subscriberInfo")
+ private SubscriberInfo subscriberInfo;
+ @JsonProperty("placementDemands")
+ private ArrayList<PlacementDemand> placementDemands = null;
+
+ @JsonProperty("requestParameters")
+ public OofRequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ @JsonProperty("requestParameters")
+ public void setRequestParameters(OofRequestParameters requestParameters) {
+ this.requestParameters = requestParameters;
+ }
+
+ @JsonProperty("subscriberInfo")
+ public SubscriberInfo getSubscriberInfo() {
+ return subscriberInfo;
+ }
+
+ @JsonProperty("subscriberInfo")
+ public void setSubscriberInfo(SubscriberInfo subscriberInfo) {
+ this.subscriberInfo = subscriberInfo;
+ }
+
+ @JsonProperty("placementDemands")
+ public ArrayList<PlacementDemand> getPlacementDemands() {
+ return placementDemands;
+ }
+
+ @JsonProperty("placementDemands")
+ public void setPlacementDemands(ArrayList<PlacementDemand> placementDemands) {
+ this.placementDemands = placementDemands;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("requestParameters", requestParameters).append("subscriberInfo", subscriberInfo).append("placementDemands", placementDemands).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
new file mode 100644
index 0000000000..ea33a26672
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.client.oof.beans;
+
+import java.io.Serializable;
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "transactionId",
+ "requestId",
+ "callbackUrl",
+ "sourceId",
+ "requestType",
+ "numSolutions",
+ "optimizers",
+ "timeout"
+})
+@JsonRootName("requestInfo")
+public class RequestInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("transactionId")
+ private String transactionId;
+ @JsonProperty("requestId")
+ private String requestId;
+ @JsonProperty("callbackUrl")
+ private String callbackUrl;
+ @JsonProperty("sourceId")
+ private String sourceId;
+ @JsonProperty("requestType")
+ private String requestType;
+ @JsonProperty("numSolutions")
+ private Integer numSolutions;
+ @JsonProperty("optimizers")
+ private List<String> optimizers = null;
+ @JsonProperty("timeout")
+ private Long timeout;
+
+ @JsonProperty("transactionId")
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ @JsonProperty("transactionId")
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ @JsonProperty("requestId")
+ public String getRequestId() {
+ return requestId;
+ }
+
+ @JsonProperty("requestId")
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ @JsonProperty("callbackUrl")
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ @JsonProperty("callbackUrl")
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+
+ @JsonProperty("sourceId")
+ public String getSourceId() {
+ return sourceId;
+ }
+
+ @JsonProperty("sourceId")
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
+ }
+
+ @JsonProperty("requestType")
+ public String getRequestType() {
+ return requestType;
+ }
+
+ @JsonProperty("requestType")
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ @JsonProperty("numSolutions")
+ public Integer getNumSolutions() {
+ return numSolutions;
+ }
+
+ @JsonProperty("numSolutions")
+ public void setNumSolutions(Integer numSolutions) {
+ this.numSolutions = numSolutions;
+ }
+
+ @JsonProperty("optimizers")
+ public List<String> getOptimizers() {
+ return optimizers;
+ }
+
+ @JsonProperty("optimizers")
+ public void setOptimizers(List<String> optimizers) {
+ this.optimizers = optimizers;
+ }
+
+ @JsonProperty("timeout")
+ public Long getTimeout() {
+ return timeout;
+ }
+
+ @JsonProperty("timeout")
+ public void setTimeout(Long timeout) {
+ this.timeout = timeout;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("transactionId", transactionId).append("requestId", requestId).append("callbackUrl", callbackUrl).append("sourceId", sourceId).append("requestType", requestType).append("numSolutions", numSolutions).append("optimizers", optimizers).append("timeout", timeout).toString();
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java
index 7160a2f333..fea7437a93 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/CloudFlavor.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 Intel Corp. Intellectual Property. All rights reserved.
+ * 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.
@@ -18,40 +18,38 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.core.domain;
+package org.onap.so.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
-/**
- * Stores Cloud Flavor information and is an attribute
- * of a <class>HomingSolution</class>
- *
- */
-public class CloudFlavor extends JsonWrapper implements Serializable {
+public class Resource implements Serializable{
- private static final long serialVersionUID = 8423934332773299577L;
- private String flavorLabel;
- private String flavor;
+ private static final long serialVersionUID = 5949861520571440421L;
- public CloudFlavor (String flavorLabel, String flavor){
- this.flavorLabel = flavorLabel;
- this.flavor = flavor;
- }
+ @JsonProperty("service-resource-id")
+ private String serviceResourceId;
+ @JsonProperty("status")
+ private String status;
- public String getFlavorLabel() {
- return flavorLabel;
+
+ public String getServiceResourceId(){
+ return serviceResourceId;
}
- public void setFlavorLabel(String flavorLabel) {
- this.flavorLabel = flavorLabel;
+ public void setServiceResourceId(String serviceResourceId){
+ this.serviceResourceId = serviceResourceId;
}
- public String getFlavor() {
- return flavor;
+ public String getStatus(){
+ return status;
}
- public void setFlavor(String flavor) {
- this.flavor = flavor;
+ public void setStatus(String status){
+ this.status = status;
}
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
new file mode 100644
index 0000000000..63aec130ba
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
@@ -0,0 +1,115 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonRootName("resourceModelInfo")
+public class ResourceModelInfo extends ModelInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("modelInvariantId")
+ private String modelInvariantId;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelType")
+ private String modelType;
+ @JsonProperty("modelVersion")
+ private String modelVersion;
+ @JsonProperty("modelCustomizationName")
+ private String modelCustomizationName;
+
+ @JsonProperty("modelInvariantId")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("modelName")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("modelName")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("modelType")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("modelType")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("modelVersion")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("modelVersion")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelType", modelType).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
new file mode 100644
index 0000000000..90443ce379
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "serviceInstanceId",
+ "serviceName",
+ "modelInfo"
+})
+@JsonRootName("serviceInfo")
+public class ServiceInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("serviceInstanceId")
+ private String serviceInstanceId;
+ @JsonProperty("serviceName")
+ private String serviceName;
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
+
+ @JsonProperty("serviceInstanceId")
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ @JsonProperty("serviceInstanceId")
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ @JsonProperty("serviceName")
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @JsonProperty("serviceName")
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ @JsonProperty("modelInfo")
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ @JsonProperty("modelInfo")
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("serviceName", serviceName).append("modelInfo", modelInfo).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
new file mode 100644
index 0000000000..bc283c803c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.client.oof.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "globalSubscriberId",
+ "subscriberName",
+ "subscriberCommonSiteId"
+})
+@JsonRootName("subscriberInfo")
+public class SubscriberInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("globalSubscriberId")
+ private String globalSubscriberId;
+ @JsonProperty("subscriberName")
+ private String subscriberName;
+ @JsonProperty("subscriberCommonSiteId")
+ private String subscriberCommonSiteId;
+
+ @JsonProperty("globalSubscriberId")
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+
+ @JsonProperty("globalSubscriberId")
+ public void setGlobalSubscriberId(String globalSubscriberId) {
+ this.globalSubscriberId = globalSubscriberId;
+ }
+
+ @JsonProperty("subscriberName")
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ @JsonProperty("subscriberName")
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ @JsonProperty("subscriberCommonSiteId")
+ public String getSubscriberCommonSiteId() {
+ return subscriberCommonSiteId;
+ }
+
+ @JsonProperty("subscriberCommonSiteId")
+ public void setSubscriberCommonSiteId(String subscriberCommonSiteId) {
+ this.subscriberCommonSiteId = subscriberCommonSiteId;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("globalSubscriberId", globalSubscriberId).append("subscriberName", subscriberName).append("subscriberCommonSiteId", subscriberCommonSiteId).toString();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
new file mode 100644
index 0000000000..149417d89b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
@@ -0,0 +1,123 @@
+/*-
+ * ============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.client.oof;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.junit.Test;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.oof.OofClient;
+import org.onap.so.client.oof.beans.OofRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+
+public class OofClientTestIT {
+
+ @Autowired
+ private OofClient client;
+
+
+ @Test(expected = Test.None.class)
+ public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
+ String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+ client.postDemands(new OofRequest());
+ }
+
+ @Test(expected = Test.None.class)
+ public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
+ String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+ client.postDemands(new OofRequest());
+ }
+
+ @Test(expected = BadResponseException.class)
+ public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
+ String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+
+ client.postDemands(new OofRequest());
+
+ //TODO assertEquals("missing data", );
+
+ }
+
+ @Test(expected = BadResponseException.class)
+ public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
+ String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+
+ client.postDemands(new OofRequest());
+
+ }
+
+ @Test(expected = BadResponseException.class)
+ public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
+ String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+
+ client.postDemands(new OofRequest());
+
+ }
+
+ @Test(expected = BadResponseException.class)
+ public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
+ String mockResponse = "{ }";
+
+ stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ .willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBody(mockResponse)));
+
+
+ client.postDemands(new OofRequest());
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofCallbackInfraVnf.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofCallbackInfraVnf.json
new file mode 100644
index 0000000000..15e601bae8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/OofHoming/oofCallbackInfraVnf.json
@@ -0,0 +1,50 @@
+{
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "requestStatus": "completed",
+ "statusMessage": "success",
+ "solutions": {
+ "placementSolutions": [
+ [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "some_resource_id",
+ "solution": {
+ "identifierType": "serviceInstanceId",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ "assignmentInfo": [
+ { "key": "cloudOwner", "value": "amazon" },
+ { "key": "vnfHostName", "value": "ahr344gh" },
+ { "key": "isRehome", "value": "False" },
+ { "key": "locationId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" }
+ ]
+ },
+ {
+ "resourceModuleName": "vG",
+ "serviceResourceId": "some_resource_id",
+ "solution": {
+ "identifierType": "cloudRegionId",
+ "cloudOwner": "amazon",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ "assignmentInfo": [
+ { "key": "cloudOwner", "value": "amazon" },
+ { "key": "locationId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" },
+ { "key":"flavors", "value":{ "flavorLabel1xxx":"vimFlavorxxx", "flavorLabel2xxx":"vimFlavorxxx"}}
+ ]
+ }
+ ]
+ ],
+ "licenseSolutions": [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "some_resource_id",
+ "entitlementPoolUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "licenseKeyGroupUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "entitlementPoolInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"],
+ "licenseKeyGroupInvariantUUID": ["1ac71fb8-ad43-4e16-9459-c3f372b8236d", "834fc71fb8-ad43-4fh7-9459-c3f372b8236f"]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index 8a3ce7f099..4562ebdaea 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -190,6 +190,12 @@ sniro:
headers.patchVersion: 1
headers.minorVersion: 1
headers.latestVersion: 2
+oof:
+ timeout: PT30M
+ host: http://localhost:${wiremock.server.port}
+ uri.v1: /api/oof/v1/placement
+ uri.v2: /api/oof/v2/placement
+ headers.auth: Basic dGVzdDp0ZXN0cHdk
spring:
datasource:
url: jdbc:mariadb://localhost:3307/camundabpmn