diff options
author | Marcus Williams <marcus.williams@intel.com> | 2019-01-28 20:43:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-28 20:43:35 +0000 |
commit | 902b6a93925067f0bb8c7a1639b62cbd64604465 (patch) | |
tree | 1869cb1b23e0fc0f7113ca812e9d26fc8fa2a403 /adapters | |
parent | 1f57cd06a3bf1deeb277430dba310088368c82fa (diff) | |
parent | fe91155454a27401e8c23780fa247c0ede196747 (diff) |
Merge "Merge 'origin/casablanca' into master"
Diffstat (limited to 'adapters')
32 files changed, 439 insertions, 85 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index c9b70610d1..5c0110b680 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -28,12 +28,9 @@ import java.util.List; import java.util.Map; import java.util.Scanner; -import javax.ws.rs.core.UriBuilderException; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilderException; -import org.onap.so.client.HttpClientFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.onap.so.adapters.vdu.CloudInfo; import org.onap.so.adapters.vdu.PluginAction; import org.onap.so.adapters.vdu.VduArtifact; @@ -44,20 +41,25 @@ import org.onap.so.adapters.vdu.VduModelInfo; import org.onap.so.adapters.vdu.VduPlugin; import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; +import org.onap.so.client.HttpClientFactory; +import org.onap.so.client.RestClient; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; +import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.client.RestClient; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.utils.TargetEntity; +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 com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.heat.model.CreateStackParam; @@ -66,7 +68,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ public static final String OOF_DIRECTIVES = "oof_directives"; public static final String SDNC_DIRECTIVES = "sdnc_directives"; - public static final String GENERIC_VNF_ID = "generic_vnf_id"; + public static final String VNF_ID = "vnf_id"; public static final String VF_MODULE_ID = "vf_module_id"; public static final String TEMPLATE_TYPE = "template_type"; public static final List<String> MULTICLOUD_INPUTS = @@ -143,8 +145,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.trace("Started MsoMulticloudUtils.createStack"); // Get the directives, if present. - String oofDirectives = ""; - String sdncDirectives = ""; + String oofDirectives = "{}"; + String sdncDirectives = "{}"; String genericVnfId = ""; String vfModuleId = ""; String templateType = ""; @@ -167,11 +169,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } - if (!stackInputs.isEmpty() && stackInputs.containsKey("VF_MODULE_ID")){ - vfModuleId = (String) stackInputs.get("VF_MODULE_ID"); + if (!stackInputs.isEmpty() && stackInputs.containsKey(VF_MODULE_ID)){ + vfModuleId = (String) stackInputs.get(VF_MODULE_ID); } - if (!stackInputs.isEmpty() && stackInputs.containsKey("GENERIC_VNF_ID")){ - genericVnfId = (String) stackInputs.get("GENERIC_VNF_ID"); + if (!stackInputs.isEmpty() && stackInputs.containsKey(VNF_ID)){ + genericVnfId = (String) stackInputs.get(VNF_ID); } // create the multicloud payload @@ -179,26 +181,17 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ MulticloudRequest multicloudRequest= new MulticloudRequest(); - try { - multicloudRequest.setGenericVnfId(genericVnfId); - multicloudRequest.setVfModuleId(vfModuleId); - multicloudRequest.setOofDirectives(JSON_MAPPER.readTree(oofDirectives)); - multicloudRequest.setSdncDirectives(JSON_MAPPER.readTree(sdncDirectives)); - multicloudRequest.setTemplateType(templateType); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16))); - } - multicloudRequest.setTemplateData(stack); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); - } - } catch (Exception e) { - logger.debug("ERROR making multicloud JSON body ", e); - } - String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null); + multicloudRequest.setGenericVnfId(genericVnfId); + multicloudRequest.setVfModuleId(vfModuleId); + multicloudRequest.setTemplateType(templateType); + multicloudRequest.setTemplateData(stack); + multicloudRequest.setOofDirectives(getDirectiveNode(oofDirectives)); + multicloudRequest.setSdncDirectives(getDirectiveNode(sdncDirectives)); if (logger.isDebugEnabled()) { - logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint)); + logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); } + + String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null); RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); Response response = multicloudClient.post(multicloudRequest); @@ -207,17 +200,23 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ createInfo.setName(stackName); MulticloudCreateResponse multicloudResponseBody = null; - if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) { + if (response.hasEntity()) { multicloudResponseBody = getCreateBody((java.io.InputStream)response.getEntity()); + } + if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) { createInfo.setCanonicalName(stackName + "/" + multicloudResponseBody.getWorkloadId()); if (logger.isDebugEnabled()) { logger.debug("Multicloud Create Response Body: " + multicloudResponseBody); } return getStackStatus(cloudSiteId, tenantId, createInfo.getCanonicalName(), pollForCompletion, timeoutMinutes, backout); } else { - createInfo.setStatus(HeatStatus.FAILED); - createInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase()); - return createInfo; + StringBuilder stackErrorStatusReason = new StringBuilder(response.getStatusInfo().getReasonPhrase()); + if (null != multicloudResponseBody) { + stackErrorStatusReason.append(multicloudResponseBody.toString()); + } + MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); + me.addContext(CREATE_STACK); + throw me; } } @@ -385,7 +384,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (pollTimeout <= 0) { // Note that this should not occur, since there is a timeout specified // in the Openstack (multicloud?) call. - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout")); + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Create stack timeout")); createTimedOut = true; break; } @@ -403,7 +402,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // Cannot query the stack status. Something is wrong. // Try to roll back the stack if (!backout) { - logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack, stack deletion suppressed")); } else { try { logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked"); @@ -417,8 +416,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, + queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -435,12 +434,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (Exception e3) { // Just log this one. We will report the original exception. - logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack on error on query")); } } } catch (Exception e2) { // Just log this one. We will report the original exception. - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack")); } } @@ -451,12 +450,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } if (!HeatStatus.CREATED.equals(stackInfo.getStatus())) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack error: Polling complete with non-success status: " - + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: " + + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error")); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { - logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion suppressed")); } else { @@ -471,8 +470,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, + queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -485,14 +484,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ continue; } else { //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate - logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion FAILED")); logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" + queryInfo.getStatusMessage()); break; } } catch (MsoException me2) { // Just log this one. We will report the original exception. logger.debug("Exception thrown trying to delete " + instanceId + " on a create->rollback: " + me2.getContextMessage(), me2); - logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage())); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage())); } } StringBuilder errorContextMessage; @@ -508,7 +507,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (MsoException e2) { // shouldn't happen - but handle - logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: rolling back stack")); } } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); @@ -611,6 +610,21 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ return client; } + private JsonNode getDirectiveNode(String directives) throws MsoException { + try { + return JSON_MAPPER.readTree(directives); + } catch (Exception e) { + logger.error(String.format("%s %s %s %s %d %s", + MessageEnum.RA_CREATE_STACK_ERR.toString(), + "Create Stack: " + e, "", "", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Exception in Create Stack: Invalid JSON format of directives" + directives)); + MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives); + me.addContext(CREATE_STACK); + throw me; + } + } + /** * VduPlugin interface for instantiate function. * diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java index d0caef33e4..a383aac77f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java @@ -54,8 +54,8 @@ public class CreateVfModuleRequest extends VfRequestCommon { private String modelCustomizationUuid; private String requestType; - private Boolean failIfExists; - private Boolean backout; + private Boolean failIfExists = false; + private Boolean backout = true; private Boolean enableBridge; private Map<String, String> vfModuleParams = new HashMap<>(); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java index 63ef8e6dd0..cc1b3ddb17 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -57,7 +57,7 @@ public abstract class CatalogQuery { while (m.find()) { String key = template.substring(m.start() + 1, m.end() - 1); logger.debug("CatalogQuery key: {} contains key? {}", key , valueMap.containsKey(key)); - m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")); + m.appendReplacement(result, Matcher.quoteReplacement(valueMap.getOrDefault(key, "\"TBD\""))); } m.appendTail(result); logger.debug("CatalogQuery return: {}", result.toString()); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 3dca6a395c..859666f446 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -52,7 +52,8 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { "\t\t\"nfFunction\" : <NF_FUNCTION>,\n"+ "\t\t\"nfType\" : <NF_TYPE>,\n"+ "\t\t\"nfRole\" : <NF_ROLE>,\n"+ - "\t\t\"nfNamingCode\" : <NF_NAMING_CODE>\n"+ + "\t\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"+ + "\t\t\"resourceInput\" : <RESOURCE_INPUT>\n"+ "\t}"; public QueryAllottedResourceCustomization() { @@ -117,7 +118,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getAllottedResource().getToscaNodeType()); put(valueMap, "ALLOTTED_RESOURCE_TYPE", arNull ? null : o.getAllottedResource().getSubcategory()); - put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole()); + put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole() != null ? o.getTargetNetworkRole() : o.getNfRole()); put(valueMap, "NF_TYPE", o.getNfType()); put(valueMap, "NF_ROLE", o.getNfRole()); put(valueMap, "NF_FUNCTION", o.getNfFunction()); @@ -125,6 +126,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java index 8670b78e15..58a2e852f0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.catalogdb.catalogrest; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.onap.so.db.catalog.beans.Recipe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,12 +57,18 @@ public class QueryResourceRecipe extends CatalogQuery{ @Override public String JSON2(boolean isArray, boolean isEmbed) { Map<String, String> valueMap = new HashMap<>(); - valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId())); - valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction()); - valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri()); - valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout())); - valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXsd()); - valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription()); + valueMap.put("id", null == resourceRecipe || null == resourceRecipe.getId() + ? StringUtils.EMPTY :String.valueOf(resourceRecipe.getId())); + valueMap.put("action", null == resourceRecipe || null == resourceRecipe.getAction() + ? StringUtils.EMPTY :resourceRecipe.getAction()); + valueMap.put("orchestrationUri", null == resourceRecipe || null == resourceRecipe.getOrchestrationUri() + ? StringUtils.EMPTY : resourceRecipe.getOrchestrationUri()); + valueMap.put("recipeTimeout", null == resourceRecipe || null == resourceRecipe.getRecipeTimeout() + ? StringUtils.EMPTY : String.valueOf(resourceRecipe.getRecipeTimeout())); + valueMap.put("paramXSD", null == resourceRecipe || null == resourceRecipe.getParamXsd() + ? StringUtils.EMPTY : resourceRecipe.getParamXsd()); + valueMap.put("description", null == resourceRecipe || null == resourceRecipe.getDescription() + ? StringUtils.EMPTY : resourceRecipe.getDescription()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); String jsonStr = ""; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 3b50871a8d..edbf9749c6 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -45,6 +45,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { "\t\"serviceType\" : <SERVICE_TYPE>,\n"+ "\t\"serviceRole\" : <SERVICE_ROLE>,\n"+ "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n"+ + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n"+ "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n"+ "<_SERVICEVNFS_>,\n"+ "<_SERVICENETWORKS_>,\n"+ @@ -81,6 +82,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { put(valueMap, "SERVICE_ROLE", service.getServiceRole()); put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext()); put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext()); + put(valueMap, "RESOURCE_ORDER", service.getResourceOrder()); String subitem; subitem = new QueryServiceVnfs(service.getVnfCustomizations()).JSON2(true, true); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index a2256f724a..f7457fda4a 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -50,6 +50,7 @@ public class QueryServiceNetworks extends CatalogQuery { "\t\t\"toscaNodeType\" : <TOSCA_NODE_TYPE>,\n"+ "\t\t\"networkType\" : <NETWORK_TYPE>,\n"+ "\t\t\"networkTechnology\" : <NETWORK_TECHNOLOGY>,\n"+ + "\t\t\"resourceInput\" : <RESOURCE_INPUT>,\n"+ "\t\t\"networkRole\" : <NETWORK_ROLE>,\n"+ "\t\t\"networkScope\" : <NETWORK_SCOPE>\n"+ "\t}"; @@ -116,6 +117,7 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_ROLE", o.getNetworkRole()); put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index 82b6aa2aeb..4170047e0b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -53,6 +53,7 @@ public class QueryServiceVnfs extends CatalogQuery { "\t\"nfRole\" : <NF_ROLE>,\n"+ "\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"+ "\t\"multiStageDesign\" : <MULTI_STEP_DESIGN>,\n"+ + "\t\"resourceInput\" : <RESOURCE_INPUT>,\n"+ "<_VFMODULES_>\n" + "\t}"; @@ -119,6 +120,7 @@ public class QueryServiceVnfs extends CatalogQuery { put(valueMap, "NF_ROLE", o.getNfRole()); put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode()); put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 70f53133dd..dbb168bd15 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -520,6 +520,7 @@ public class CatalogDbAdapterRest { try { if (smUuid != null && !"".equals(smUuid)) { logger.debug("Query Csar by service model uuid: {}",smUuid); + Service service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(smUuid); if (service != null) { @@ -587,18 +588,22 @@ public class CatalogDbAdapterRest { if (null == recipe) { NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - if(null!=vnf) { - recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, vnf.getModelVersion()); - } - // for network fetch the default recipe - if (recipe == null) { - recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action); + + if(nResource != null) { + recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion()); + + // for network fetch the default recipe + if (recipe == null) { + recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action); + } } } if (null == recipe) { AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); - recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion()); + if (arResource != null) { + recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion()); + } } if (recipe != null) { QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql index e4b599a044..e4b599a044 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql new file mode 100644 index 0000000000..75a8c20352 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql @@ -0,0 +1,4 @@ +use catalogdb; + +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'GenericVnfHealthCheckBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'ConfigurationScaleOutBB';
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql new file mode 100644 index 0000000000..47c540b95d --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql @@ -0,0 +1,31 @@ +USE catalogdb; + +INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES +('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1',' +heat_template_version: 2013-05-23 +description: A simple Neutron network +parameters: + network_name: + type: string + description: Name of the Neutron Network + default: ONAP-NW1 + shared: + type: boolean + description: Shared amongst tenants + default: False +outputs: + network_id: + description: Openstack network identifier + value: { get_resource: network } +resources: + network: + type: OS::Neutron::Net + properties: + name: { get_param: network_name } + shared: { get_param: shared }',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); + + + +INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) +VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','3.0'); + diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql new file mode 100644 index 0000000000..7077032fca --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql @@ -0,0 +1,5 @@ +use catalogdb; + +ALTER TABLE cloud_sites + MODIFY IF EXISTS REGION_ID varchar(50) NULL, + MODIFY IF EXISTS CLLI varchar(50) NULL;
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql new file mode 100644 index 0000000000..00f4777c03 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql @@ -0,0 +1,4 @@ +use catalogdb; + +INSERT INTO controller_selection_reference (VNF_TYPE, CONTROLLER_NAME, ACTION_CATEGORY) VALUES ('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'HealthCheck'); +INSERT INTO controller_selection_reference (VNF_TYPE, CONTROLLER_NAME, ACTION_CATEGORY) VALUES ('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'ConfigScaleOut');
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql new file mode 100644 index 0000000000..bded179395 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql @@ -0,0 +1,2 @@ +update building_block_detail set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM"; +update orchestration_status_state_transition_directive set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM";
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql new file mode 100644 index 0000000000..9f51ed173d --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql @@ -0,0 +1,13 @@ +USE catalogdb; + +INSERT INTO building_block_detail (BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) +VALUES +('FlowCompleteActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFHealthCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFQuiesceTrafficActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFResumeTrafficActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFSetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUnsetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradePostCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradePreCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradeSoftwareActivity', 'NO_VALIDATE', 'CUSTOM');
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql new file mode 100644 index 0000000000..1725028104 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql @@ -0,0 +1,9 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `homing_instances` ( +`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, +`CLOUD_OWNER` VARCHAR(200) NOT NULL, +`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, +`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, +PRIMARY KEY (`SERVICE_INSTANCE_ID`) +) ; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql new file mode 100644 index 0000000000..10d8789328 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql @@ -0,0 +1,13 @@ +use catalogdb; + +ALTER TABLE service +ADD RESOURCE_ORDER varchar(255); + +ALTER TABLE vnf_resource_customization +ADD RESOURCE_INPUT varchar(2000); + +ALTER TABLE network_resource_customization +ADD RESOURCE_INPUT varchar(2000); + +ALTER TABLE allotted_resource_customization +ADD RESOURCE_INPUT varchar(2000);
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql new file mode 100644 index 0000000000..dfb5075674 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql @@ -0,0 +1,10 @@ +use catalogdb; + +ALTER TABLE vnf_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); + +ALTER TABLE network_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); + +ALTER TABLE allotted_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000);
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql new file mode 100644 index 0000000000..b1aefaf56c --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql @@ -0,0 +1,5 @@ +use catalogdb; + +ALTER TABLE network_resource MODIFY COLUMN AIC_VERSION_MIN varchar(20) NULL; +ALTER TABLE network_resource MODIFY COLUMN HEAT_TEMPLATE_ARTIFACT_UUID varchar(200) NULL; +ALTER TABLE network_resource DROP FOREIGN KEY fk_network_resource__temp_network_heat_template_lookup__mod_nm1;
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 077b4ea6d5..0f5ad6d92f 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -25,6 +25,8 @@ import static org.junit.Assert.*; import java.io.IOException; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -65,6 +67,8 @@ public class CatalogDBRestTest { private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources"; + private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe"; + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks"; private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs"; @@ -94,6 +98,8 @@ public class CatalogDBRestTest { private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}"; private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + + private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df"; private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671"; @@ -648,6 +654,42 @@ public class CatalogDBRestTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); } + + @Test + public void testResourceReceipe() throws JSONException { + String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}"; + + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID) + .queryParam("action", "createInstance"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false); + } + + @Test + public void testResourceReceipeNotMatched() throws JSONException { + + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID) + .queryParam("action", "invalid_action"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + } @Test public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java index 05d1928a17..5a6ab747c5 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java @@ -63,14 +63,14 @@ public class CloudConfigTest { headers.set("Content-Type",MediaType.APPLICATION_JSON); CloudSite cloudSite = new CloudSite(); - cloudSite.setId("MTN6"); + cloudSite.setId("MTN7"); cloudSite.setClli("TESTCLLI"); cloudSite.setRegionId("regionId"); cloudSite.setCloudVersion("VERSION"); cloudSite.setPlatform("PLATFORM"); CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId("RANDOMID"); + cloudIdentity.setId("RANDOMID-test"); cloudIdentity.setIdentityUrl("URL"); cloudIdentity.setMsoId("MSO_ID"); cloudIdentity.setMsoPass("MSO_PASS"); @@ -81,7 +81,7 @@ public class CloudConfigTest { cloudSite.setIdentityService(cloudIdentity); String uri = "/cloudSite"; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri); - HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers); + HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, request, String.class); assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value()); @@ -98,4 +98,6 @@ public class CloudConfigTest { } + + } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java index 645714cc80..e403867c42 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java @@ -21,11 +21,16 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.so.db.catalog.beans.ArRecipe; +import org.onap.so.db.catalog.beans.NetworkRecipe; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.jsonpath.JsonPathUtil; public class QueryResourceRecipeTest { @@ -67,4 +72,24 @@ public class QueryResourceRecipeTest { return recipe; } + @Test + public void convertToJson() { + Recipe recipe = createRecipe(); + QueryResourceRecipe queryResourceRecipe = new QueryResourceRecipe(recipe); + assertEquals("{\"orchestrationUri\":\"uriTest\",\"action\":\"actionTest\",\"description\":\"descrTest\",\"id\":\"123\",\"recipeTimeout\":\"100\",\"paramXSD\":\"paramsXsdTest\"}", + queryResourceRecipe.JSON2(false,false)); + } + + @Test + public void convertToJsonEmptyRecipe() { + QueryResourceRecipe vnfQueryRR = new QueryResourceRecipe(new VnfRecipe()); + QueryResourceRecipe networkQueryRR = new QueryResourceRecipe(new NetworkRecipe()); + QueryResourceRecipe arQueryRR = new QueryResourceRecipe(new ArRecipe()); + + String expected = "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}"; + assertEquals(expected, vnfQueryRR.JSON2(false, false)); + assertEquals(expected, networkQueryRR.JSON2(false,false)); + assertEquals(expected, arQueryRR.JSON2(false,false)); + } + } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index e249285867..4479e1ba4a 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -39,6 +39,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; +import org.onap.so.db.catalog.beans.HomingInstance; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.ServerType; @@ -425,6 +426,81 @@ public class CatalogDbClientTest { Assert.assertEquals("regionId", getCloudSite.getRegionId()); Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } + + @Test + public void testGetHomingInstance() { + HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671"); + Assert.assertNotNull(homingInstance); + Assert.assertNotNull(homingInstance.getCloudOwner()); + Assert.assertNotNull(homingInstance.getCloudRegionId()); + Assert.assertNotNull(homingInstance.getOofDirectives()); + } + + @Test + public void testPostHomingInstance() { + CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); + HomingInstance homingInstance = new HomingInstance(); + homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671"); + homingInstance.setCloudOwner("CloudOwner-1"); + homingInstance.setCloudRegionId("CloudRegionOne"); + homingInstance.setOofDirectives("{\n" + + "\"directives\": [\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + + "\"attribute_name\": \"firewall_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vfw\"\n" + + "},\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + + "\"attribute_name\": \"packetgen_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vgenerator\"\n" + + "},\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + + "\"attribute_name\": \"sink_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vsink\"\n" + + "}\n" + + "]\n" + + "}"); + localClient.postHomingInstance(homingInstance); + HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671"); + Assert.assertNotNull(getHomingInstance); + Assert.assertNotNull(getHomingInstance.getCloudRegionId()); + Assert.assertNotNull(getHomingInstance.getCloudOwner()); + Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner()); + Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId()); + } + @Test public void testGetServiceByModelName() { Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 9eb3daa5ae..3e92b5d7ba 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -51,6 +51,14 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` ( CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) ) ; +CREATE TABLE IF NOT EXISTS `homing_instances` ( +`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, +`CLOUD_OWNER` VARCHAR(200) NOT NULL, +`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, +`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, +PRIMARY KEY (`SERVICE_INSTANCE_ID`) +) ; + insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values ('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43'); @@ -105,8 +113,8 @@ insert into heat_environment(artifact_uuid, name, version, description, body, ar insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', 'ff874603-4222-11e7-9252-005056850d2e'); -insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values -('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null); +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design, resource_input) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null, "{\\\"vf_module_id\\\":\\\"vFirewall\\\",\\\"vfw_private_ip_1\\\":\\\"192.168.20.100\\\",\\\"public_net_id\\\":\\\"PUBLIC NET ID\\\",\\\"vfw_private_ip_0\\\":\\\"192.168.10.100\\\",\\\"onap_private_subnet_id\\\":\\\"PRIVATE NETWORK\\\",\\\"sec_group\\\":\\\"SECURITY GROUP\\\",\\\"vfw_private_ip_2\\\":\\\"10.0.100.1\\\",\\\"vfw_name_0\\\":\\\"zdfw1fwl01fwl01\\\",\\\"nexus_artifact_repo\\\":\\\"https://nexus.onap.org\\\",\\\"onap_private_net_cidr\\\":\\\"10.0.0.0/16\\\",\\\"dcae_collector_ip\\\":\\\"10.0.4.1\\\",\\\"vnf_id\\\":\\\"vFirewall_demo_app\\\",\\\"dcae_collector_port\\\":\\\"8081\\\",\\\"vpg_name_0\\\":\\\"zdfw1fwl01pgn01\\\",\\\"vsn_private_ip_0\\\":\\\"192.168.20.250\\\",\\\"vpg_private_ip_1\\\":\\\"10.0.100.2\\\",\\\"vsn_private_ip_1\\\":\\\"10.0.100.3\\\",\\\"vpg_private_ip_0\\\":\\\"192.168.10.200\\\",\\\"protected_private_net_cidr\\\":\\\"192.168.20.0/24\\\",\\\"unprotected_private_net_cidr\\\":\\\"192.168.10.0/24\\\",\\\"nf_naming\\\":\\\"true\\\",\\\"vsn_name_0\\\":\\\"zdfw1fwl01snk01\\\",\\\"multi_stage_design\\\":\\\"false\\\",\\\"onap_private_net_id\\\":\\\"PRIVATE NETWORK\\\",\\\"unprotected_private_net_id\\\":\\\"zdfw1fwl01_unprotected\\\",\\\"availability_zone_max_count\\\":\\\"1\\\",\\\"vfw_flavor_name\\\":\\\"(m1.medium suggested)\\\",\\\"demo_artifacts_version\\\":\\\"1.3.0-SNAPSHOT\\\",\\\"pub_key\\\":\\\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQXYJYYi3/OUZXUiCYWdtc7K0m5C0dJKVxPG0eI8EWZrEHYdfYe6WoTSDJCww+1qlBSpA5ac/Ba4Wn9vh+lR1vtUKkyIC/nrYb90ReUd385Glkgzrfh5HdR5y5S2cL/Frh86lAn9r6b3iWTJD8wBwXFyoe1S2nMTOIuG4RPNvfmyCTYVh8XTCCE8HPvh3xv2r4egawG1P4Q4UDwk+hDBXThY2KS8M5/8EMyxHV0ImpLbpYCTBA6KYDIRtqmgS6iKyy8v2D1aSY5mc9J0T5t9S2Gv+VZQNWQDDKNFnxqYaAo1uEoq/i1q63XC5AD3ckXb2VT6dp23BQMdDfbHyUWfJN\\\",\\\"key_name\\\":\\\"vfw_key\\\",\\\"install_script_version\\\":\\\"1.3.0-SNAPSHOT\\\",\\\"vfw_image_name\\\":\\\"(UBUNTU 1404 required)\\\",\\\"protected_private_net_id\\\":\\\"zdfw1fwl01_protected\\\",\\\"cloud_env\\\":\\\"openstack\\\"}"); insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values @@ -210,7 +218,17 @@ INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPT VALUES ('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671'); +insert into homing_instances (service_instance_id, cloud_owner, cloud_region_id, oof_directives) values +('5df8b6de-2083-11e7-93ae-92361f232671', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'), +('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'); + +-- for query resource receipe +INSERT INTO allotted_resource +(MODEL_UUID, MODEL_INVARIANT_UUID, MODEL_VERSION, MODEL_NAME, TOSCA_NODE_TYPE, SUBCATEGORY, DESCRIPTION, CREATION_TIMESTAMP) +VALUES('25e2d69b-3b22-47b8-b4c9-7b14fd4a80df', '8f5fe343-9a3a-4d31-a829-49b27bbfc1c4', '2.0', 'sotnvpnattachmentvF', 'org.openecomp.resource.vf.Sdwanvpnattachmentvf', 'Allotted Resource', 'sdwanvpnattachmentVF', '2019-01-24 09:59:16.000'); +INSERT INTO ar_recipe(ID, MODEL_NAME, ACTION, VERSION_STR, SERVICE_TYPE, DESCRIPTION, ORCHESTRATION_URI, AR_PARAM_XSD, RECIPE_TIMEOUT, CREATION_TIMESTAMP) +VALUES(1, 'sotnvpnattachmentvF', 'createInstance', '2.0', 'VF', 'sotnvpnattachmentvF', '/mso/async/services/CreateSDNCNetworkResource', '', 180, '2019-01-24 09:59:16.000'); INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, IS_ALACARTE, MIN_API_VERSION, MAX_API_VERSION, CLOUD_OWNER, SERVICE_TYPE) VALUES ('Service-Create', 'createInstance', 'Service', true, '7','7', 'my-custom-cloud-owner','*'); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index e0d7581dcf..09ee0cde04 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -994,10 +994,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } } } - if (multicloudInputs) { - goldenInputs.put(MsoMulticloudUtils.GENERIC_VNF_ID, genericVnfId); - goldenInputs.put(MsoMulticloudUtils.VF_MODULE_ID, vfModuleId); - } LOGGER.debug("Ignoring extra inputs: " + extraInputs); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index f958a5b140..1fd3ffc90a 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -67,8 +67,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ public void createVfModule() throws Exception { //expectedException.expect(VnfException.class); Map<String, String> stackInputs = new HashMap<>(); - stackInputs.put("oof_directives", "{oofDIRECTIVES}"); - stackInputs.put("sdnc_directives", "{sdncDIRECTIVES}"); + stackInputs.put("oof_directives", "{}"); + stackInputs.put("sdnc_directives", "{}"); stackInputs.put("generic_vnf_id", "genVNFID"); stackInputs.put("vf_module_id", "vfMODULEID"); diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 72810d6f3c..e9f2a09860 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -28,6 +28,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, + `resource_input` varchar(20000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -138,11 +139,11 @@ create table `network_resource` ( `model_name` varchar(200) not null, `model_invariant_uuid` varchar(200) default null, `description` varchar(1200) default null, - `heat_template_artifact_uuid` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) null, `neutron_network_type` varchar(20) default null, `model_version` varchar(20) default null, `tosca_node_type` varchar(200) default null, - `aic_version_min` varchar(20) not null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, `orchestration_mode` varchar(20) default 'heat', `resource_category` varchar(20) default null, @@ -151,8 +152,7 @@ create table `network_resource` ( primary key (`model_uuid`), key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), - constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, - constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade ) engine=innodb default charset=latin1; @@ -168,6 +168,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -203,6 +204,7 @@ create table `service` ( `service_role` varchar(200) default null, `environment_context` varchar(200) default null, `workload_context` varchar(200) default null, + `resource_order` varchar(200) default null, primary key (`model_uuid`), key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade @@ -381,6 +383,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java index e28bdb2f96..0c2a49ae53 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -73,6 +73,17 @@ public interface MsoRequestsDbAdapter { @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; @WebMethod + public void initServiceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = false) String operationId, + @WebParam(name = "operationType") @XmlElement(required = false) String operationType, + @WebParam(name = "userId") @XmlElement(required = false) String userId, + @WebParam(name = "result") @XmlElement(required = false) String result, + @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; + + @WebMethod public void initResourceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, @WebParam(name = "operationId") @XmlElement(required = true) String operationId, @WebParam(name = "operationType") @XmlElement(required = true) String operationType, diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 893156ce7d..626e3568bc 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -220,6 +220,38 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } /** + * Init operation status <br> + * + * @param serviceId + * @param operationId + * @param operationType + * @param userId + * @param result + * @param operationContent + * @param progress + * @param reason + * @throws MsoRequestsDbException + * @since ONAP Casablanca Release + */ + @Override + @Transactional + public void initServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, + String result, String operationContent, String progress, String reason) throws MsoRequestsDbException { + OperationStatus operStatus = new OperationStatus(); + + operStatus.setOperationId(operationId); + operStatus.setServiceId(serviceId); + operStatus.setUserId(userId); + operStatus.setOperation(operationType); + operStatus.setReason(reason); + operStatus.setProgress(progress); + operStatus.setResult(result); + operStatus.setOperationContent(operationContent); + operStatus.setResult(result); + operationStatusRepository.save(operStatus); + } + + /** * init the operation status of all the resources <br> * * @param serviceId @@ -306,7 +338,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { resStatus.setErrorCode(errorCode); resStatus.setStatusDescription(statusDescription); resourceOperationStatusRepository.save(resStatus); - + updateOperationStatusBasedOnResourceStatus(resStatus); } diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql new file mode 100644 index 0000000000..87401ade13 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql @@ -0,0 +1,11 @@ +use requestdb; + +ALTER TABLE infra_active_requests + MODIFY IF EXISTS AIC_CLOUD_REGION varchar(50) NULL, + MODIFY IF EXISTS AIC_NODE_CLLI varchar(50) NULL; + +ALTER TABLE archived_infra_requests + MODIFY IF EXISTS AIC_CLOUD_REGION varchar(50) NULL, + MODIFY IF EXISTS AIC_NODE_CLLI varchar(50) NULL; + + diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index 4b3181e6e9..65c7d093a9 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -84,6 +84,14 @@ public class SDNCRestClient{ msoLogger.debug("BPEL Request:" + bpelRequest.toString()); + // Added delay to allow completion of create request to SDNC + // before executing activate of create request. + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + String action = bpelRequest.getRequestHeader().getSvcAction(); String operation = bpelRequest.getRequestHeader().getSvcOperation(); String bpelReqId = bpelRequest.getRequestHeader().getRequestId(); |