summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2018-11-09 15:56:17 -0800
committerMarcus G K Williams <marcus.williams@intel.com>2018-11-12 18:26:57 -0800
commit0f76551ead270d92d9933eab58d088e49b1e766c (patch)
tree159816c59ce619f6ced5a36bc67c530c60bc6d42 /bpmn
parenta21c5617e3b278a1bd179708b0345381632cef2b (diff)
Fix OOF Directives processing
- Various fixes to process OOF directives correctly - Add orchestrator userParam Processing to ala carte and vCPE path to ensure multicloud adapter can be called when homing - Fix JsonUtils to accept json object as well as strings - Adds JsonUtils unit tests to ensure json object code works correctly and didn't break previous func. - Fix OOF Homing codes processing of OOF response to match Casablanca response from OOF (including OOF directives) - Add CloudIdentity get and put to catalogDBClient, along with junit tests - to enable creation of cloudSites - Fix serviceResourceId check Issue-ID: SO-1203 Change-Id: Ice9a9d1da2ce0cd4bd11029e3669b30d658fe359 Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy71
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy46
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java4
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java14
-rw-r--r--bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json110
-rwxr-xr-xbpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy4
7 files changed, 205 insertions, 52 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 806a144a48..c50ef3530e 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
@@ -30,8 +30,10 @@ 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.db.catalog.beans.AuthenticationType
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.beans.ServerType
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
@@ -211,17 +213,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
for (int j = 0; j < arrSol.length(); j++) {
JSONObject placement = arrSol.getJSONObject(j)
utils.log("DEBUG", "****** Placement Solution is: " + placement + " *****", "true")
- String jsonServiceResourceId = placement.getString("serviceResourceId")
- String jsonResourceModuleName = placement.getString("resourceModuleName")
+ String jsonServiceResourceId = jsonUtil.getJsonValue( placement.toString(), "serviceResourceId")
+ utils.log("DEBUG", "****** homing serviceResourceId is: " + jsonServiceResourceId + " *****", "true")
for (Resource resource : resourceList) {
String serviceResourceId = resource.getResourceId()
- String resourceModuleName = ""
- if (resource.getResourceType() == ResourceType.ALLOTTED_RESOURCE ||
- resource.getResourceType() == ResourceType.VNF) {
- resourceModuleName = resource.getNfFunction()
- }
- if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId) ||
- resourceModuleName.equalsIgnoreCase(jsonResourceModuleName)) {
+ utils.log("DEBUG", "****** decomp serviceResourceId is: " + serviceResourceId + " *****", "true")
+ if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) {
JSONObject solution = placement.getJSONObject("solution")
String solutionType = solution.getString("identifierType")
String inventoryType = ""
@@ -230,20 +227,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
} else {
inventoryType = "cloud"
}
+ utils.log("DEBUG", "****** homing inventoryType is: " + inventoryType + " *****", "true")
resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
+ utils.log("DEBUG", "****** assignmentInfo is: " + assignmentArr.toString() + " *****", "true")
+
+ Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
+ assignmentArr.toString(), "key", "value")
String oofDirectives = null
- assignmentArr.each { element ->
- JSONObject jsonObject = new JSONObject(element.toString())
- if (jsonUtil.getJsonRawValue(jsonObject.toString(), "key") == "oof_directives") {
- oofDirectives = jsonUtil.getJsonRawValue(jsonObject.toString(), "value")
+ assignmentMap.each { key, value ->
+ utils.log("DEBUG", "****** element: " + key + " *****", "true")
+ if (key == "oof_directives") {
+ oofDirectives = value
+ utils.log("DEBUG", "****** homing oofDirectives: " + oofDirectives + " *****", "true")
}
}
- Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
- assignmentArr.toString(), "key", "value")
String cloudOwner = assignmentMap.get("cloudOwner")
+ utils.log("DEBUG", "****** homing cloudOwner: " + cloudOwner + " *****", "true")
String cloudRegionId = assignmentMap.get("locationId")
+ utils.log("DEBUG", "****** homing cloudRegionId: " + cloudRegionId + " *****", "true")
resource.getHomingSolution().setCloudOwner(cloudOwner)
resource.getHomingSolution().setCloudRegionId(cloudRegionId)
@@ -251,12 +254,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudSite.setId(cloudRegionId)
cloudSite.setRegionId(cloudRegionId)
String orchestrator = execution.getVariable("orchestrator")
- if ((orchestrator != null) || (orchestrator != "")) {
+ if ((orchestrator != null) && (orchestrator != "")) {
cloudSite.setOrchestrator(orchestrator)
+ utils.log("DEBUG", "****** orchestrator: " + orchestrator + " *****", "true")
+ } else {
+ cloudSite.setOrchestrator("multicloud")
}
CloudIdentity cloudIdentity = new CloudIdentity()
cloudIdentity.setId(cloudRegionId)
+ cloudIdentity.setIdentityServerType(ServerType."KEYSTONE")
+ cloudIdentity.setAdminTenant("service")
+ cloudIdentity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD)
+ String msoMulticloudUserName = UrnPropertiesReader
+ .getVariable("mso.multicloud.api.password", execution,
+ "apih")
+ String msoMulticloudPassword = UrnPropertiesReader
+ .getVariable("mso.multicloud.api.password", execution,
+ "abc123")
+ cloudIdentity.setMsoId(msoMulticloudUserName)
+ cloudIdentity.setMsoPass(msoMulticloudPassword)
// Get MSB Url
String msbHost = oofUtils.getMsbHost(execution)
String multicloudApiEndpoint = UrnPropertiesReader
@@ -265,16 +282,24 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint
+ "/" + cloudOwner + "/" +
cloudRegionId + "/infra_workload")
-
+ utils.log("DEBUG", "****** Cloud IdentityUrl: " + msbHost + multicloudApiEndpoint
+ + "/" + cloudOwner + "/" +
+ cloudRegionId + "/infra_workload"
+ + " *****", "true")
+ utils.log("DEBUG", "****** CloudIdentity: " + cloudIdentity.toString()
+ + " *****", "true")
cloudSite.setIdentityService(cloudIdentity)
+ utils.log("DEBUG", "****** CloudSite: " + cloudSite.toString()
+ + " *****", "true")
// Set cloudsite in catalog DB here
- oofUtils.createCloudSiteCatalogDb(cloudSite)
+ // TODO Get cloudsite and compare, set if not present
+ oofUtils.createCloudSiteCatalogDb(cloudSite, execution)
if (oofDirectives != null && oofDirectives != "") {
resource.getHomingSolution().setOofDirectives(oofDirectives)
execution.setVariable("oofDirectives", oofDirectives)
- utils.log("DEBUG", "***** OofDirectives is: " + oofDirectives +
+ utils.log("DEBUG", "***** OofDirectives set to: " + oofDirectives +
" *****", "true")
}
@@ -285,6 +310,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
resource.getHomingSolution().setVnf(vnf)
resource.getHomingSolution().setServiceInstanceId(solution.getJSONArray("identifiers")[0].toString())
}
+ } else {
+ utils.log("DEBUG", "ProcessHomingSolution Exception: no matching serviceResourceIds returned in " +
+ "homing solution", isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - " +
+ "Occurred in Homing ProcessHomingSolution: no matching serviceResourceIds returned")
+
}
}
}
@@ -314,8 +345,10 @@ class OofHoming extends AbstractServiceTaskProcessor {
utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled)
} catch (BpmnError b) {
+ utils.log("DEBUG", "ProcessHomingSolution Error: " + b, isDebugEnabled)
throw b
} catch (Exception e) {
+ utils.log("DEBUG", "ProcessHomingSolution Exception: " + e, isDebugEnabled)
msoLogger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution")
}
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 909683adea..19d19b8cea 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -33,22 +33,18 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.core.domain.Subscriber
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.client.CatalogDbClient
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
-import org.springframework.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 javax.ws.rs.core.UriBuilder
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
@@ -503,36 +499,26 @@ class OofUtils {
* @return void
*/
Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
-
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
- 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)
+ CloudSite getCloudsite = null
- 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.")
+ CatalogDbClient catalogDbClient = new CatalogDbClient(endpoint, auth)
+ try {
+ getCloudsite = catalogDbClient.getCloudSite(cloudSite.getId().toString())
+ } catch (Exception e) {
+ e = null
+ utils.log("DEBUG", "Could not find cloudsite : " + cloudSite.getId(), isDebugEnabled)
+ utils.log("DEBUG", "Creating cloudSite: " + cloudSite.toString(), isDebugEnabled)
+ }
+ if (getCloudsite?.getId() != cloudSite.getId()) {
+ catalogDbClient.postCloudSite(cloudSite)
}
}
String getMsbHost(DelegateExecution execution) {
- msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
+ String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
index ee53148e44..35f76908e3 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
@@ -927,7 +927,7 @@ public class JsonUtils {
for (int i = 0; i < arr.length(); i++){
JSONObject jo = arr.getJSONObject(i);
String key = jo.getString(keyNode);
- String value = jo.getString(valueNode);
+ String value = jo.get(valueNode).toString();
map.put(key, value);
}
msoLogger.debug("Completed Entry Array To Map Util Method");
@@ -954,7 +954,7 @@ public class JsonUtils {
for(int i = 0; i < arr.length(); i++){
JSONObject jo = arr.getJSONObject(i);
String key = jo.getString(keyNode);
- String value = jo.getString(valueNode);
+ String value = jo.get(valueNode).toString();
map.put(key, value);
}
msoLogger.debug("Completed Entry Array To Map Util Method");
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java
index 6748128f05..067ae9806d 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java
@@ -81,7 +81,19 @@ public class JsonUtilsTest {
JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
Map<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue");
assertEquals(map.get("cloudOwner"), "CloudOwner");
- }
+ }
+ @Test
+ public void entryArrayToMapStringTestOof() throws IOException {
+ JsonUtils utils = new JsonUtils();
+ String response = this.getJson("OofExample.json");
+ String entry = JsonUtils.getJsonValue(response, "solutions.placementSolutions");
+ JSONArray arr = new JSONArray(entry);
+ JSONArray arr2 = arr.getJSONArray(0);
+ JSONObject homingDataJson = arr2.getJSONObject(0);
+ JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
+ Map<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "key", "value");
+ assertEquals(map.get("cloudOwner"), "HPA-cloud");
+ }
@Test
public void getJsonRootPropertyTest() throws IOException {
String response = this.getJson("SDNCServiceResponseExample.json");
diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json
new file mode 100644
index 0000000000..127748a5e8
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json
@@ -0,0 +1,110 @@
+{
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions":{
+ "placementSolutions":[
+ [
+ {
+ "serviceResourceId":"78976677-bca7-446a-8b31-52b83e9aa925",
+ "resourceModuleName":"7400fd06C75f4a44A68f",
+ "solution":{
+ "identifierType":"cloudRegionId",
+ "cloudOwner":"HPA-cloud",
+ "identifiers":[
+ "Cloud-region3"
+ ]
+ },
+ "assignmentInfo":[
+ {
+ "value":"false",
+ "key":"isRehome"
+ },
+ {
+ "value":"att_aic",
+ "key":"locationType"
+ },
+ {
+ "value":"Cloud-region3",
+ "key":"locationId"
+ },
+ {
+ "value":{
+ "directives":[
+ {
+ "directives":[
+ {
+ "attributes":[
+ {
+ "attribute_value":"Flavor31",
+ "attribute_name":"label_1"
+ }
+ ],
+ "type":"flavor_directives"
+ },
+ {
+ "attributes":[
+ {
+ "attribute_value":"direct",
+ "attribute_name":"oof_returned_vnic_type_for_firewall_protected"
+ }
+ ],
+ "type":"sriovNICNetwork_directives"
+ }
+ ],
+ "type":"vnfc",
+ "id":"vfw_1"
+ },
+ {
+ "directives":[
+ {
+ "attributes":[
+ {
+ "attribute_value":"Flavor32",
+ "attribute_name":"label_2"
+ }
+ ],
+ "type":"flavor_directives"
+ }
+ ],
+ "type":"vnfc",
+ "id":"vfw_2"
+ },
+ {
+ "directives":[
+ {
+ "attributes":[
+ {
+ "attribute_value":"Flavor32",
+ "attribute_name":"label_3"
+ }
+ ],
+ "type":"flavor_directives"
+ }
+ ],
+ "type":"vnfc",
+ "id":"vfw_3"
+ }
+ ]
+ },
+ "key":"oof_directives"
+ },
+ {
+ "value":"DLLSTX233",
+ "key":"cloudClli"
+ },
+ {
+ "value":"75919",
+ "key":"aic_version"
+ },
+ {
+ "value":"HPA-cloud",
+ "key":"cloudOwner"
+ }
+ ]
+ }
+ ]
+ ]
+ },
+ "transactionId":"",
+ "requestId":"05da4f90-15f7-4128-8ac4-e06dc3cc06f9"
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy
index 9763960bfd..848785e5f3 100755
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy
@@ -165,6 +165,10 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString())
inputMap.put(userParam.name, userParam.value)
}
+ if ("Orchestrator".equalsIgnoreCase(userParam?.name)) {
+ execution.setVariable("orchestrator", userParam.value)
+ inputMap.put("orchestrator", userParam.value)
+ }
}
}
@@ -344,6 +348,10 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString())
inputMap.put(userParam.name, userParam.value)
}
+ if ("Orchestrator".equalsIgnoreCase(userParam?.name)) {
+ execution.setVariable("orchestrator", userParam.value)
+ inputMap.put("orchestrator", userParam.value)
+ }
}
}
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 1a47ef88e2..187189c694 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
@@ -250,6 +250,10 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
execution.setVariable("callHoming", true)
inputMap.put("Homing_Solution", userParam.value)
}
+ if ("Orchestrator".equalsIgnoreCase(userParam?.name)) {
+ execution.setVariable("orchestrator", userParam.value)
+ inputMap.put("orchestrator", userParam.value)
+ }
}
}