diff options
70 files changed, 4390 insertions, 1151 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java index c6e29d05d7..d2b3334c8c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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. @@ -20,166 +22,78 @@ package org.onap.so.cloudify.beans; -import java.util.HashMap; import java.util.Map; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import org.onap.so.cloudify.v3.model.Execution; - /* * This Java bean class relays Heat stack status information to ActiveVOS processes. - * + * * This bean is returned by all Heat-specific adapter operations (create, query, delete) */ -public class DeploymentInfo { - // Set defaults for everything - private String id = ""; - private DeploymentStatus status = DeploymentStatus.NOTFOUND; - private Map<String,Object> outputs = new HashMap<String,Object>(); - private Map<String,Object> inputs = new HashMap<String,Object>(); - private String lastAction; - private String actionStatus; - private String errorMessage; - - public DeploymentInfo () { - } - - public DeploymentInfo (String id, Map<String,Object> outputs) { - this.id = id; - if (outputs != null) this.outputs = outputs; - } - - public DeploymentInfo (String id) { - this.id = id; - } - - public DeploymentInfo (String id, DeploymentStatus status) { - this.id = id; - this.status = status; - } - - public DeploymentInfo (Deployment deployment) { - this(deployment, null, null); - } - - /** - * Construct a DeploymentInfo object from a deployment and the latest Execution action - * @param deployment - * @param execution - */ - public DeploymentInfo (Deployment deployment, DeploymentOutputs outputs, Execution execution) - { - if (deployment == null) { - this.id = null; - return; - } - - this.id = deployment.getId(); - - if (outputs != null) - this.outputs = outputs.getOutputs(); - - if (deployment.getInputs() != null) - this.inputs = deployment.getInputs(); - - if (execution != null) { - this.lastAction = execution.getWorkflowId(); - this.actionStatus = execution.getStatus(); - this.errorMessage = execution.getError(); - - // Compute the status based on the last workflow - if (lastAction.equals("install")) { - if (actionStatus.equals("terminated")) - this.status = DeploymentStatus.INSTALLED; - else if (actionStatus.equals("failed")) - this.status = DeploymentStatus.FAILED; - else if (actionStatus.equals("started") || actionStatus.equals("pending")) - this.status = DeploymentStatus.INSTALLING; - else - this.status = DeploymentStatus.UNKNOWN; - } - else if (lastAction.equals("uninstall")) { - if (actionStatus.equals("terminated")) - this.status = DeploymentStatus.CREATED; - else if (actionStatus.equals("failed")) - this.status = DeploymentStatus.FAILED; - else if (actionStatus.equals("started") || actionStatus.equals("pending")) - this.status = DeploymentStatus.UNINSTALLING; - else - this.status = DeploymentStatus.UNKNOWN; - } - else { - // Could have more cases in the future for different actions. - this.status = DeploymentStatus.UNKNOWN; - } - } - else { - this.status = DeploymentStatus.CREATED; - } - } - - public String getId() { - return id; - } - - public void setId (String id) { - this.id = id; - } - - public DeploymentStatus getStatus() { - return status; - } - - public void setStatus (DeploymentStatus status) { - this.status = status; - } - - public Map<String,Object> getOutputs () { - return outputs; - } - - public void setOutputs (Map<String,Object> outputs) { - this.outputs = outputs; - } - - public Map<String,Object> getInputs () { - return inputs; - } - - public void setInputs (Map<String,Object> inputs) { - this.inputs = inputs; - } - - public String getLastAction() { - return lastAction; - } - - public String getActionStatus() { - return actionStatus; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void saveExecutionStatus (Execution execution) { - this.lastAction = execution.getWorkflowId(); - this.actionStatus = execution.getStatus(); - this.errorMessage = execution.getError(); - } - - @Override +public final class DeploymentInfo { + + private final String id; + private final DeploymentStatus status; + private final Map<String, Object> outputs; + private final Map<String, Object> inputs; + private final String lastAction; + private final String actionStatus; + private final String errorMessage; + + DeploymentInfo(String id, DeploymentStatus deploymentStatus, + Map<String, Object> deploymentOutputs, + Map<String, Object> deploymentInputs, + String lastAction, + String actionStatus, + String errorMessage) { + + this.id = id; + this.status = deploymentStatus; + this.outputs = deploymentOutputs; + this.inputs = deploymentInputs; + this.lastAction = lastAction; + this.actionStatus = actionStatus; + this.errorMessage = errorMessage; + } + + public String getId() { + return id; + } + + public DeploymentStatus getStatus() { + return status; + } + + public Map<String, Object> getOutputs() { + return outputs; + } + + public Map<String, Object> getInputs() { + return inputs; + } + + public String getLastAction() { + return lastAction; + } + + public String getActionStatus() { + return actionStatus; + } + + public String getErrorMessage() { + return errorMessage; + } + + @Override public String toString() { return "DeploymentInfo {" + - "id='" + id + '\'' + - ", inputs='" + inputs + '\'' + - ", outputs='" + outputs + '\'' + - ", lastAction='" + lastAction + '\'' + - ", status='" + status + '\'' + - ", errorMessage='" + errorMessage + '\'' + - '}'; + "id='" + id + '\'' + + ", inputs='" + inputs + '\'' + + ", outputs='" + outputs + '\'' + + ", lastAction='" + lastAction + '\'' + + ", status='" + status + '\'' + + ", errorMessage='" + errorMessage + '\'' + + '}'; } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java new file mode 100644 index 0000000000..2e12869c95 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java @@ -0,0 +1,118 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 Nokia. + * ============================================================================= + * 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.cloudify.beans; + +import java.util.HashMap; +import java.util.Map; +import org.onap.so.cloudify.v3.model.Execution; + +public final class DeploymentInfoBuilder { + + private String id = ""; + private DeploymentStatus deploymentStatus = DeploymentStatus.NOTFOUND; + private Map<String, Object> deploymentOutputs = new HashMap<>(); + private Map<String, Object> deploymentInputs = new HashMap<>(); + private String lastAction; + private String actionStatus; + private String errorMessage; + + public DeploymentInfoBuilder withId(String id) { + this.id = id; + return this; + } + + public DeploymentInfoBuilder withStatus(DeploymentStatus deploymentStatus) { + this.deploymentStatus = deploymentStatus; + return this; + } + + public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) { + this.deploymentOutputs = deploymentOutputs; + return this; + } + + public DeploymentInfoBuilder withDeploymentInputs(Map<String, Object> deploymentInputs) { + this.deploymentInputs = deploymentInputs; + return this; + } + + public DeploymentInfoBuilder withLastAction(String lastAction) { + this.lastAction = lastAction; + return this; + } + + public DeploymentInfoBuilder withActionStatus(String actionStatus) { + this.actionStatus = actionStatus; + return this; + } + + public DeploymentInfoBuilder withErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + return this; + } + + public DeploymentInfoBuilder fromExecution(Execution execution) { + if (execution != null) { + this.lastAction = execution.getWorkflowId(); + this.actionStatus = execution.getStatus(); + this.errorMessage = execution.getError(); + + // Compute the status based on the last workflow + if (lastAction.equals("install")) { + if (actionStatus.equals("terminated")) { + this.deploymentStatus = DeploymentStatus.INSTALLED; + } else if (actionStatus.equals("failed")) { + this.deploymentStatus = DeploymentStatus.FAILED; + } else if (actionStatus.equals("started") || actionStatus.equals("pending")) { + this.deploymentStatus = DeploymentStatus.INSTALLING; + } else { + this.deploymentStatus = DeploymentStatus.UNKNOWN; + } + } else if (lastAction.equals("uninstall")) { + if (actionStatus.equals("terminated")) { + this.deploymentStatus = DeploymentStatus.CREATED; + } else if (actionStatus.equals("failed")) { + this.deploymentStatus = DeploymentStatus.FAILED; + } else if (actionStatus.equals("started") || actionStatus.equals("pending")) { + this.deploymentStatus = DeploymentStatus.UNINSTALLING; + } else { + this.deploymentStatus = DeploymentStatus.UNKNOWN; + } + } else { + // Could have more cases in the future for different actions. + this.deploymentStatus = DeploymentStatus.UNKNOWN; + } + } else { + this.deploymentStatus = DeploymentStatus.CREATED; + } + + return this; + } + + public DeploymentInfo build() { + return new DeploymentInfo(id, + deploymentStatus, + deploymentOutputs, + deploymentInputs, + lastAction, + actionStatus, + errorMessage); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 677f6395ff..85abf9403c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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 @@ -20,6 +22,9 @@ package org.onap.so.cloudify.utils; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -30,7 +35,6 @@ import java.util.Map; import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; - import org.onap.so.adapters.vdu.CloudInfo; import org.onap.so.adapters.vdu.PluginAction; import org.onap.so.adapters.vdu.VduArtifact; @@ -42,14 +46,13 @@ 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.cloud.CloudConfig; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.cloudify.base.client.CloudifyBaseException; import org.onap.so.cloudify.base.client.CloudifyClientTokenProvider; import org.onap.so.cloudify.base.client.CloudifyConnectException; import org.onap.so.cloudify.base.client.CloudifyRequest; import org.onap.so.cloudify.base.client.CloudifyResponseException; import org.onap.so.cloudify.beans.DeploymentInfo; +import org.onap.so.cloudify.beans.DeploymentInfoBuilder; import org.onap.so.cloudify.beans.DeploymentStatus; import org.onap.so.cloudify.exceptions.MsoCloudifyException; import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound; @@ -77,6 +80,8 @@ import org.onap.so.cloudify.v3.model.Executions; import org.onap.so.cloudify.v3.model.OpenstackConfig; import org.onap.so.cloudify.v3.model.StartExecutionParams; import org.onap.so.config.beans.PoConfig; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -93,10 +98,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ @@ -155,7 +156,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * @param inputs A map of key/value inputs * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client * @param timeoutMinutes Timeout after which the "install" will be cancelled - * @param environment An optional yaml-format string to specify environmental parameters * @param backout Flag to delete deployment on install Failure - defaulted to True * @return A DeploymentInfo object * @throws MsoCloudifyException Thrown if the Cloudify API call returns an exception. @@ -256,7 +256,12 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Success! // Create and return a DeploymentInfo structure. Include the Runtime outputs DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); - return new DeploymentInfo (deployment, outputs, installWorkflow); + return new DeploymentInfoBuilder() + .withId(deployment.getId()) + .withDeploymentInputs(deployment.getInputs()) + .withDeploymentOutputs(outputs.getOutputs()) + .fromExecution(installWorkflow) + .build(); } else { // The workflow completed with errors. Must try to back it out. @@ -538,7 +543,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * * @param tenantId The Openstack ID of the tenant in which to query * @param cloudSiteId The cloud identifier (may be a region) in which to query - * @param stackName The name of the stack to query (may be simple or canonical) * @return A StackInfo object * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. */ @@ -556,7 +560,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ Cloudify cloudify = getCloudifyClient (cloudSite.get()); // Build and send the Cloudify request - Deployment deployment = null; + Deployment deployment = new Deployment(); DeploymentOutputs outputs = null; try { GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId); @@ -573,10 +577,18 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // If no executions, does this give NOT_FOUND or empty set? if (executions.getItems().isEmpty()) { - return new DeploymentInfo (deployment); + return new DeploymentInfoBuilder() + .withId(deployment.getId()) + .withDeploymentInputs(deployment.getInputs()) + .build(); } else { - return new DeploymentInfo (deployment, outputs, executions.getItems().get(0)); + return new DeploymentInfoBuilder() + .withId(deployment.getId()) + .withDeploymentInputs(deployment.getInputs()) + .withDeploymentOutputs(outputs.getOutputs()) + .fromExecution(executions.getItems().get(0)) + .build(); } } catch (CloudifyConnectException ce) { @@ -589,10 +601,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Got a NOT FOUND error. React differently based on deployment vs. execution if (deployment != null) { // Got NOT_FOUND on the executions. Assume this is a valid "empty" set - return new DeploymentInfo (deployment, outputs, null); + return new DeploymentInfoBuilder() + .withId(deployment.getId()) + .withDeploymentInputs(deployment.getInputs()) + .withDeploymentOutputs(outputs.getOutputs()) + .build(); } else { // Deployment not found. Default status of a DeploymentInfo object is NOTFOUND - return new DeploymentInfo (deploymentId); + return new DeploymentInfoBuilder().withId(deploymentId).build(); } } throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); @@ -615,8 +631,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * * @param tenantId The Openstack ID of the tenant in which to perform the delete * @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack. - * @param stackName The name/id of the stack to delete. May be simple or canonical - * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client * @return A StackInfo object * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. * @throws MsoCloudSiteNotFound @@ -651,7 +665,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Deployment doesn't exist. Return a "NOTFOUND" DeploymentInfo object // TODO: Should return NULL? LOGGER.debug("Deployment requested for deletion does not exist: " + deploymentId); - return new DeploymentInfo (deploymentId, DeploymentStatus.NOTFOUND); + return new DeploymentInfoBuilder() + .withId(deploymentId) + .withStatus(DeploymentStatus.NOTFOUND) + .build(); } else { // Convert the CloudifyResponseException to an MsoOpenstackException LOGGER.debug("ERROR STATUS = " + e.getStatus() + ",\n" + e.getMessage() + "\n" + e.getLocalizedMessage()); @@ -741,7 +758,12 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ } // Return the deleted deployment info (with runtime outputs) along with the completed uninstall workflow status - return new DeploymentInfo (deployment, outputs, uninstallWorkflow); + return new DeploymentInfoBuilder() + .withId(deployment.getId()) + .withDeploymentInputs(deployment.getInputs()) + .withDeploymentOutputs(outputs.getOutputs()) + .fromExecution(uninstallWorkflow) + .build(); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 15f84890b7..476bff3692 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -277,8 +277,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ boolean backout) throws MsoException { // Take out the multicloud inputs, if present. - String[] directives = { "oof_directives", "sdnc_directives", "generic_vnf_id", "vf_module_id" }; - for (String key : directives) { + for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) { if (stackInputs.containsKey(key)) { stackInputs.remove(key); if (stackInputs.isEmpty()) { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java deleted file mode 100644 index 9b2475a1c4..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============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.openstack.utils; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MsoMulticloudParam { - - @JsonProperty("generic-vnf-id") - private String genericVnfId; - - @JsonProperty("vf-module-id") - private String vfModuleId; - - @JsonProperty("oof_directives") - private String oofDirectives; - - @JsonProperty("sdnc_directives") - private String sdncDirectives; - - @JsonProperty("template_type") - private String templateType; - - @JsonProperty("template_data") - private String templateData; - - public void setGenericVnfId(String genericVnfId){ - this.genericVnfId = genericVnfId; - } - - public String getGenericVnfId(){ - return this.genericVnfId; - } - - public void setVfModuleId(String vfModuleId){ - this.vfModuleId = vfModuleId; - } - - public String getVfModuleId(){ - return this.vfModuleId; - } - - public void setOofDirectives(String oofDirectives){ - this.oofDirectives = oofDirectives; - } - - public String getOofDirectives(){ - return this.oofDirectives; - } - - public void setSdncDirectives(String sdncDirectives){ - this.sdncDirectives = sdncDirectives; - } - - public String getSdncDirectives(){ - return this.sdncDirectives; - } - - public void setTemplateType(String templateType){ - this.templateType = templateType; - } - - public String TemplateType(){ - return this.templateType; - } - - public void setTemplateData(String templateData){ - this.templateData = templateData; - } - - public String getTemplateData(){ - return this.templateData; - } - - @Override - public String toString() { - return String.format("MulticloudParam{" - + "genericVnfId='%s'," - + " vfModuleId='%s'," - + " oofDirectives='%s'," - + " sdncDirectives='%s'," - + " templateType='%s'," - + " templateData='%s'" - + "}", - genericVnfId, - vfModuleId, - oofDirectives, - sdncDirectives, - templateType, - templateData); - } -} 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 4ed35a4d28..306de05eea 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 @@ -21,13 +21,21 @@ package org.onap.so.openstack.utils; import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Scanner; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; +import javax.ws.rs.core.Response.StatusType; import javax.ws.rs.core.Response; +import org.apache.http.HttpStatus; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.so.adapters.vdu.CloudInfo; @@ -48,24 +56,27 @@ import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.onap.so.openstack.mappers.StackInfoMapper; import org.onap.so.client.HttpClient; import org.onap.so.client.RestClient; -import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.utils.TargetEntity; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.heat.model.CreateStackParam; import com.woorea.openstack.heat.model.Stack; @Component public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ - @Autowired - protected CloudConfig cloudConfig; - - @Autowired - private Environment env; + 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 VF_MODULE_ID = "vf_module_id"; + public static final String TEMPLATE_TYPE = "template_type"; + public static final List<String> MULTICLOUD_INPUTS = + Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, GENERIC_VNF_ID, VF_MODULE_ID, TEMPLATE_TYPE); private static final String ONAP_IP = "ONAP_IP"; @@ -75,6 +86,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class); + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + /****************************************************************************** * * Methods (and associated utilities) to implement the VduPlugin interface @@ -135,59 +148,90 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ Map <String, Object> heatFiles, boolean backout) throws MsoException { - // Get the directives, if present. - String oofDirectives = null; - String sdncDirectives = null; - String genericVnfId = null; - String vfModuleId = null; + logger.trace("Started MsoMulticloudUtils.createStack"); - String key = "oof_directives"; - if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) { - oofDirectives = (String) stackInputs.get(key); - stackInputs.remove(key); - } - key = "sdnc_directives"; - if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) { - sdncDirectives = (String) stackInputs.get(key); - stackInputs.remove(key); - } - key = "generic_vnf_id"; - if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) { - genericVnfId = (String) stackInputs.get(key); - stackInputs.remove(key); - } - key = "vf_module_id"; - if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) { - vfModuleId = (String) stackInputs.get(key); - stackInputs.remove(key); + // Get the directives, if present. + String oofDirectives = ""; + String sdncDirectives = ""; + String genericVnfId = ""; + String vfModuleId = ""; + String templateType = ""; + + for (String key: MULTICLOUD_INPUTS) { + if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) { + if ( key == OOF_DIRECTIVES) {oofDirectives = (String) stackInputs.get(key);} + if ( key == SDNC_DIRECTIVES) {sdncDirectives = (String) stackInputs.get(key);} + if ( key == GENERIC_VNF_ID) {genericVnfId = (String) stackInputs.get(key);} + if ( key == VF_MODULE_ID) {vfModuleId = (String) stackInputs.get(key);} + if ( key == TEMPLATE_TYPE) {templateType = (String) stackInputs.get(key);} + if (logger.isDebugEnabled()) { + logger.debug(String.format("Found %s: %s", key, stackInputs.get(key))); + } + stackInputs.remove(key); + } } // create the multicloud payload CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles); - MsoMulticloudParam multicloudParam = new MsoMulticloudParam(); - multicloudParam.setGenericVnfId(genericVnfId); - multicloudParam.setVfModuleId(vfModuleId); - multicloudParam.setOofDirectives(oofDirectives); - multicloudParam.setSdncDirectives(sdncDirectives); - multicloudParam.setTemplateType("heat"); - multicloudParam.setTemplateData(stack.toString()); + MulticloudRequest multicloudRequest= new MulticloudRequest(); + HttpEntity<MulticloudRequest> request = null; + try { + multicloudRequest.setGenericVnfId(genericVnfId); + multicloudRequest.setVfModuleId(vfModuleId); + multicloudRequest.setOofDirectives(oofDirectives); + multicloudRequest.setSdncDirectives(sdncDirectives); + multicloudRequest.setTemplateType(templateType); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16))); + } + multicloudRequest.setTemplateData(JSON_MAPPER.writeValueAsString(stack)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); + } + CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> + new MsoCloudSiteNotFound(cloudSiteId)); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + HttpHeaders headers = new HttpHeaders(); + headers.set ("X-Auth-User", cloudIdentity.getMsoId ()); + headers.set ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ())); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString()); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString()); + + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Request Headers: %s", headers.toString())); + } + request = new HttpEntity<>(multicloudRequest, headers); + } catch (Exception e) { + logger.debug("ERROR making multicloud JSON body ", e); + } String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint)); + } RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); - if (multicloudClient != null) { - Response res = multicloudClient.post(multicloudParam); - logger.debug("Multicloud Post response is: " + res); - } + Response response = multicloudClient.post(request); - Stack responseStack = new Stack(); - responseStack.setStackStatus(HeatStatus.CREATED.toString()); + StackInfo responseStackInfo = new StackInfo(); + responseStackInfo.setName(stackName); + responseStackInfo.setStatus(mapResponseToHeatStatus(response)); - return new StackInfoMapper(responseStack).map(); + MulticloudCreateResponse multicloudResponseBody = null; + if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) { + multicloudResponseBody = getCreateBody((java.io.InputStream)response.getEntity()); + responseStackInfo.setCanonicalName(multicloudResponseBody.getWorkloadId()); + if (logger.isDebugEnabled()) { + logger.debug("Multicloud Create Response Body: " + multicloudResponseBody); + } + } + + return responseStackInfo; } + @Override public Map<String, Object> queryStackForOutputs(String cloudSiteId, String tenantId, String stackName) throws MsoException { logger.debug("MsoHeatUtils.queryStackForOutputs)"); @@ -211,64 +255,129 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ */ @Override public StackInfo queryStack (String cloudSiteId, String tenantId, String stackName) throws MsoException { - logger.debug ("Query multicloud HEAT stack: " + stackName + " in tenant " + tenantId); + if (logger.isDebugEnabled()) { + logger.debug (String.format("Query multicloud HEAT stack: %s in tenant %s", stackName, tenantId)); + } - String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName); + StackInfo returnInfo = new StackInfo(); + returnInfo.setName(stackName); + String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName); RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); if (multicloudClient != null) { Response response = multicloudClient.get(); - logger.debug("Multicloud Get response is: " + response); + if (logger.isDebugEnabled()) { + logger.debug (String.format("Mulicloud GET Response: %s", response.toString())); + } + + returnInfo.setStatus(mapResponseToHeatStatus(response)); - return new StackInfo (stackName, HeatStatus.CREATED); + MulticloudQueryResponse multicloudQueryBody = null; + if (response.getStatus() == Response.Status.OK.getStatusCode() && response.hasEntity()) { + multicloudQueryBody = getQueryBody((java.io.InputStream)response.getEntity()); + returnInfo.setCanonicalName(multicloudQueryBody.getWorkloadId()); + if (logger.isDebugEnabled()) { + logger.debug("Multicloud Create Response Body: " + multicloudQueryBody.toString()); + } + } } - return new StackInfo (stackName, HeatStatus.NOTFOUND); + return returnInfo; + } public StackInfo deleteStack (String cloudSiteId, String tenantId, String stackName) throws MsoException { - logger.debug ("Delete multicloud HEAT stack: " + stackName + " in tenant " + tenantId); + if (logger.isDebugEnabled()) { + logger.debug (String.format("Delete multicloud HEAT stack: %s in tenant %s", stackName, tenantId)); + } + StackInfo returnInfo = new StackInfo(); + returnInfo.setName(stackName); + Response response = null; String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName); - RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); if (multicloudClient != null) { - Response response = multicloudClient.delete(); - logger.debug("Multicloud Get response is: " + response); - - return new StackInfo (stackName, HeatStatus.DELETING); + response = multicloudClient.delete(); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Delete response is: %s", response.getEntity().toString())); + } } - - return new StackInfo (stackName, HeatStatus.FAILED); + returnInfo.setStatus(mapResponseToHeatStatus(response)); + return returnInfo; } // --------------------------------------------------------------- // PRIVATE FUNCTIONS FOR USE WITHIN THIS CLASS + private HeatStatus mapResponseToHeatStatus(Response response) { + if (response.getStatusInfo().getStatusCode() == Response.Status.OK.getStatusCode()) { + return HeatStatus.CREATED; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.CREATED.getStatusCode()) { + return HeatStatus.CREATED; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.NO_CONTENT.getStatusCode()) { + return HeatStatus.CREATED; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.BAD_REQUEST.getStatusCode()) { + return HeatStatus.FAILED; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { + return HeatStatus.FAILED; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.NOT_FOUND.getStatusCode()) { + return HeatStatus.NOTFOUND; + } else if (response.getStatusInfo().getStatusCode() == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) { + return HeatStatus.FAILED; + } else { + return HeatStatus.UNKNOWN; + } + } + private MulticloudCreateResponse getCreateBody(java.io.InputStream in) { + Scanner scanner = new Scanner(in); + scanner.useDelimiter("\\Z"); + String body = ""; + if (scanner.hasNext()) { + body = scanner.next(); + } + scanner.close(); - private String getMsbHost() { - // MSB_IP will be set as ONAP_IP environment parameter in install flow. - String msbIp = System.getenv().get(ONAP_IP); + try { + return new ObjectMapper().readerFor(MulticloudCreateResponse.class).readValue(body); + } catch (Exception e) { + logger.debug("Exception retrieving multicloud vfModule POST response body " + e); + } + return null; + } - // if ONAP IP is not set. get it from config file. - if (null == msbIp || msbIp.isEmpty()) { - msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP); + private MulticloudQueryResponse getQueryBody(java.io.InputStream in) { + Scanner scanner = new Scanner(in); + scanner.useDelimiter("\\Z"); + String body = ""; + if (scanner.hasNext()) { + body = scanner.next(); } - Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); + scanner.close(); - return UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString(); + try { + return new ObjectMapper().readerFor(MulticloudQueryResponse.class).readValue(body); + } catch (Exception e) { + logger.debug("Exception retrieving multicloud workload query response body " + e); + } + return null; } private String getMulticloudEndpoint(String cloudSiteId, String workloadId) throws MsoCloudSiteNotFound { CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId)); - String endpoint = getMsbHost() + cloudSite.getIdentityService().getIdentityUrl(); + String endpoint = cloudSite.getIdentityService().getIdentityUrl(); if (workloadId != null) { - return endpoint + workloadId; + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Endpoint is: %s/%s", endpoint, workloadId)); + } + return String.format("%s/%s", endpoint, workloadId); } else { + if (logger.isDebugEnabled()) { + logger.debug(String.format("Multicloud Endpoint is: %s", endpoint)); + } return endpoint; } } @@ -277,13 +386,13 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ RestClient client = null; try { client= new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(), - "application/json", TargetEntity.OPENSTACK_ADAPTER); + MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD); } catch (MalformedURLException e) { - logger.debug("Encountered malformed URL error getting multicloud rest client " + e.getMessage()); + logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage())); } catch (IllegalArgumentException e) { - logger.debug("Encountered illegal argument getting multicloud rest client " + e.getMessage()); + logger.debug(String.format("Encountered illegal argument getting multicloud rest client %s",e.getMessage())); } catch (UriBuilderException e) { - logger.debug("Encountered URI builder error getting multicloud rest client " + e.getMessage()); + logger.debug(String.format("Encountered URI builder error getting multicloud rest client %s", e.getMessage())); } return client; } @@ -382,7 +491,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ try { // Delete the Multicloud stack - StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId, true); + StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId); // Populate a VduInstance based on the deleted Cloudify Deployment object VduInstance vduInstance = stackInfoToVduInstance(stackInfo); @@ -425,6 +534,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ { VduInstance vduInstance = new VduInstance(); + if (logger.isDebugEnabled()) { + logger.debug(String.format("StackInfo to convert: %s", stackInfo.getParameters().toString())); + } // The full canonical name as the instance UUID vduInstance.setVduInstanceId(stackInfo.getCanonicalName()); vduInstance.setVduInstanceName(stackInfo.getName()); @@ -447,6 +559,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // There are lots of HeatStatus values, so this is a bit long... HeatStatus heatStatus = stackInfo.getStatus(); String statusMessage = stackInfo.getStatusMessage(); + logger.debug("HeatStatus = " + heatStatus + " msg = " + statusMessage); + + if (logger.isDebugEnabled()) { + logger.debug(String.format("Stack Status: %s", heatStatus.toString())); + logger.debug(String.format("Stack Status Message: %s", statusMessage)); + } if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) { vduStatus.setState(VduStateType.INSTANTIATING); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java new file mode 100644 index 0000000000..543ad07d52 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java @@ -0,0 +1,77 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "id", + "links" +}) +public class MulticloudCreateHeatResponse implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("id") + private String id; + @JsonProperty("links") + private List<MulticloudCreateLinkResponse> links; + + @JsonCreator + public MulticloudCreateHeatResponse( + @JsonProperty("id") String id, + @JsonProperty("links") List<MulticloudCreateLinkResponse> links) { + this.id = id; + this.links = links; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("links") + public List<MulticloudCreateLinkResponse> getLinks() { + return links; + } + + @JsonProperty("links") + public void setLinks(List<MulticloudCreateLinkResponse> links) { + this.links = links; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("links", links).toString(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java new file mode 100644 index 0000000000..b609ac96c4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java @@ -0,0 +1,76 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "href", + "rel" +}) +public class MulticloudCreateLinkResponse implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("href") + private String href; + @JsonProperty("rel") + private String rel; + + @JsonCreator + public MulticloudCreateLinkResponse( + @JsonProperty("href") String href, + @JsonProperty("rel") String rel) { + this.href = href; + this.rel = rel; + } + + @JsonProperty("href") + public String getHref() { + return href; + } + + @JsonProperty("href") + public void setHref(String href) { + this.href = href; + } + + @JsonProperty("rel") + public String getRel() { + return rel; + } + + @JsonProperty("rel") + public void setRel(String rel) { + this.rel = rel; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("href", href).append("rel", rel).toString(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java new file mode 100644 index 0000000000..fafd4a074d --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java @@ -0,0 +1,90 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "template_type", + "workload_id", + "template_response" +}) +public class MulticloudCreateResponse implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("template_type") + private String templateType; + @JsonProperty("workload_id") + private String workloadId; + @JsonProperty("template_response") + private MulticloudCreateStackResponse templateResponse; + + @JsonCreator + public MulticloudCreateResponse( + @JsonProperty("template_type") String templateType, + @JsonProperty("workload_id") String workloadId, + @JsonProperty("template_response") MulticloudCreateStackResponse templateResponse) { + this.templateType = templateType; + this.workloadId = workloadId; + this.templateResponse = templateResponse; + } + + @JsonProperty("template_type") + public String getTemplateType() { + return templateType; + } + + @JsonProperty("template_type") + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + @JsonProperty("workload_id") + public String getWorkloadId() { + return workloadId; + } + + @JsonProperty("workload_id") + public void setWorkloadId(String workloadId) { + this.workloadId = workloadId; + } + + @JsonProperty("template_response") + public void setTemplateResponse(MulticloudCreateStackResponse templateResponse) { + this.templateResponse = templateResponse; + } + + @JsonProperty("template_response") + public MulticloudCreateStackResponse getTemplateResponse() { + return templateResponse; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId).append("templateResponse", templateResponse).toString(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java new file mode 100644 index 0000000000..f1d44a8814 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java @@ -0,0 +1,60 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "stack" +}) +public class MulticloudCreateStackResponse implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("stack") + private MulticloudCreateHeatResponse stack; + + @JsonCreator + public MulticloudCreateStackResponse( + @JsonProperty("stack") MulticloudCreateHeatResponse stack) { + this.stack = stack; + } + + @JsonProperty("stack") + public MulticloudCreateHeatResponse getStack() { + return stack; + } + + @JsonProperty("stack") + public void setStack(MulticloudCreateHeatResponse stack) { + this.stack = stack; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("stack", stack).toString(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java new file mode 100644 index 0000000000..b22e9dc03e --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java @@ -0,0 +1,90 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "template_type", + "workload_id", + "workload_status" +}) +public class MulticloudQueryResponse implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("template_type") + private String templateType; + @JsonProperty("workload_id") + private String workloadId; + @JsonProperty("workload_status") + private String workloadStatus; + + @JsonCreator + public MulticloudQueryResponse( + @JsonProperty("template_type") String templateType, + @JsonProperty("workload_id") String workloadId, + @JsonProperty("workload_status") String workloadStatus) { + this.templateType = templateType; + this.workloadId = workloadId; + this.workloadStatus = workloadStatus; + } + + @JsonProperty("template_type") + public String getTemplateType() { + return templateType; + } + + @JsonProperty("template_type") + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + @JsonProperty("workload_id") + public String getWorkloadId() { + return workloadId; + } + + @JsonProperty("workload_id") + public void setWorkloadId(String workloadId) { + this.workloadId = workloadId; + } + + @JsonProperty("workload_status") + public String getWorkloadStatus() { + return workloadStatus; + } + + @JsonProperty("workload_status") + public void setWorkloadStatus(String workloadStatus) { + this.workloadStatus = workloadStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId).append("workloadStatus", workloadStatus).toString(); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java new file mode 100644 index 0000000000..fefc0951f6 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java @@ -0,0 +1,120 @@ +/*- + * ============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.openstack.utils; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "generic-vnf-id", + "vf-module-id", + "oof_directives", + "sdnc_directives", + "template_type", + "template_data" +}) +public class MulticloudRequest implements Serializable { + private final static long serialVersionUID = -5215028275577848311L; + + @JsonProperty("generic-vnf-id") + private String genericVnfId; + @JsonProperty("vf-module-id") + private String vfModuleId; + @JsonProperty("oof_directives") + private String oofDirectives; + @JsonProperty("sdnc_directives") + private String sdncDirectives; + @JsonProperty("template_type") + private String templateType; + @JsonProperty("template_data") + private String templateData; + + + @JsonProperty("generic-vnf-id") + public String getGenericVnfId() { + return genericVnfId; + } + + @JsonProperty("generic-vnf-id") + public void setGenericVnfId(String genericVnfId) { + this.genericVnfId = genericVnfId; + } + + @JsonProperty("vf-module-id") + public String getVfModuleId() { + return vfModuleId; + } + + @JsonProperty("vf-module-id") + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + @JsonProperty("oof_directives") + public String getOofDirectives() { + return oofDirectives; + } + + @JsonProperty("oof_directives") + public void setOofDirectives(String oofDirectives) { + this.oofDirectives = oofDirectives; + } + + @JsonProperty("sdnc_directives") + public String getSdncDirectives() { + return sdncDirectives; + } + + @JsonProperty("sdnc_directives") + public void setSdncDirectives(String sdncDirectives) { + this.sdncDirectives = sdncDirectives; + } + + @JsonProperty("template_type") + public String getTemplateType() { + return templateType; + } + + @JsonProperty("template_type") + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + @JsonProperty("template_data") + public String getTemplateData() { + return templateData; + } + + @JsonProperty("template_data") + public void setTemplateData(String templateData) { + this.templateData = templateData; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("genericVnfId", genericVnfId).append("vfModuleId", vfModuleId).append("oofDirectives", oofDirectives).append("sdncDirectives", sdncDirectives).append("templateType", templateType).append("templateData", templateData).toString(); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java new file mode 100644 index 0000000000..8f172b79ca --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java @@ -0,0 +1,168 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 Nokia. + * ============================================================================= + * 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.cloudify.beans; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableMap; +import org.junit.Test; +import org.onap.so.cloudify.v3.model.Execution; + +public class DeploymentInfoBuilderTest { + + private static final String ERROR_MESSAGE = "something went wrong"; + private static final String INSTALL_WORKFLOW_ID = "install"; + private static final String UNINSTALL_WORKFLOW_ID = "uninstall"; + + @Test + public void shouldConstructDeploymentInfo_withBasicValues() { + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.CREATED) + .withDeploymentOutputs(ImmutableMap.of()) + .withDeploymentInputs(ImmutableMap.of()) + .withActionStatus("started") + .withLastAction(INSTALL_WORKFLOW_ID) + .withErrorMessage(ERROR_MESSAGE) + .build(); + + assertThat(deploymentInfo.getId()).isEqualTo("id"); + assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED); + assertThat(deploymentInfo.getOutputs()).isEqualTo(ImmutableMap.of()); + assertThat(deploymentInfo.getInputs()).isEqualTo(ImmutableMap.of()); + assertThat(deploymentInfo.getActionStatus()).isEqualTo("started"); + assertThat(deploymentInfo.getLastAction()).isEqualTo(INSTALL_WORKFLOW_ID); + assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE); + } + + @Test + public void shouldConstructDeploymentInfo_withCreateDeploymentStatus_fromNullExecution() { + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .fromExecution(null) + .build(); + + assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED); + } + + @Test + public void shouldConstructDeploymentInfo_withInstalledDeploymentStatus_fromTerminatedExecution() { + String workflowIdLastAction = INSTALL_WORKFLOW_ID; + String status = "terminated"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLED; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedInstallExecution() { + String workflowIdLastAction = INSTALL_WORKFLOW_ID; + String status = "failed"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromStartedExecution() { + String workflowIdLastAction = INSTALL_WORKFLOW_ID; + String status = "started"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromPendingExecution() { + String workflowIdLastAction = INSTALL_WORKFLOW_ID; + String status = "pending"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableExecution() { + String workflowIdLastAction = INSTALL_WORKFLOW_ID; + String status = "strangeStatus"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withCreatedDeploymentStatus_fromTerminatedExecution() { + String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; + String status = "terminated"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.CREATED; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedUninstallExecution() { + String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; + String status = "failed"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromStartedUninstallExecution() { + String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; + String status = "started"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromPendingUninstallExecution() { + String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; + String status = "pending"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableUninstallExecution() { + String workflowIdLastAction = UNINSTALL_WORKFLOW_ID; + String status = "strangeStatus"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + @Test + public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_forUnknownExecutionWorkflowId() { + String workflowIdLastAction = "strangeWorkflowIdLastAction"; + String status = "strangeStatus"; + DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN; + verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); + } + + private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus, + DeploymentStatus expectedDeploymentStatus) { + + Execution execution = new Execution(); + execution.setWorkflowId(workflowIdLastAction); + execution.setStatus(actionStatus); + execution.setError(ERROR_MESSAGE); + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .fromExecution(execution) + .build(); + + assertThat(deploymentInfo.getLastAction()).isEqualTo(workflowIdLastAction); + assertThat(deploymentInfo.getActionStatus()).isEqualTo(actionStatus); + assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE); + assertThat(deploymentInfo.getStatus()).isEqualTo(expectedDeploymentStatus); + } +}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java deleted file mode 100644 index e200f9aa96..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* -* ============LICENSE_START======================================================= - * ONAP : SO - * ================================================================================ - * Copyright (C) 2018 TechMahindra - * ================================================================================ - * 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.cloudify.beans; - -import static org.mockito.Mockito.mock; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.mockito.Mock; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import org.onap.so.cloudify.v3.model.Execution; -import org.powermock.api.mockito.PowerMockito; - -public class DeploymentInfoTest { - - @Mock - DeploymentStatus status; - - @Mock - DeploymentOutputs out; - - @Mock - Execution execution; - - @Mock - Deployment deployment; - - @Test - public void test() { - Deployment deployment=mock(Deployment.class); - Map<String,Object> dep=new HashMap(); - Map<String,Object> outputs = new HashMap<String,Object>(); - Map<String,Object> inputs = new HashMap<String,Object>(); - inputs.put("id",dep); - status=DeploymentStatus.CREATED; - outputs.put("id", out); - dep.put("id", outputs); - DeploymentInfo dinfo=new DeploymentInfo(deployment); - DeploymentInfo dinfi=new DeploymentInfo("id"); - DeploymentInfo din=new DeploymentInfo("id",outputs); - DeploymentInfo dfo=new DeploymentInfo("id", status); - DeploymentInfo dfoi=new DeploymentInfo(deployment, out, execution); - dinfo=PowerMockito.spy(new DeploymentInfo()); - dinfo.setId("id"); - dinfi.setInputs(inputs); - din.setStatus(status); - din.setOutputs(outputs); - assert(din.toString()!=null); - assert(din.getOutputs().equals(outputs)); - assert(din.getId().equals("id")); - assert(din.getStatus().equals(status)); - din.getLastAction(); - din.getErrorMessage(); - din.getActionStatus(); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java index 96202c5122..c7aecd90be 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java @@ -2,14 +2,16 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2018 Nokia. * ================================================================================ * 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. @@ -17,7 +19,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.so.cloudify.utils; import static com.shazam.shazamcrest.MatcherAssert.assertThat; @@ -42,6 +43,7 @@ import org.onap.so.adapters.vdu.VduModelInfo; import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.cloud.CloudConfig; +import org.onap.so.cloudify.beans.DeploymentInfoBuilder; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloudify.beans.DeploymentInfo; @@ -82,9 +84,10 @@ public class MsoCloudifyUtilsTest2 { List<VduArtifact> artifacts = new ArrayList<>(); artifacts.add(artifact); vduModel.setArtifacts(artifacts); - DeploymentInfo deployment = new DeploymentInfo(); - deployment.setId("id"); - deployment.setStatus(DeploymentStatus.INSTALLED); + DeploymentInfo deployment = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.INSTALLED) + .build(); Map<String, byte[]> blueprintFiles = new HashMap<>(); blueprintFiles.put(artifact.getName(), artifact.getContent()); String instanceName = "instanceName"; @@ -118,9 +121,10 @@ public class MsoCloudifyUtilsTest2 { CloudInfo cloudInfo = new CloudInfo(); cloudInfo.setCloudSiteId("cloudSiteId"); cloudInfo.setTenantId("tenantId"); - DeploymentInfo deployment = new DeploymentInfo(); - deployment.setId("id"); - deployment.setStatus(DeploymentStatus.INSTALLED); + DeploymentInfo deployment = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.INSTALLED) + .build(); String instanceId = "instanceId"; MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); @@ -148,14 +152,12 @@ public class MsoCloudifyUtilsTest2 { cloudInfo.setTenantId("tenantId"); String instanceId = "instanceId"; int timeoutMinutes = 1; - DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class); - deployment.setId("id"); - deployment.setStatus(DeploymentStatus.CREATED); - when(deployment.getId()).thenReturn("id"); - when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED); - when(deployment.getLastAction()).thenReturn("deleting"); + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.CREATED) + .withLastAction("deleting").build(); MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - doReturn(deployment).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(), + doReturn(deploymentInfo).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(), instanceId, timeoutMinutes); VduInstance actual = cloudify.deleteVdu(cloudInfo, instanceId, timeoutMinutes); @@ -173,16 +175,14 @@ public class MsoCloudifyUtilsTest2 { status.setLastAction(new PluginAction("deleting", null, null)); expected.setStatus(status); - DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class); - deployment.setId("id"); - deployment.setStatus(DeploymentStatus.CREATED); - when(deployment.getId()).thenReturn("id"); - when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED); - when(deployment.getLastAction()).thenReturn("deleting"); + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.CREATED) + .withLastAction("deleting").build(); MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - VduInstance actual = cloudify.deploymentInfoToVduInstance(deployment); + VduInstance actual = cloudify.deploymentInfoToVduInstance(deploymentInfo); assertThat(actual, sameBeanAs(expected)); } @@ -193,16 +193,14 @@ public class MsoCloudifyUtilsTest2 { expected.setState(VduStateType.DELETING); expected.setLastAction(new PluginAction("deleting", null, null)); - DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class); - deployment.setId("id"); - deployment.setStatus(DeploymentStatus.CREATED); - when(deployment.getId()).thenReturn("id"); - when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED); - when(deployment.getLastAction()).thenReturn("deleting"); + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder() + .withId("id") + .withStatus(DeploymentStatus.CREATED) + .withLastAction("deleting").build(); MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - VduStatus actual = cloudify.deploymentStatusToVduStatus(deployment); + VduStatus actual = cloudify.deploymentStatusToVduStatus(deploymentInfo); assertThat(actual, sameBeanAs(expected)); } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql index 5c9e5aae9f..1663fdd6a8 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql @@ -39,7 +39,6 @@ INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORC -- INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('dfcd7471-16c7-444e-8268-d4c50d90593a','UUI_DEFAULT','dfcd7471-16c7-444e-8268-d4c50d90593a','1.0','Default service for UUI to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-23 18:52:03',NULL); -INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('f2e1dc69-c8ef-47e9-8b64-966cc87f2110','*','f2e1dc69-c8ef-47e9-8b64-966cc87f2110','1.0','Default service to use for infra APIH orchestration','2018-01-19 18:52:03',NULL); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (11,'createInstance','1','Custom recipe to create E2E service-instance if no custom BPMN flow is found','/mso/async/services/CreateCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (12,'deleteInstance','1','Custom recipe to delete E2E service-instance if no custom BPMN flow is found','/mso/async/services/DeleteCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); @@ -48,9 +47,6 @@ INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORC INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (15,'updateInstance','1','Custom recipe to update E2E service-instance if no custom BPMN flow is found','/mso/async/services/UpdateCustomE2EServiceInstance',NULL,180,NULL,'2018-03-05 10:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (16,'scaleInstance','1','Custom recipe to scale E2E service-instance if no custom BPMN flow is found','/mso/async/services/ScaleCustomE2EServiceInstance',NULL,180,NULL,'2018-05-15 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); -INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (13,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); -INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (14,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); - INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (1,'*','VOLUME_GROUP',NULL,'CREATE',NULL,'1','Recipe Match All for','/mso/async/services/createCinderVolumeV1',null,180,'2017-10-05 18:52:03'); INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (2,'*','VOLUME_GROUP',NULL,'DELETE',NULL,'1','Recipe Match All for','/mso/async/services/deleteCinderVolumeV1',null,180,'2017-10-05 18:52:03'); INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (3,'*','VOLUME_GROUP',NULL,'UPDATE',NULL,'1','Recipe Match All for','/mso/async/services/updateCinderVolumeV1',null,180,'2017-10-05 18:52:03'); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java index bf69686a76..e38bd02069 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java @@ -29,6 +29,15 @@ public class CatalogDbClientPortChanger extends CatalogDbClient { public String wiremockPort; + CatalogDbClientPortChanger(){ + + } + + CatalogDbClientPortChanger(String baseUri, String auth, String wiremockPort) { + super(baseUri, auth); + this.wiremockPort = wiremockPort; + } + protected URI getUri(String template) { URI uri = URI.create(template); String path = uri.getPath(); 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 4ec5839cb6..5c7b64d054 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 @@ -26,10 +26,13 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; +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.CloudifyManager; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.beans.VfModule; @@ -38,12 +41,15 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import java.net.URI; import java.util.List; import java.util.UUID; @@ -54,12 +60,28 @@ public class CatalogDbClientTest { public static final String MTN13 = "mtn13"; @LocalServerPort private int port; + + @Value("${mso.db.auth}") + private String msoAdaptersAuth; + @Autowired CatalogDbClientPortChanger client; @Before - public void initialize() { - client.wiremockPort = String.valueOf(port); + public void initialize(){ + client.wiremockPort= String.valueOf(port); + } + + @Test + public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(){ + RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "*", "*", "*", "*"); + Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); + } + + @Test + public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound(){ + RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(UUID.randomUUID().toString(), "*", "*", "*", "*"); + Assert.assertNull(rainyDayHandlerStatus); } @Test @@ -363,4 +385,33 @@ public class CatalogDbClientTest { VfModule module = moduleList.get(0); Assert.assertEquals("vSAMP10a DEV Base",module.getDescription()); } + + @Test + public void testPostCloudSite() { + CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); + CloudSite cloudSite = new CloudSite(); + cloudSite.setId("MTN6"); + cloudSite.setClli("TESTCLLI"); + cloudSite.setRegionId("regionId"); + cloudSite.setCloudVersion("VERSION"); + cloudSite.setPlatform("PLATFORM"); + + CloudIdentity cloudIdentity = new CloudIdentity(); + cloudIdentity.setId("RANDOMID"); + cloudIdentity.setIdentityUrl("URL"); + cloudIdentity.setMsoId("MSO_ID"); + cloudIdentity.setMsoPass("MSO_PASS"); + cloudIdentity.setAdminTenant("ADMIN_TENANT"); + cloudIdentity.setMemberRole("ROLE"); + cloudIdentity.setIdentityServerType(ServerType.KEYSTONE); + cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY); + cloudSite.setIdentityService(cloudIdentity); + localClient.postCloudSite(cloudSite); + CloudSite getCloudSite = this.client.getCloudSite("MTN6"); + Assert.assertNotNull(getCloudSite); + Assert.assertNotNull(getCloudSite.getIdentityService()); + Assert.assertEquals("TESTCLLI", getCloudSite.getClli()); + Assert.assertEquals("regionId", getCloudSite.getRegionId()); + Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml index a1e62f5e85..a59ea0ef65 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml @@ -1,5 +1,5 @@ # TEST FILE -catalog.db.endpoint: "http://localhost:" +catalog.db.endpoint: http://localhost:${wiremock.server.port} ssl-enable: false mso: @@ -8,7 +8,7 @@ mso: catalog: db: spring: - endpoint: "http://localhost:" + endpoint: http://localhost:${wiremock.server.port} db: auth: Basic YnBlbDptc28tZGItMTUwNyE= @@ -50,7 +50,7 @@ mariaDB4j: databaseName: catalogdb server: - port: 8080 + port: ${wiremock.server.port} tomcat: max-threads: 50 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 e9567170dd..9a64e62e57 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 @@ -710,6 +710,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { CloudSite cloudSite = cloudSiteOp.get(); MavenLikeVersioning aicV = new MavenLikeVersioning(); aicV.setVersion(cloudSite.getCloudVersion()); + Boolean usingMulticloud = getUsingMulticloud(cloudSite); String vnfMin = vnfResource.getAicVersionMin(); String vnfMax = vnfResource.getAicVersionMax(); @@ -732,23 +733,25 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // Use the VduPlugin. VduPlugin vduPlugin = getVduPlugin(cloudSiteId); - // First, look up to see if the VF already exists. + // First, look up to see if the VF already exists, unless using multicloud adapter long subStartTime1 = System.currentTimeMillis (); - try { - vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleName); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "QueryVDU", vfModuleName); - } - catch (VduException me) { - // Failed to query the VDU due to a plugin exception. - String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "Exception - queryVdu", me); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu", vfModuleName); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + if (!usingMulticloud) { + try { + vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleName); + LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "QueryVDU", vfModuleName); + } + catch (VduException me) { + // Failed to query the VDU due to a plugin exception. + String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "Exception - queryVdu", me); + LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu", vfModuleName); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - // Convert to a generic VnfException - me.addContext ("CreateVFModule"); - throw new VnfException (me); + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + throw new VnfException (me); + } } // More precise handling/messaging if the Module already exists @@ -810,7 +813,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { Map<String, Object> volumeGroupOutputs = null; // If a Volume Group was provided, query its outputs for inclusion in Module input parameters - if (volumeGroupId != null) { + if (!usingMulticloud && volumeGroupId != null) { long subStartTime2 = System.currentTimeMillis (); VduInstance volumeVdu = null; try { @@ -858,7 +861,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("WARNING: Add-on Module request - no Base Module ID provided"); } - if (baseVfModuleId != null) { + // Need to verify if multicloud needs to have the vaseVfModuleId passed to it. Ignoring this for now. + if (!usingMulticloud && baseVfModuleId != null) { long subStartTime2 = System.currentTimeMillis (); VduInstance baseVdu = null; try { @@ -979,9 +983,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } if (!extraInputs.isEmpty()) { - // Add directive inputs - String[] directives = { "oof_directives", "sdnc_directives" }; - for (String key : directives) { + // Add multicloud inputs + for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) { if (extraInputs.contains(key)) { goldenInputs.put(key, inputs.get(key)); extraInputs.remove(key); @@ -1242,4 +1245,12 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // Default - return HEAT plugin, though will fail later return heatUtils; } + + private Boolean getUsingMulticloud (CloudSite cloudSite) { + if (cloudSite.getOrchestrator().equalsIgnoreCase("MULTICLOUD")) { + return true; + } else { + return false; + } + } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java index 88f102c2a5..c332c49832 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java @@ -33,6 +33,10 @@ public class VnfAdapterRestUtils { private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, VnfAdapterRestUtils.class); + private static final String HEAT_MODE = "HEAT"; + private static final String CLOUDIFY_MODE = "CLOUDIFY"; + private static final String MULTICLOUD_MODE = "MULTICLOUD"; + @Autowired private CloudConfig cloudConfig; @@ -65,9 +69,12 @@ public class VnfAdapterRestUtils if (cloudSite.isPresent()) { LOGGER.debug("Got CloudSite: " + cloudSite.toString()); if (cloudConfig.getCloudifyManager(cloudSite.get().getCloudifyId()) != null) { - mode = "CLOUDIFY"; - } else { - mode = "HEAT"; + mode = CLOUDIFY_MODE; + } else if (MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.get().getOrchestrator())) { + mode = MULTICLOUD_MODE; + } + else { + mode = HEAT_MODE; } } } @@ -77,15 +84,15 @@ public class VnfAdapterRestUtils MsoVnfAdapter vnfAdapter = null; // TODO: Make this more dynamic (e.g. Service Loader) - if ("CLOUDIFY".equalsIgnoreCase(mode)) { + if (CLOUDIFY_MODE.equalsIgnoreCase(mode)) { LOGGER.debug ("GetVnfAdapterImpl: Return Cloudify Adapter"); vnfAdapter = cloudifyImpl; } - else if ("HEAT".equalsIgnoreCase(mode)) { + else if (HEAT_MODE.equalsIgnoreCase(mode)) { LOGGER.debug ("GetVnfAdapterImpl: Return Heat Adapter"); vnfAdapter = vnfImpl; } - else if ("MULTICLOUD".equalsIgnoreCase(mode)) { + else if (MULTICLOUD_MODE.equalsIgnoreCase(mode)) { LOGGER.debug ("GetVnfAdapterImpl: Return Plugin (multicloud) Adapter"); vnfAdapter = vnfPluginImpl; } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java index a2f57ef06f..9ead28b577 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java @@ -77,7 +77,10 @@ public class BaseRestTestUtils { private int port; public ObjectMapper mapper; - + + public String orchestrator = "orchestrator"; + public String cloudEndpoint = "/v2.0"; + protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ ObjectMapper mapper = new ObjectMapper(); @@ -111,7 +114,6 @@ public class BaseRestTestUtils { public void setUp() throws Exception { reset(); mapper = new ObjectMapper(); - CloudIdentity identity = new CloudIdentity(); identity.setId("MTN13"); identity.setMsoId("m93945"); @@ -119,7 +121,8 @@ public class BaseRestTestUtils { identity.setAdminTenant("admin"); identity.setMemberRole("admin"); identity.setTenantMetadata(new Boolean(true)); - identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0"); + identity.setIdentityUrl("http://localhost:" + wireMockPort + cloudEndpoint); + identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD); CloudSite cloudSite = new CloudSite(); @@ -127,12 +130,10 @@ public class BaseRestTestUtils { cloudSite.setCloudVersion("3.0"); cloudSite.setClli("MDT13"); cloudSite.setRegionId("mtn13"); - cloudSite.setOrchestrator("orchestrator" + - ""); + cloudSite.setOrchestrator(orchestrator); identity.setIdentityServerType(ServerType.KEYSTONE); cloudSite.setIdentityService(identity); - stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) @@ -145,8 +146,7 @@ public class BaseRestTestUtils { .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); - cloudConfig.getCloudSite("MTN13").get().getIdentityService().setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - + cloudConfig.getCloudSite("MTN13").get().getIdentityService().setIdentityUrl("http://localhost:" + wireMockPort + cloudEndpoint); } protected static String getBody(String body, int port, String urlPath) throws IOException { 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 new file mode 100644 index 0000000000..07fa47df42 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.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.adapters.vnf; + +import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication; +import org.onap.so.adapters.vnf.exceptions.VnfException; +import org.onap.so.cloud.CloudConfig; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.entity.MsoRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; + +import javax.xml.ws.Holder; +import java.util.HashMap; +import java.util.Map; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +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.urlMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; + +public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Autowired + private MsoVnfPluginAdapterImpl instance; + + @Autowired + private CloudConfig cloudConfig; + + @Before + public void before() throws Exception { + super.orchestrator = "multicloud"; + super.cloudEndpoint = "/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload"; + super.setUp(); + } + + @Test + 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("generic_vnf_id", "genVNFID"); + stackInputs.put("vf_module_id", "vfMODULEID"); + + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse() + //.withHeader() + .withStatus(HttpStatus.SC_NOT_FOUND))); + + stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse() + .withStatus(HttpStatus.SC_NOT_FOUND))); + + stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse() + .withBodyFile("MulticloudResponse_Stack_Create.json") + .withStatus(HttpStatus.SC_CREATED))); + + instance.createVfModule("MTN13", "123", "vf", "v1", "vfname", "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); + } + + @Test + public void deleteVfModule() throws Exception { + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse() + .withBodyFile("MulticloudResponse_Stack.json") + .withStatus(HttpStatus.SC_OK))); + + stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse() + .withStatus(HttpStatus.SC_NO_CONTENT))); + + instance.deleteVfModule("MTN13", "123", "workload-id", msoRequest, new Holder<>()); + } + + @Test + public void queryVfModule() throws Exception { + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse() + .withBodyFile("MulticloudResponse_Stack.json") + .withStatus(HttpStatus.SC_OK))); + + instance.queryVnf("MTN13", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(), new Holder<>(), new Holder<>()); + } + + // TODO Error Tests +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java index 77ef8d4776..936bce5b5c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java @@ -20,31 +20,15 @@ package org.onap.so.adapters.vnf; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.client.WireMock; import org.apache.http.HttpStatus; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.MockitoAnnotations; -import org.onap.so.adapters.vdu.CloudInfo; -import org.onap.so.adapters.vdu.VduInstance; -import org.onap.so.adapters.vdu.VduStateType; -import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.adapters.vnf.exceptions.VnfException; -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.entity.MsoRequest; -import org.onap.so.openstack.beans.HeatStatus; -import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.utils.MsoMulticloudUtils; import org.springframework.beans.factory.annotation.Autowired; -import javax.ws.rs.core.MediaType; import javax.xml.ws.Holder; import java.util.HashMap; import java.util.Map; @@ -52,15 +36,11 @@ import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.delete; import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.reset; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.mockito.Mockito.when; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessMulticloud; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse; public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { @@ -72,53 +52,6 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"; - /*** - * Before each test execution, updating IdentityUrl port value to the ramdom wireMockPort - * Since URL will be used as a rest call and required to be mocked in unit tests - */ - @Before - public void setUp() throws Exception { - reset(); - mapper = new ObjectMapper(); - - CloudIdentity identity = new CloudIdentity(); - identity.setId("MTN13"); - identity.setMsoId("m93945"); - identity.setMsoPass("93937EA01B94A10A49279D4572B48369"); - identity.setAdminTenant("admin"); - identity.setMemberRole("admin"); - identity.setTenantMetadata(new Boolean(true)); - identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0"); - identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD); - - CloudSite cloudSite = new CloudSite(); - cloudSite.setId("MTN13"); - cloudSite.setCloudVersion("3.0"); - cloudSite.setClli("MDT13"); - cloudSite.setRegionId("MTN13"); - cloudSite.setOrchestrator("multicloud" + - ""); - identity.setIdentityServerType(ServerType.KEYSTONE); - cloudSite.setIdentityService(identity); - - - - stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() - .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) - .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withStatus(HttpStatus.SC_OK))); - stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse() - .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) - .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) - .withStatus(HttpStatus.SC_OK))); - stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse() - .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) - .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) - .withStatus(HttpStatus.SC_OK))); - cloudConfig.getCloudSite("MTN13").get().getIdentityService().setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - - } - @Test public void createVfModule_ModelCustUuidIsNull() throws Exception { expectedException.expect(VnfException.class); @@ -155,7 +88,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { new Holder<VnfRollback>()); } - /* @Test + @Test public void createVfModule_INSTANTIATED() throws Exception { mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackVfModule_200(); @@ -167,40 +100,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - }*/ - - @Test - public void createVfModule_INSTANTIATED_Multicloud() throws Exception { - mockOpenStackResponseAccessMulticloud(wireMockPort); - mockOpenStackGetStackVfModule_200(); - - MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", - null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, - Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(), - new Holder<VnfRollback>()); - } - - /* - @Test - public void createVfModule_Multicloud() throws Exception { - expectedException.expect(VnfException.class); - mockOpenStackResponseAccessMulticloud(wireMockPort); - mockOpenStackGetStackVfModule_404(); - - MsoRequest msoRequest = getMsoRequest(); - Map<String, String> map = new HashMap<>(); - map.put("key1", "value1"); - map.put("oof_directives", "{ abc: 123 }"); - map.put("sdnc_directives", "{ def: 456 }"); - msoVnfPluginAdapter.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", - null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, - Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(), - new Holder<VnfRollback>()); } - */ @Test public void createVfModule_queryVduNotFoundWithVolumeGroupId() throws Exception { diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack.json b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack.json new file mode 100644 index 0000000000..068cb83a33 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack.json @@ -0,0 +1,5 @@ +{ + "template_type":"heat", + "workload_id": "vfname", + "workload_status":"STATUS" + }
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create.json b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create.json new file mode 100644 index 0000000000..b6092bfbe0 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create.json @@ -0,0 +1,16 @@ +{ + "template_type": "heat", + "workload_id": "workload-id", + "template_response": + { + "stack": { + "id": "abcdef00-1234-abcd-5678-ef9123456789", + "links": [ + { + "href": "http://localhost:1234/v1/id12345678/stacks/workload-id/abcdef00-1234-abcd-5678-ef9123456789", + "rel": "self" + } + ] + } + } +} diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql index 960f483e46..0103564b5b 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/data.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql @@ -144,7 +144,7 @@ VALUES ('97b73b0f-2860-49e5-b9c5-b6f91e4ee4a8', 'fsb_volume_image_name_0', b'1', VALUES ('207fe0dc-4c89-4e5d-9a78-345e99ef7fbe', '547e9ac6-0489-41b6-8289-a7705f6e5c9d', '1', 'TestVnfType::TestModule-0', NULL, 1, 'd187c228-71c6-4c6d-8f33-cd1243442d0a', '97b73b0f-2860-49e5-b9c5-b6f91e4ee4a8', '2018-05-13 12:12:09', 'c5efeb55-4ade-49b8-815c-6a6391f6c46b'); INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('f4a21b58-5654-4cf6-9c50-de42004fe2b4', 'base_vmme.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n Internal1_allow_transit: "True"\n Internal1_dhcp: "False"\n Internal1_forwarding_mode: "l2"\n Internal1_net_cidr: "169.253.0.0"\n Internal1_net_cidr_len: "17"\n Internal1_net_gateway: "169.253.0.3"\n Internal1_rpf: "disable"\n Internal1_shared: "False"\n Internal2_allow_transit: "True"\n Internal2_dhcp: "False"\n Internal2_forwarding_mode: "l2"\n Internal2_net_cidr: "169.255.0.0"\n Internal2_net_cidr_len: "17"\n Internal2_net_gateway: "169.255.0.3"\n Internal2_rpf: "disable"\n Internal2_shared: "False"\n domain_name: "default-domain"\n fsb1_Internal1_mac: "00:80:37:0E:0B:12"\n fsb1_Internal2_mac: "00:80:37:0E:0B:12"\n fsb2_Internal1_mac: "00:80:37:0E:0D:12"\n fsb2_Internal2_mac: "00:80:37:0E:0D:12"\n fsb_flavor_name: "nv.c20r64d1"\n gtp_sec_group_name: "gtp-sec-group"\n int1_sec_group_name: "int1-sec-group"\n int2_sec_group_name: "int2-sec-group"\n ncb1_Internal1_mac: "00:80:37:0E:09:12"\n ncb1_Internal2_mac: "00:80:37:0E:09:12"\n ncb2_Internal1_mac: "00:80:37:0E:0F:12"\n ncb2_Internal2_mac: "00:80:37:0E:0F:12"\n ncb_flavor_name: "nv.c20r64d1"\n oam_sec_group_name: "oam-sec-group"\n pxe_image_name: "MME_PXE-Boot_16ACP04_GA.qcow2"\n sctp-a-IPv6_ethertype: "IPv6"\n sctp-a-display_name: "epc-sctp-a-ipv4v6-sec-group"\n sctp-a-dst_subnet_prefix_v6: "::"\n sctp-a-egress-dst_end_port: 65535\n sctp-a-egress-dst_start_port: 0\n sctp-a-egress-src_end_port: 65535\n sctp-a-egress-src_start_port: 0\n sctp-a-egress_action: "pass"\n sctp-a-egress_dst_subnet_prefix: "0.0.0.0"\n sctp-a-egress_dst_subnet_prefix_len: 0\n sctp-a-egress_ethertype: "IPv4"\n sctp-a-egress_rule_application: "any"\n sctp-a-egress_rule_protocol: "icmp"\n sctp-a-egress_src_addresses: "local"\n sctp-a-ingress-dst_end_port: 65535\n sctp-a-ingress-dst_start_port: 0\n sctp-a-ingress-src_end_port: 65535\n sctp-a-ingress-src_start_port: 0\n sctp-a-ingress-src_subnet_prefix: "0.0.0.0"\n sctp-a-ingress-src_subnet_prefix_len: 0\n sctp-a-ingress_action: "pass"\n sctp-a-ingress_dst_addresses: "local"\n sctp-a-ingress_ethertype: "IPv4"\n sctp-a-ingress_rule_application: "any"\n sctp-a-ingress_rule_protocol: "icmp"\n sctp-a-ipv6-egress-dst_start_port: "0"\n sctp-a-ipv6-egress_action: "pass"\n sctp-a-ipv6-egress_dst_end_port: "65535"\n sctp-a-ipv6-egress_dst_subnet_prefix: "0.0.0.0"\n sctp-a-ipv6-egress_dst_subnet_prefix_len: "0"\n sctp-a-ipv6-egress_ethertype: "IPv4"\n sctp-a-ipv6-egress_rule_application: "any"\n sctp-a-ipv6-egress_rule_protocol: "any"\n sctp-a-ipv6-egress_src_addresses: "local"\n sctp-a-ipv6-egress_src_end_port: "65535"\n sctp-a-ipv6-egress_src_start_port: "0"\n sctp-a-ipv6-ingress-dst_end_port: "65535"\n sctp-a-ipv6-ingress-dst_start_port: "0"\n sctp-a-ipv6-ingress-src_end_port: 65535\n sctp-a-ipv6-ingress-src_start_port: 0\n sctp-a-ipv6-ingress_action: "pass"\n sctp-a-ipv6-ingress_dst_addresses: "local"\n sctp-a-ipv6-ingress_ethertype: "IPv4"\n sctp-a-ipv6-ingress_rule_application: "any"\n sctp-a-ipv6-ingress_rule_protocol: "any"\n sctp-a-ipv6-ingress_src_subnet_prefix: "0.0.0.0"\n sctp-a-ipv6-ingress_src_subnet_prefix_len: "0"\n sctp-a-name: "epc-sctp-a-ipv4v6-sec-group"\n sctp-a-src_subnet_prefix_v6: "::"\n sctp-b-IPv6_ethertype: "IPv6"\n sctp-b-display_name: "epc-sctp-b-ipv4v6-sec-group"\n sctp-b-dst_subnet_prefix_v6: "::"\n sctp-b-egress-dst_end_port: 65535\n sctp-b-egress-dst_start_port: 0\n sctp-b-egress-src_end_port: 65535\n sctp-b-egress-src_start_port: 0\n sctp-b-egress_action: "pass"\n sctp-b-egress_dst_subnet_prefix: "0.0.0.0"\n sctp-b-egress_dst_subnet_prefix_len: 0\n sctp-b-egress_ethertype: "IPv4"\n sctp-b-egress_rule_application: "any"\n sctp-b-egress_rule_protocol: "icmp"\n sctp-b-egress_src_addresses: "local"\n sctp-b-ingress-dst_end_port: 65535\n sctp-b-ingress-dst_start_port: 0\n sctp-b-ingress-src_end_port: 65535\n sctp-b-ingress-src_start_port: 0\n sctp-b-ingress-src_subnet_prefix: "0.0.0.0"\n sctp-b-ingress-src_subnet_prefix_len: 0\n sctp-b-ingress_action: "pass"\n sctp-b-ingress_dst_addresses: "local"\n sctp-b-ingress_ethertype: "IPv4"\n sctp-b-ingress_rule_application: "any"\n sctp-b-ingress_rule_protocol: "icmp"\n sctp-b-ipv6-egress-dst_start_port: "0"\n sctp-b-ipv6-egress_action: "pass"\n sctp-b-ipv6-egress_dst_end_port: "65535"\n sctp-b-ipv6-egress_dst_subnet_prefix: "0.0.0.0"\n sctp-b-ipv6-egress_dst_subnet_prefix_len: "0"\n sctp-b-ipv6-egress_ethertype: "IPv4"\n sctp-b-ipv6-egress_rule_application: "any"\n sctp-b-ipv6-egress_rule_protocol: "any"\n sctp-b-ipv6-egress_src_addresses: "local"\n sctp-b-ipv6-egress_src_end_port: "65535"\n sctp-b-ipv6-egress_src_start_port: "0"\n sctp-b-ipv6-ingress-dst_end_port: "65535"\n sctp-b-ipv6-ingress-dst_start_port: "0"\n sctp-b-ipv6-ingress-src_end_port: 65535\n sctp-b-ipv6-ingress-src_start_port: 0\n sctp-b-ipv6-ingress_action: "pass"\n sctp-b-ipv6-ingress_dst_addresses: "local"\n sctp-b-ipv6-ingress_ethertype: "IPv4"\n sctp-b-ipv6-ingress_rule_application: "any"\n sctp-b-ipv6-ingress_rule_protocol: "any"\n sctp-b-ipv6-ingress_src_subnet_prefix: "0.0.0.0"\n sctp-b-ipv6-ingress_src_subnet_prefix_len: "0"\n sctp-b-name: "epc-sctp-b-ipv4v6-sec-group"\n sctp-b-src_subnet_prefix_v6: "::"\n sctp_rule_protocol: "132"\n vlc_st_availability_zone: "True"\n vlc_st_interface_type_gtp: "other0"\n vlc_st_interface_type_int1: "other1"\n vlc_st_interface_type_int2: "other2"\n vlc_st_interface_type_oam: "management"\n vlc_st_interface_type_sctp_a: "left"\n vlc_st_interface_type_sctp_b: "right"\n vlc_st_service_mode: "in-network-nat"\n vlc_st_service_type: "firewall"\n vlc_st_version: "2"\n vlc_st_virtualization_type: "virtual-machine"\n availability_zone_0: \n availability_zone_1: \n availability_zone_2: \n availability_zone_3: \n fsb_name_0: \n fsb_name_1: \n fsb_oam_ip_0: \n fsb_oam_ip_1: \n fsb_volume_id_0: \n fsb_volume_id_1: \n gtp_net_fqdn: \n gtp_net_name: \n ncb_name_0: \n ncb_name_1: \n oam_net_fqdn: \n oam_net_name: \n sctp_a_net_fqdn: \n sctp_a_net_name: \n sctp_b_net_fqdn: \n sctp_b_net_name: \n vf_module_id: \n vlc_gtp_route_prefixes: \n vlc_oam_route_prefixes: \n vlc_sctp_a_route_prefixes: \n vlc_sctp_b_route_prefixes: \n vnf_id: \n vnf_name: \n', 'MGJjYzM2ZWY1ODBjYzc1MzBiMGQxZmI4N2MyZmFkY2E=', '2018-05-13 12:12:09'); -INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('3375f64b-4709-4802-8713-7a164763f9cd', 'base_vDB_11032016_volume.env', '1', 'Auto-generated HEAT Environment deployment artifact', '#_______________________________________________________________________________________________________________________________________\n #| AT&T Proprietary (Restricted) |\n #| Only for use by authorized individuals or any above-designated team(s) |\n #| within the AT&T companies and not for general distribution |\n #|_______________________________________________________________________________________________________________________________________|\nparameters:\n oam_volume_size: "10"\n prx_volume_size: "10"\n rdn_volume_size: "10"\n#_______________________________________________________________________________________________________________________________________\n #| AT&T Proprietary (Restricted) |\n #| Only for use by authorized individuals or any above-designated team(s) |\n #| within the AT&T companies and not for general distribution |\n #|_______________________________________________________________________________________________________________________________________|\n', 'NGE2YTZjM2YzZDkyNWEzNTljMjQwYzkyNTIyMDU3ZDQ=', '2017-01-26 16:01:40'); +INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('3375f64b-4709-4802-8713-7a164763f9cd', 'base_vDB_11032016_volume.env', '1', 'Auto-generated HEAT Environment deployment artifact', '#', 'NGE2YTZjM2YzZDkyNWEzNTljMjQwYzkyNTIyMDU3ZDQ=', '2017-01-26 16:01:40'); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index f1269f412b..7c037e4885 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -7,9 +7,9 @@ * 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. @@ -26,6 +26,9 @@ import org.junit.runner.RunWith; import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; +import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; +import org.onap.so.db.request.beans.RequestProcessingData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; @@ -41,6 +44,8 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertFalse; @RunWith(SpringRunner.class) @SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -90,6 +95,7 @@ public class RequestsDbClientTest { assertThat(request, sameBeanAs(response).ignoring("operateAt").ignoring("finishedAt")); } + private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) { assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log")); } @@ -189,4 +195,37 @@ public class RequestsDbClientTest { assertNull(requestsDbClient.getOneByServiceIdAndOperationId(UUID.randomUUID().toString(),operationStatus.getOperationId())); } + + + @Test + public void getRequestProcessingDataBySoRequestIdTest(){ + List<RequestProcessingData> requestProcessingDataList = requestsDbClient + .getRequestProcessingDataBySoRequestId("00032ab7-na18-42e5-965d-8ea592502018"); + assertNotNull(requestProcessingDataList); + assertFalse(requestProcessingDataList.isEmpty()); + assertEquals(2,requestProcessingDataList.size()); + } + + @Test + public void findOneByOperationalEnvIdAndServiceModelVersionIdTest(){ + OperationalEnvServiceModelStatus operationalEnvServiceModelStatus =requestsDbClient.findOneByOperationalEnvIdAndServiceModelVersionId("1234","TEST1234"); + assertNotNull(operationalEnvServiceModelStatus); + assertEquals("1234",operationalEnvServiceModelStatus.getOperationalEnvId()); + assertEquals("TEST1234",operationalEnvServiceModelStatus.getServiceModelVersionId()); + } + + @Test + public void getAllByOperationalEnvIdAndRequestId(){ + List<OperationalEnvServiceModelStatus> operationalEnvServiceModelStatuses =requestsDbClient.getAllByOperationalEnvIdAndRequestId("1234","00032ab7-3fb3-42e5-965d-8ea592502017"); + assertNotNull(operationalEnvServiceModelStatuses); + assertFalse(operationalEnvServiceModelStatuses.isEmpty()); + assertEquals(2,operationalEnvServiceModelStatuses.size()); + } + + @Test + public void getDistributionStatusByIdTest(){ + OperationalEnvDistributionStatus operationalEnvDistributionStatus =requestsDbClient.getDistributionStatusById("111"); + assertNotNull(operationalEnvDistributionStatus); + assertEquals("111",operationalEnvDistributionStatus.getDistributionId()); + } } diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql index ae5f5e9124..fcfd1483da 100644 --- a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -36,3 +36,14 @@ VALUES (1, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca714', 'requestAction', 'assign', 'pincFabricConfigRequest'), (2, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca715', 'configurationId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfigRequest'), (3, '5ffbabd6-b793-4377-a1ab-082670fbc7ac', '5ffbabd6-b793-4377-a1ab-082670fbc7ac', 'configId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfig'); + +INSERT INTO activate_operational_env_service_model_distribution_status (OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID,SERVICE_MOD_VER_FINAL_DISTR_STATUS,RECOVERY_ACTION,RETRY_COUNT_LEFT,WORKLOAD_CONTEXT, CREATE_TIME, MODIFY_TIME) +VALUES +('1234', 'TEST1234', '00032ab7-3fb3-42e5-965d-8ea592502017', "Test", "Test", 1, 'DEFAULT', '2018-08-14 16:50:59', '2018-08-14 16:50:59'); +INSERT INTO activate_operational_env_service_model_distribution_status (OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID,SERVICE_MOD_VER_FINAL_DISTR_STATUS,RECOVERY_ACTION,RETRY_COUNT_LEFT,WORKLOAD_CONTEXT, CREATE_TIME, MODIFY_TIME) +VALUES +('1234', 'TEST1235', '00032ab7-3fb3-42e5-965d-8ea592502017', "Test", "Test", 2, 'DEFAULT', '2018-08-14 16:50:59', '2018-08-14 16:50:59'); + +INSERT INTO `activate_operational_env_per_distributionid_status` (`DISTRIBUTION_ID`, `DISTRIBUTION_ID_STATUS`, `DISTRIBUTION_ID_ERROR_REASON`, `CREATE_TIME`, `MODIFY_TIME`, `OPERATIONAL_ENV_ID`, `SERVICE_MODEL_VERSION_ID`, `REQUEST_ID`) +VALUES +('111', 'TEST', 'ERROR', '2018-09-12 19:29:24', '2018-09-12 19:29:25', '1234', 'TEST1234', '00032ab7-3fb3-42e5-965d-8ea592502017');
\ No newline at end of file diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index b5cb596ea0..9ea397701c 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -196,12 +196,12 @@ <dependency> <groupId>org.onap.sdc.sdc-tosca</groupId> <artifactId>sdc-tosca</artifactId> - <version>1.4.1</version> + <version>1.4.4</version> </dependency> <dependency> <groupId>org.onap.sdc.jtosca</groupId> <artifactId>jtosca</artifactId> - <version>1.4.1</version> + <version>1.4.4</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 7ead6cbb7f..91505918a8 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -26,7 +26,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.util.ArrayList; import java.util.List; import org.onap.sdc.api.IDistributionClient; @@ -46,7 +45,6 @@ import org.onap.so.asdc.client.exceptions.ASDCParametersException; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.IVfResourceInstaller; import org.onap.so.asdc.installer.ToscaResourceStructure; -import org.onap.so.asdc.installer.VfModuleStructure; import org.onap.so.asdc.installer.VfResourceStructure; import org.onap.so.asdc.installer.bpmn.BpmnInstaller; import org.onap.so.asdc.installer.heat.ToscaResourceInstaller; @@ -596,7 +594,7 @@ public class ASDCController { distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID()); Thread.sleep(watchDogTimeout / 10); }catch(Exception e){ - LOGGER.debug ("Exception in Watchdog Loop " + e.getMessage()); + LOGGER.debug ("Exception in Watchdog Loop " + e); Thread.sleep(watchDogTimeout / 10); } @@ -628,7 +626,7 @@ public class ASDCController { LOGGER.debug ("A&AI Updated succefully with Distribution Status!"); } catch(Exception e) { - LOGGER.debug ("Exception in Watchdog executePatchAAI(): " + e.getMessage()); + LOGGER.debug ("Exception in Watchdog executePatchAAI(): " + e); watchdogError = "Error calling A&AI " + e.getMessage(); if(e.getCause() != null) { LOGGER.debug ("Exception caused by: " + e.getCause().getMessage()); @@ -660,7 +658,7 @@ public class ASDCController { LOGGER.debug ("A&AI Updated succefully with Distribution Status of " + DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name()); } catch(Exception aaiException) { - LOGGER.debug ("Exception in executePatchAAI(): " + aaiException.getMessage()); + LOGGER.debug ("Exception in executePatchAAI(): " + aaiException); if(aaiException.getCause() != null) { LOGGER.debug ("Exception caused by: " + aaiException.getCause().getMessage()); } @@ -708,6 +706,7 @@ public class ASDCController { } catch(ArtifactInstallerException e){ deploySuccessful = false; errorMessage = e.getMessage(); + LOGGER.debug ("Exception in processResourceNotification(): " + e); } } else { // Services with resources @@ -744,6 +743,7 @@ public class ASDCController { } catch(ArtifactInstallerException e){ deploySuccessful = false; errorMessage = e.getMessage(); + LOGGER.debug ("Exception in processResourceNotification(): " + e); } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 970cb0bf50..f77a48a1f8 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -488,21 +488,24 @@ public class ToscaResourceInstaller { .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - logger.debug("Comparing VFModuleMetadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); + logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream() .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) - .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())). - findFirst(); + .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())) + .findFirst(); if(matchingObject.isPresent()){ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet); vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); }else - throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID()); + throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID()); } service.getVnfCustomizations().add(vnfResource); + } else{ + logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + + "Tosca VF Customization UUID: " + vfCustomizationUUID); } } } @@ -1150,7 +1153,7 @@ public class ToscaResourceInstaller { vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); - vfcInstanceGroup.setToscaNodeType(group.getType()); + vfcInstanceGroup.setToscaNodeType(group.getType()); vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type @@ -1201,7 +1204,7 @@ public class ToscaResourceInstaller { if(vfModule==null) vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata); - vfModuleCustomization = createVfModuleCustomzation(group, toscaResourceStructure, vfModule, vfModuleData); + vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData); setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, vfMetadata); vfModuleCustomization.setVfModule(vfModule); @@ -1416,7 +1419,7 @@ public class ToscaResourceInstaller { return vfModule; } - protected VfModuleCustomization createVfModuleCustomzation(Group group, + protected VfModuleCustomization createVfModuleCustomization(Group group, ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) { VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); @@ -1691,6 +1694,8 @@ public class ToscaResourceInstaller { testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); vnfResource.setAicVersionMin( testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES))); + vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)); + vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)); return vnfResource; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index ab9c359b7f..9df9ffc7af 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -203,11 +203,11 @@ public class ASDCNotificationLogging { List<NodeTemplate> vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList(); for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) { - + + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VNF Properties:"); - buffer.append(System.lineSeparator()); - + buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); @@ -262,6 +262,7 @@ public class ASDCNotificationLogging { for (Group group : groupList) { Metadata instanceMetadata = group.getMetadata(); + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VNFC Instance Group Properties:"); buffer.append(System.lineSeparator()); @@ -277,18 +278,19 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); - buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); } } - + List<Group> vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))); for(Group group : vfGroups){ Metadata vfMetadata = group.getMetadata(); + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VF Module Properties:"); buffer.append(System.lineSeparator()); @@ -306,13 +308,14 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Description:"); buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); - buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); } List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC); for(NodeTemplate cvfcTemplate : cvfcList) { + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("CVNFC Properties:"); buffer.append(System.lineSeparator()); @@ -339,6 +342,7 @@ public class ASDCNotificationLogging { List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); for(NodeTemplate vfcTemplate : vfcList) { + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("VNFC Properties:"); buffer.append(System.lineSeparator()); @@ -370,13 +374,13 @@ public class ASDCNotificationLogging { List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList(); if(nodeTemplatesVLList != null){ - - buffer.append(System.lineSeparator()); - buffer.append("NETWORK Level Properties:"); - buffer.append(System.lineSeparator()); - + for(NodeTemplate vlNode : nodeTemplatesVLList){ + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + buffer.append("NETWORK Level Properties:"); + buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); buffer.append(System.lineSeparator()); @@ -414,6 +418,7 @@ public class ASDCNotificationLogging { if (networkCollectionList != null) { for (NodeTemplate crNode : networkCollectionList) { + buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); buffer.append(System.lineSeparator()); @@ -448,6 +453,7 @@ public class ASDCNotificationLogging { Metadata vlMetadata = vlNodeTemplate.getMetaData(); + buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("Network CR VL Properties:"); buffer.append(System.lineSeparator()); @@ -481,7 +487,8 @@ public class ASDCNotificationLogging { if(groupList != null){ for (Group group : groupList) { Metadata instanceMetadata = group.getMetadata(); - buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); buffer.append("Network Instance Group Properties:"); buffer.append(System.lineSeparator()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java index 32f512b0f0..3418ee3295 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java @@ -50,6 +50,10 @@ public class YamlEditor { public YamlEditor (byte[] body) { init (body); } + + public YamlEditor (Yaml yaml) { + this.yaml = yaml; + } @SuppressWarnings("unchecked") protected synchronized void init (byte[] body) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 7a56ab88ab..70d523eab4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -42,7 +42,7 @@ public class ExecuteBuildingBlockRainyDay { @Autowired private CatalogDbClient catalogDbClient; - private static final String ASTERISK = "ASTERISK"; + private static final String ASTERISK = "*"; public void setRetryTimer(DelegateExecution execution) { try { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 2144f1c69a..0c2a95f5d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -53,6 +53,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { private GenericVnf vnf; private BuildingBlock buildingBlock; private ExecuteBuildingBlock executeBuildingBlock; + private static final String ASTERISK = "*"; @Before public void before() { @@ -99,7 +100,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setServiceType("st1"); rainyDayHandlerStatus.setVnfType("vnft1"); rainyDayHandlerStatus.setPolicy("Rollback"); - rainyDayHandlerStatus.setWorkStep("ASTERISK"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); @@ -115,15 +116,15 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); - rainyDayHandlerStatus.setErrorCode("ASTERISK"); + rainyDayHandlerStatus.setErrorCode(ASTERISK); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); - rainyDayHandlerStatus.setServiceType("ASTERISK"); - rainyDayHandlerStatus.setVnfType("ASTERISK"); + rainyDayHandlerStatus.setServiceType(ASTERISK); + rainyDayHandlerStatus.setVnfType(ASTERISK); rainyDayHandlerStatus.setPolicy("Rollback"); - rainyDayHandlerStatus.setWorkStep("ASTERISK"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); - doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "ASTERISK"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "ASTERISK", "ASTERISK", "ASTERISK", "ASTERISK"); + doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index c48d000ab3..f640aa74f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -22,17 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject import org.json.XML import org.onap.so.bpmn.common.recipe.ResourceInput import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.logger.MsoLogger -import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.logger.MsoLogger /** @@ -50,9 +48,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - MsoUtils msoUtils = new MsoUtils() - - public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started preProcessRequest *****") @@ -133,7 +128,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info("started prepareUpdateAfterActivateSDNCResource ") ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") @@ -191,7 +185,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info("Started prepareSDNCRequest ") try { @@ -409,7 +402,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void postActivateSDNCCall(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info("started postCreateSDNCCall ") String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") @@ -419,7 +411,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void sendSyncResponse(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") msoLogger.dubug(" *** sendSyncResponse *** ") try { @@ -431,10 +422,10 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + String msg = "Exception in sendSyncResponse:" + ex.getMessage() msoLogger.debug( msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.dubug(" ***** Exit sendSyncResopnse *****") + msoLogger.dubug(" ***** Exit sendSyncResponse *****") } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 5255b37bb0..7eeeff8546 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -20,32 +20,21 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject import org.json.XML -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiResponse; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.recipe.ResourceInput; -import org.onap.so.bpmn.common.resource.ResourceRequestBuilder -import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder +import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse -import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.common.scripts.AaiUtil - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.logger.MsoLogger +import static org.apache.commons.lang3.StringUtils.* /** * This groovy class supports the <class>CreateSDNCCNetworkResource.bpmn</class> process. @@ -60,11 +49,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() - MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started preProcessRequest *****") try { @@ -155,8 +141,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) - //TODO Here build networkrequest - } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -243,12 +227,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { /** * Pre Process the BPMN Flow Request - * Inclouds: + * Includes: * generate the nsOperationKey * generate the nsParameters */ public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") try { @@ -534,7 +517,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void afterCreateSDNCCall(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") @@ -581,7 +563,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") msoLogger.debug(" *** sendSyncResponse *** ") try { @@ -593,10 +574,10 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + String msg = "Exception in sendSyncResponse:" + ex.getMessage() msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.debug(" ***** Exit sendSyncResopnse *****") + msoLogger.debug(" ***** Exit sendSyncResponse *****") } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy index b6ea9f3fef..f13141751b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy @@ -22,17 +22,13 @@ package org.onap.so.bpmn.infrastructure.scripts import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.BpmnError -import org.json.JSONObject -import org.json.XML -import org.onap.so.logger.MsoLogger +import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.recipe.ResourceInput import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.logger.MsoLogger /** @@ -49,11 +45,8 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started preProcessRequest *****") try { @@ -125,8 +118,6 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) - //TODO Here build networkrequest - } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -137,7 +128,6 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor } public void prepareSDNCRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") try { @@ -383,7 +373,6 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor } public void postDeactivateSDNCCall(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") @@ -392,7 +381,6 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor } public void sendSyncResponse(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") msoLogger.debug(" *** sendSyncResponse *** ") try { @@ -404,11 +392,11 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + String msg = "Exception in sendSyncResponse:" + ex.getMessage() msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger("DEBUG"," ***** Exit sendSyncResopnse *****") + msoLogger.debug(" ***** Exit sendSyncResponse *****") } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index 192788a4ca..3519bd7484 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -20,24 +20,18 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.MsoLogger - -import static org.apache.commons.lang3.StringUtils.*; - import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.recipe.ResourceInput; -import org.onap.so.bpmn.common.resource.ResourceRequestBuilder -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +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.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.logger.MsoLogger -import groovy.json.* +import static org.apache.commons.lang3.StringUtils.* /** * This groovy class supports the <class>DeleteSDNCCNetworkResource.bpmn</class> process. @@ -54,10 +48,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started preProcessRequest *****") try { @@ -147,8 +138,6 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) - //TODO Here build networkrequest - } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -160,12 +149,11 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { /** * Pre Process the BPMN Flow Request - * Inclouds: + * Includes: * generate the nsOperationKey * generate the nsParameters */ public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") try { @@ -444,7 +432,6 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void postDeleteSDNCCall(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started prepareSDNCRequest *****") String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") @@ -454,7 +441,6 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") msoLogger.debug( " *** sendSyncResponse *** ") try { @@ -466,10 +452,10 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable("sentSyncResponse", true) } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + String msg = "Exception in sendSyncResponse:" + ex.getMessage() msoLogger.debug( msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.debug(" ***** Exit sendSyncResopnse *****") + msoLogger.debug(" ***** Exit sendSyncResponse *****") } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn index e3b5e7997e..fe2c8928d8 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn @@ -171,4 +171,4 @@ dcsi.prepareSDNCRequest(execution)</bpmn:script> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn index f975ffbcd6..3b1c56628e 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn @@ -4,7 +4,7 @@ <bpmn2:scriptTask id="sendSyncAckResponse_ScriptTask" name="Send Sync Ack Response" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.sendSyncResponse(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -16,7 +16,7 @@ CreateVcpeResCustService.sendSyncResponse(execution)]]></bpmn2:script> <bpmn2:scriptTask id="preProcessRequest_ScriptTask" name="PreProcess Incoming Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.preProcessRequest(execution) ]]></bpmn2:script> @@ -29,7 +29,7 @@ CreateVcpeResCustService.preProcessRequest(execution) <bpmn2:scriptTask id="postProcessAndCompletionRequest_ScriptTask" name="Post Process & Completion Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0afe2pg</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_29</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.postProcessResponse(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -72,7 +72,7 @@ execution.setVariable("CreateVcpeResCustServiceSuccessIndicator", true)]]></bpmn <bpmn2:scriptTask id="ScriptTask_1" name="Log / Print Unexpected Error" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* ExceptionUtil ex = new ExceptionUtil() ex.processJavaException(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -124,7 +124,7 @@ ex.processJavaException(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_0yk02h3" name="Prepare FalloutHandler" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0jg47xm</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0807ukc</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.prepareFalloutRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -176,14 +176,14 @@ CreateVcpeResCustService.prepareFalloutRequest(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_17doerz" name="Pre Process Rollback" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_02o4yqx</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0ftzjjm</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService= new CreateVcpeResCustService() CreateVcpeResCustService.preProcessRollback(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:scriptTask id="ScriptTask_0wyub4x" name="Post Process Rollback" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0dvsqpp</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1rabks0</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService= new CreateVcpeResCustService() CreateVcpeResCustService.postProcessRollback(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -332,7 +332,7 @@ CreateVcpeResCustService.postProcessRollback(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_0cdtchu" name="Prepare Decompose Service " scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1eu60rt</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_00h6hmd</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.prepareDecomposeService(execution)]]></bpmn2:script> </bpmn2:scriptTask> @@ -350,7 +350,7 @@ CreateVcpeResCustService.prepareDecomposeService(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_0lpv2da" name="PostProcess Decompose Service " scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_17g05fd</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_11efpvh</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.vcpe.scripts.* + <bpmn2:script><![CDATA[import org.onap.so.bpmn.vcpe.scripts.* def CreateVcpeResCustService = new CreateVcpeResCustService() CreateVcpeResCustService.processDecomposition(execution)]]></bpmn2:script> </bpmn2:scriptTask> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn index 09d8e35258..eaf37191d5 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn @@ -180,4 +180,4 @@ csi.sendSyncResponse(execution)</bpmn:script> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn index da17fee16e..80fcc1762e 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn @@ -296,4 +296,4 @@ dcsi.prepareUpdateAfterDeleteSDNCResource(execution)</bpmn:script> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index 39f4c7822a..5f263e8b4b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -7,9 +7,9 @@ * 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. @@ -73,7 +73,7 @@ public class SDNCAssignTasks { public void assignVnf(BuildingBlockExecution execution) { try { - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + GeneralBuildingBlock gBBInput = execution.getVariable("generalBuildingBlock"); RequestContext requestContext = gBBInput.getRequestContext(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); @@ -85,7 +85,7 @@ public class SDNCAssignTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - + public void assignVfModule(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); @@ -101,14 +101,14 @@ public class SDNCAssignTasks { } Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); + + String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); execution.setVariable("SDNCAssignResponse_"+ vfModule.getVfModuleId(), response); - } catch (Exception ex) { + } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - + /** * BPMN access method to perform Assign action on SDNC for L3Network * @param execution @@ -117,14 +117,14 @@ public class SDNCAssignTasks { public void assignNetwork(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - + Customer customer = gBBInput.getCustomer(); RequestContext requestContext = gBBInput.getRequestContext(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - + sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 9e4b01eea5..d3f817c2a5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -221,7 +221,7 @@ public class WorkflowActionBBTasks { } public void checkRetryStatus(DelegateExecution execution) { - if (execution.getVariable("handlingCode") == "Retry") { + if (execution.getVariable("handlingCode").equals("Retry")) { int currSequence = (int) execution.getVariable("gCurrentSequence"); currSequence--; execution.setVariable("gCurrentSequence", currSequence); @@ -239,8 +239,9 @@ public class WorkflowActionBBTasks { List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution .getVariable("flowsToExecute"); List<ExecuteBuildingBlock> rollbackFlows = new ArrayList(); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE) - 1; - for (int i = flowsToExecute.size() - 1; i >= 0; i--) { + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE) + 1; + int listSize = flowsToExecute.size(); + for (int i = listSize - 1; i >= 0; i--) { if (i >= currentSequence) { flowsToExecute.remove(i); } else { @@ -248,11 +249,13 @@ public class WorkflowActionBBTasks { BuildingBlock bb = flowsToExecute.get(i).getBuildingBlock(); String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName(); if (flowName.contains("Assign")) { - flowName = "Unassign" + flowName.substring(7, flowName.length()); + flowName = "Unassign" + flowName.substring(6, flowName.length()); } else if (flowName.contains("Create")) { flowName = "Delete" + flowName.substring(6, flowName.length()); } else if (flowName.contains("Activate")) { flowName = "Deactivate" + flowName.substring(8, flowName.length()); + }else{ + continue; } flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName); rollbackFlows.add(flowsToExecute.get(i)); @@ -262,7 +265,6 @@ public class WorkflowActionBBTasks { execution.setVariable("isRollbackNeeded", false); else execution.setVariable("isRollbackNeeded", true); - execution.setVariable("flowsToExecute", rollbackFlows); execution.setVariable("handlingCode", "PreformingRollback"); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index aefb84c606..ee1d432b6f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -26,21 +26,14 @@ import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; -import org.json.JSONObject; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.logging.jaxrs.filter.SpringClientFilter; -import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; @@ -99,24 +92,32 @@ public class SdnCommonTasks { * @return * @throws BadResponseException */ - public String validateSDNResponse(LinkedHashMap<?, ?> output) throws BadResponseException { - if (CollectionUtils.isEmpty(output)) { - msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, NO_RESPONSE_FROM_SDNC, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_SDNC); - throw new BadResponseException(NO_RESPONSE_FROM_SDNC); + public String validateSDNResponse(LinkedHashMap<?, ?> output) throws BadResponseException { + if (CollectionUtils.isEmpty(output)) { + msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, NO_RESPONSE_FROM_SDNC, "BPMN", + MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, NO_RESPONSE_FROM_SDNC); + throw new BadResponseException(NO_RESPONSE_FROM_SDNC); + } + LinkedHashMap<?, ?> embeddedResponse =(LinkedHashMap<?, ?>) output.get("output"); + String responseCode = ""; + String responseMessage = ""; + if (embeddedResponse != null) { + responseCode = (String) embeddedResponse.get(RESPONSE_CODE); + responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE); } - String responseCode = (String) output.get(RESPONSE_CODE); - String responseMessage = (String) output.get(RESPONSE_MESSAGE); - msoLogger.info("ResponseCode: " + responseCode + " ResponseMessage: " + responseMessage); - int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0; - if (isHttpCodeSuccess(code)) { - msoLogger.info("Successful Response from SDNC"); - return responseMessage; - } else { - String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); - msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, errorMessage); - throw new BadResponseException(errorMessage); - } - } + + msoLogger.info("ResponseCode: " + responseCode + " ResponseMessage: " + responseMessage); + int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0; + if (isHttpCodeSuccess(code)) { + msoLogger.info("Successful Response from SDNC"); + return responseMessage; + } else { + String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); + msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, errorMessage, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError, errorMessage); + throw new BadResponseException(errorMessage); + } + } /*** * diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index fb9533091b..b5bb0bed94 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -7,9 +7,9 @@ * 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. @@ -58,6 +58,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; @@ -88,20 +89,20 @@ public class TestDataSetup{ private int volumeGroupCounter; private int vpnBindingCounter; private int vpnBondingLinkCounter; - + protected BuildingBlockExecution execution; - + protected GeneralBuildingBlock gBBInput; - + protected HashMap<ResourceKey, String> lookupKeyMap; - + protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB(); - + @Rule public ExpectedException expectedException = ExpectedException.none(); - + protected DelegateExecution delegateExecution; - + @Before public void buildingBlockTestDataSetupBefore() { collectionCounter = 0; @@ -120,183 +121,183 @@ public class TestDataSetup{ volumeGroupCounter = 0; vpnBindingCounter = 0; vpnBondingLinkCounter = 0; - + execution = new DelegateExecutionImpl(new ExecutionImpl()); execution.setVariable("testProcessKey", "testProcessKeyValue"); - + gBBInput = new GeneralBuildingBlock(); execution.setVariable("gBBInput", gBBInput); - + lookupKeyMap = new HashMap<ResourceKey, String>(); execution.setVariable("lookupKeyMap", lookupKeyMap); - + ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class); doReturn("test").when(mockExecutionImpl).getProcessInstanceId(); - + ExecutionImpl executionImpl = new ExecutionImpl(); executionImpl.setProcessInstance(mockExecutionImpl); - + delegateExecution = (DelegateExecution) executionImpl; delegateExecution.setVariable("testProcessKey", "testProcessKeyValue"); } - + public Map<String, String> buildUserInput() { Map<String, String> userInput = new HashMap<>(); userInput.put("testUserInputKey", "testUserInputValue"); - + return userInput; } - + public Map<String, String> setUserInput() { Map<String, String> userInput = buildUserInput(); - + gBBInput.setUserInput(userInput); - + return userInput; } - + public RequestContext buildRequestContext() { RequestContext requestContext = new RequestContext(); requestContext.setMsoRequestId(UUID.randomUUID().toString()); requestContext.setProductFamilyId("testProductFamilyId"); requestContext.setRequestorId("testRequestorId"); - + requestContext.setUserParams(new HashMap<>()); - + Map<String,Object> dataMap = new HashMap<>(); dataMap.put("vpnId","testVpnId"); dataMap.put("vpnRegion","testVpnRegion"); dataMap.put("vpnRt","testVpnRt"); dataMap.put("vpnName","vpnName"); dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"})); - + HashMap<String,Object> userParams = new HashMap<>(); userParams.put("vpnData",dataMap); - + List<Map<String,Object>> userParamsList = new ArrayList<>(); userParamsList.add(userParams); - + RequestParameters requestParameters = new RequestParameters(); requestParameters.setUserParams(userParamsList); requestContext.setRequestParameters(requestParameters); - + return requestContext; } - + public RequestContext setRequestContext() { RequestContext requestContext = buildRequestContext(); - + gBBInput.setRequestContext(requestContext); - + return requestContext; } - + public CloudRegion buildCloudRegion() { CloudRegion cloudRegion = new CloudRegion(); cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId"); cloudRegion.setTenantId("testTenantId"); cloudRegion.setCloudOwner("testCloudOwner"); - + return cloudRegion; } - + public CloudRegion setCloudRegion() { CloudRegion cloudRegion = buildCloudRegion(); - + gBBInput.setCloudRegion(cloudRegion); - + return cloudRegion; } - + public OrchestrationContext buildOrchestrationContext() { OrchestrationContext orchestrationContext = new OrchestrationContext(); - + return orchestrationContext; } - + public OrchestrationContext setOrchestrationContext() { OrchestrationContext orchestrationContext = buildOrchestrationContext(); - + gBBInput.setOrchContext(orchestrationContext); - + return orchestrationContext; } - + public Collection buildCollection() { collectionCounter++; - + Collection collection = new Collection(); collection.setId("testId" + collectionCounter); collection.setInstanceGroup(buildInstanceGroup()); - + return collection; } - + public Configuration buildConfiguration() { configurationCounter++; - + Configuration configuration = new Configuration(); configuration.setConfigurationId("testConfigurationId" + configurationCounter); configuration.setConfigurationName("testConfigurationName" + configurationCounter); - + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter); modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter); modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter); - + configuration.setModelInfoConfiguration(modelInfoConfiguration); - + return configuration; } - + public OwningEntity buildOwningEntity() { owningEntityCounter++; - + OwningEntity owningEntity = new OwningEntity(); owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter); owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter); - + return owningEntity; } - + public Project buildProject() { projectCounter++; - + Project project = new Project(); project.setProjectName("testProjectName" + projectCounter); - + return project; } - + public ServiceSubscription buildServiceSubscription() { serviceSubscriptionCounter++; - + ServiceSubscription serviceSubscription = new ServiceSubscription(); serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter); serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter); - + return serviceSubscription; } - + public Customer buildCustomer() { customerCounter++; - + Customer customer = new Customer(); customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter); customer.setSubscriberType("testSubscriberType" + customerCounter); customer.setServiceSubscription(buildServiceSubscription()); - + return customer; } - + public ServiceInstance buildServiceInstance() { serviceInstanceCounter++; - + ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter); serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter); - + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter); modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter); @@ -304,30 +305,30 @@ public class TestDataSetup{ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter); modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter); serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - + serviceInstance.setProject(buildProject()); - + serviceInstance.setOwningEntity(buildOwningEntity()); - + serviceInstance.setCollection(buildCollection()); - + serviceInstance.getConfigurations().add(buildConfiguration()); - + return serviceInstance; } - + public ServiceInstance setServiceInstance() { ServiceInstance serviceInstance = buildServiceInstance(); - + if(gBBInput.getCustomer() == null) { gBBInput.setCustomer(buildCustomer()); } gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance); lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId()); - + return serviceInstance; } - + public Customer setCustomer() { if(gBBInput.getCustomer() != null) return gBBInput.getCustomer(); Customer customer = new Customer(); @@ -337,64 +338,64 @@ public class TestDataSetup{ customer.setServiceSubscription(buildServiceSubscription()); gBBInput.setCustomer(customer); - + return customer; } - + public Collection setCollection() { Collection collection = new Collection(); collection.setId("testId"); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.setCollection(collection); - + return collection; } - + public InstanceGroup setInstanceGroup() { InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId"); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction"); - + Collection collection = null; - + try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); collection = serviceInstance.getCollection(); - + if (collection == null) { collection = setCollection(); } } catch(BBObjectNotFoundException e) { collection = setCollection(); } - + collection.setInstanceGroup(instanceGroup); - + return instanceGroup; } - + public VpnBinding buildVpnBinding() { vpnBindingCounter++; - + VpnBinding vpnBinding = new VpnBinding(); vpnBinding.setVpnId("testVpnId" + vpnBindingCounter); vpnBinding.setVpnName("testVpnName" + vpnBindingCounter); vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter); - + return vpnBinding; } - + public VpnBinding setVpnBinding() { VpnBinding vpnBinding = buildVpnBinding(); - + Customer customer = gBBInput.getCustomer(); if(customer == null){ @@ -403,72 +404,72 @@ public class TestDataSetup{ customer.getVpnBindings().add(vpnBinding); lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId()); - + return vpnBinding; } - + public InstanceGroup buildInstanceGroup() { instanceGroupCounter++; - + InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId" + instanceGroupCounter); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter); - + return instanceGroup; } - + public L3Network buildL3Network() { l3NetworkCounter++; - + L3Network network = new L3Network(); network.setNetworkId("testNetworkId" + l3NetworkCounter); network.setNetworkName("testNetworkName" + l3NetworkCounter); network.setNetworkType("testNetworkType" + l3NetworkCounter); - + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter); modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter); modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter); modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter); network.setModelInfoNetwork(modelInfoNetwork); - + return network; } - + public L3Network setL3Network() { L3Network network = buildL3Network(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getNetworks().add(network); lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId()); - + return network; } - + public GenericVnf buildGenericVnf() { genericVnfCounter++; - + GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("testVnfId" + genericVnfCounter); genericVnf.setVnfName("testVnfName" + genericVnfCounter); genericVnf.setVnfType("testVnfType" + genericVnfCounter); genericVnf.setIpv4OamAddress("10.222.22.2"); - + Platform platform = new Platform(); platform.setPlatformName("testPlatformName"); genericVnf.setPlatform(platform); - + LineOfBusiness lob = new LineOfBusiness(); lob.setLineOfBusinessName("testLineOfBusinessName"); genericVnf.setLineOfBusiness(lob); - + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter); modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter); @@ -476,34 +477,40 @@ public class TestDataSetup{ modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter); modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - + + License license = new License(); + List<String> array = new ArrayList<String>(); + array.add("testPoolUuid"); + license.setEntitlementPoolUuids(array); + genericVnf.setLicense(license); + return genericVnf; } - + public GenericVnf setGenericVnf() { GenericVnf genericVnf = buildGenericVnf(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVnfs().add(genericVnf); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId()); - + return genericVnf; } - + public VfModule buildVfModule() { vfModuleCounter++; - + VfModule vfModule = new VfModule(); vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter); vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter); - + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter); modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter); @@ -511,128 +518,128 @@ public class TestDataSetup{ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter); modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter); vfModule.setModelInfoVfModule(modelInfoVfModule); - + return vfModule; } - + public VfModule setVfModule() { VfModule vfModule = buildVfModule(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVfModules().add(vfModule); lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); - + return vfModule; } - + public VolumeGroup buildVolumeGroup() { volumeGroupCounter++; - + VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter); volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter); volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter); - + return volumeGroup; } - + public VolumeGroup setVolumeGroup() { VolumeGroup volumeGroup = buildVolumeGroup(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVolumeGroups().add(volumeGroup); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - + return volumeGroup; } - + public Pnf buildPnf() { pnfCounter++; - + Pnf pnf = new Pnf(); pnf.setPnfId("testPnfId" + pnfCounter); pnf.setPnfName("testPnfName" + pnfCounter); - + return pnf; } - + public ServiceProxy buildServiceProxy() { serviceProxyCounter++; - + ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setServiceInstance(buildServiceInstance()); serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf()); - + Pnf primaryPnf = buildPnf(); primaryPnf.setRole("Primary"); serviceProxy.getServiceInstance().getPnfs().add(primaryPnf); - + Pnf secondaryPnf = buildPnf(); secondaryPnf.setRole("Secondary"); serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf); - + return serviceProxy; } - + public VpnBondingLink buildVpnBondingLink() { vpnBondingLinkCounter++; - + VpnBondingLink vpnBondingLink = new VpnBondingLink(); vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter); - + Configuration vnrConfiguration = buildConfiguration(); - vnrConfiguration.setNetwork(buildL3Network()); + vnrConfiguration.setNetwork(buildL3Network()); vpnBondingLink.setVnrConfiguration(vnrConfiguration); vpnBondingLink.setVrfConfiguration(buildConfiguration()); - + vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy()); - + vpnBondingLink.setTransportServiceProxy(buildServiceProxy()); - + return vpnBondingLink; } - + public VpnBondingLink setVpnBondingLink() { VpnBondingLink vpnBondingLink = buildVpnBondingLink(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVpnBondingLinks().add(vpnBondingLink); lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId()); return vpnBondingLink; } - + public Customer setAvpnCustomer() { Customer customer = buildCustomer(); - + gBBInput.setCustomer(customer); - + return customer; } - + public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) { ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setId("testProxyId" + uniqueIdentifier); @@ -658,12 +665,12 @@ public class TestDataSetup{ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier); modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier); modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier); - + ar.setModelInfoAllottedResource(modelInfo); - + return ar; } - + public Configuration setConfiguration () { Configuration config = new Configuration(); config.setConfigurationId("testConfigurationId"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java index 6a40db3eaa..cc96326563 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java @@ -7,9 +7,9 @@ * 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. @@ -44,7 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired; public class SDNCAssignTasksTest extends BaseTaskTest{ @Autowired private SDNCAssignTasks sdncAssignTasks; - + private L3Network network; private ServiceInstance serviceInstance; private RequestContext requestContext; @@ -53,7 +53,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ private VfModule vfModule; private VolumeGroup volumeGroup; private Customer customer; - + @Before public void before() { customer = setCustomer(); @@ -66,7 +66,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ volumeGroup = setVolumeGroup(); } - + @Test public void assignServiceInstanceTest() throws Exception { doReturn("response").when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext); @@ -76,35 +76,36 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext); assertTrue(execution.getVariable("SDNCResponse").equals("response")); } - + @Test public void assignServiceInstanceExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - + doThrow(Exception.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext); sdncAssignTasks.assignServiceInstance(execution); } - + @Test public void assignVnfTest() throws Exception { doReturn("response").when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); + execution.setVariable("generalBuildingBlock", gBBInput); sdncAssignTasks.assignVnf(execution); verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false); assertTrue(execution.getVariable("SDNCResponse").equals("response")); } - + @Test public void assignVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - + doThrow(Exception.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); - + sdncAssignTasks.assignVnf(execution); } - + @Test public void assignVfModuleTest() throws Exception { doReturn("response").when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); @@ -114,16 +115,16 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); assertTrue(execution.getVariable("SDNCAssignResponse_" + vfModule.getVfModuleId()).equals("response")); } - + @Test public void assignVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - + doThrow(Exception.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); sdncAssignTasks.assignVfModule(execution); } - + @Test public void assignNetworkTest() throws Exception { doReturn("response").when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); @@ -132,11 +133,11 @@ public class SDNCAssignTasksTest extends BaseTaskTest{ verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); } - + @Test public void assignNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - + doThrow(Exception.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion); sdncAssignTasks.assignNetwork(execution); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 27173b7502..6cac238482 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -153,55 +153,56 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("CreateNetworkBB"); + bb1.setBpmnFlowName("AssignVfModuleBB"); flowsToExecute.add(ebb1); ebb1.setBuildingBlock(bb1); ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("ActivateNetworkBB"); + bb2.setBpmnFlowName("CreateVfModuleBB"); + flowsToExecute.add(ebb2); + ebb2.setBuildingBlock(bb2); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); + BuildingBlock bb3 = new BuildingBlock(); + bb3.setBpmnFlowName("ActivateVfModuleBB"); + flowsToExecute.add(ebb3); + ebb3.setBuildingBlock(bb3); + + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("gCurrentSequence", 2); + + workflowActionBBTasks.rollbackExecutionPath(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB"); + assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB"); + assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB"); + } + + @Test + public void rollbackExecutionPathUnfinishedFlowTest(){ + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); + BuildingBlock bb1 = new BuildingBlock(); + bb1.setBpmnFlowName("AssignVfModuleBB"); + flowsToExecute.add(ebb1); + ebb1.setBuildingBlock(bb1); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); + BuildingBlock bb2 = new BuildingBlock(); + bb2.setBpmnFlowName("CreateVfModuleBB"); flowsToExecute.add(ebb2); ebb2.setBuildingBlock(bb2); ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("CreateVolumeGroupBB"); + bb3.setBpmnFlowName("ActivateVfModuleBB"); flowsToExecute.add(ebb3); ebb3.setBuildingBlock(bb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("ActivateVolumeGroupBB"); - flowsToExecute.add(ebb4); - ebb4.setBuildingBlock(bb4); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - BuildingBlock bb5 = new BuildingBlock(); - bb5.setBpmnFlowName("CreateVfModuleBB"); - flowsToExecute.add(ebb5); - ebb5.setBuildingBlock(bb5); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - BuildingBlock bb6 = new BuildingBlock(); - bb6.setBpmnFlowName("ActivateVfModuleBB"); - flowsToExecute.add(ebb6); - ebb6.setBuildingBlock(bb6); - ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock(); - BuildingBlock bb7 = new BuildingBlock(); - bb7.setBpmnFlowName("ActivateVnfBB"); - ebb7.setBuildingBlock(bb7); - flowsToExecute.add(ebb7); - ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock(); - BuildingBlock bb8 = new BuildingBlock(); - bb8.setBpmnFlowName("ActivateServiceInstance"); - ebb8.setBuildingBlock(bb8); - flowsToExecute.add(ebb8); execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable("gCurrentSequence", 6); + execution.setVariable("gCurrentSequence", 1); workflowActionBBTasks.rollbackExecutionPath(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB"); - assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeactivateVolumeGroupBB"); - assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"DeleteVolumeGroupBB"); - assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB"); - assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB"); + assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB"); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java index eb17ad0ff9..e30fe660c3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java @@ -20,6 +20,8 @@ package org.onap.so.client.sdn.common; +import static org.junit.Assert.assertEquals; + import java.util.LinkedHashMap; import org.junit.Assert; @@ -58,10 +60,12 @@ public class SdnCommonTasksTest{ @Test public void validateSDNResponseTest() throws BadResponseException { - LinkedHashMap responseMap = new LinkedHashMap(); - responseMap.put("response-code", "0"); - responseMap.put("response-message", "success"); - Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap)); + LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>(); + LinkedHashMap<String, Object> output = new LinkedHashMap<>(); + output.put("response-code", "0"); + output.put("response-message", "success"); + responseMap.put("output", output); + assertEquals("success", sdnCommonTasks.validateSDNResponse(responseMap)); } @Test @@ -74,10 +78,12 @@ public class SdnCommonTasksTest{ @Test public void validateSDNResponseTestRespCodeNot200() throws BadResponseException { expectedException.expect(BadResponseException.class); - LinkedHashMap responseMap = new LinkedHashMap(); - responseMap.put("response-code", "300"); - responseMap.put("response-message", "Failed"); - Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap)); + LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>(); + LinkedHashMap<String, Object> output = new LinkedHashMap<>(); + output.put("response-code", "300"); + output.put("response-message", "Failed"); + responseMap.put("output", output); + sdnCommonTasks.validateSDNResponse(responseMap); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java index 2492638520..e24ca339a3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java @@ -22,7 +22,9 @@ package org.onap.so.client.sdnc; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import java.io.IOException; @@ -34,6 +36,7 @@ import org.junit.Test; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.skyscreamer.jsonassert.JSONAssert; import com.github.tomakehurst.wiremock.junit.WireMockRule; @@ -55,4 +58,31 @@ public class SDNCClientTest extends BaseTaskTest { String response = SPY_sdncClient.get(queryLink); JSONAssert.assertEquals(responseJson, response, false); } + + @Test(expected = BadResponseException.class) + public void post404Test() throws BadResponseException, MapperException, IOException { + String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json"))); + + String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; + + wireMockRule.stubFor(post(urlMatching(queryLink)) + .willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json").withBody(responseJson))); + + SPY_sdncClient.post("", SDNCTopology.NETWORK); + } + + @Test + public void post200Test() throws BadResponseException, MapperException, IOException { + String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json"))); + + String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; + + wireMockRule.stubFor(post(urlMatching(queryLink)) + .willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json").withBody(responseJson))); + + String response = SPY_sdncClient.post("", SDNCTopology.NETWORK); + JSONAssert.assertEquals("", response, false); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json new file mode 100644 index 0000000000..286ce4c844 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200Response.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "Y" + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json new file mode 100644 index 0000000000..cf0254886d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut404Response.json @@ -0,0 +1,8 @@ +{ + "output": { + "svc-request-id": "086a7a09-1470-4977-8b3e-307488b8811a", + "response-code": "404", + "response-message": "invalid input: the service-instance does not have any service data in SDNC", + "ack-final-indicator": "Y" + } +} diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java index 84dae957ba..4d48d349b5 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntity.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -23,7 +23,8 @@ package org.onap.so.utils; import java.util.EnumSet; public enum TargetEntity { - OPENSTACK_ADAPTER, BPMN, GRM ,AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER, NARAD; + OPENSTACK_ADAPTER, BPMN, GRM ,AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, + VNF_ADAPTER, SDNC_ADAPTER, NARAD, MULTICLOUD; private static final String PREFIX = "SO"; diff --git a/docs/api/SO_Interface.rst b/docs/api/SO_Interface.rst index 695cedbd48..4f3d9146e4 100644 --- a/docs/api/SO_Interface.rst +++ b/docs/api/SO_Interface.rst @@ -18,7 +18,7 @@ Create service instance +--------------------+-------------------------------------+ |Interface Definition|Description | +====================+=====================================+ -|URI |{serverRoot}/serviceInstances/v6 | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6 | +--------------------+-------------------------------------+ |Operation Type |POST | +--------------------+-------------------------------------+ @@ -210,7 +210,7 @@ Delete service instance +--------------------+---------------------------------------------------------+ |Interface Definition|Description | +====================+=========================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId} | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId} | +--------------------+---------------------------------------------------------+ |Operation Type |DELETE | +--------------------+---------------------------------------------------------+ @@ -263,7 +263,7 @@ Create Volume Group +--------------------+-------------------------------------------------------------------------------------------+ |Interface Definition|Description | +====================+===========================================================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups | +--------------------+-------------------------------------------------------------------------------------------+ |Operation Type |POST | +--------------------+-------------------------------------------------------------------------------------------+ @@ -394,7 +394,7 @@ Delete Volume Group +--------------------+---------------------------------------------------------------------------------------------------------------------+ |Interface Definition|Description | +====================+=====================================================================================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volume-groupinstance-id} | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volume-groupinstance-id} | +--------------------+---------------------------------------------------------------------------------------------------------------------+ |Operation Type |DELETE | +--------------------+---------------------------------------------------------------------------------------------------------------------+ @@ -455,7 +455,7 @@ Create VF Module +--------------------+----------------------------------------------------------------------------------------+ |Interface Definition|Description | +====================+========================================================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules | +--------------------+----------------------------------------------------------------------------------------+ |Operation Type |POST | +--------------------+----------------------------------------------------------------------------------------+ @@ -550,7 +550,7 @@ Delete VF Module +--------------------+--------------------------------------------------------------------------------------------------------------+ |Interface Definition|Description | +====================+==============================================================================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleinstance-id} | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleinstance-id} | +--------------------+--------------------------------------------------------------------------------------------------------------+ |Operation Type |DELETE | +--------------------+--------------------------------------------------------------------------------------------------------------+ @@ -619,7 +619,7 @@ Create VNF +--------------------+--------------------------------------------------------------+ |Interface Definition|Description | +====================+==============================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs | +--------------------+--------------------------------------------------------------+ |Operation Type |POST | +--------------------+--------------------------------------------------------------+ @@ -766,7 +766,7 @@ Delete VNF +--------------------+------------------------------------------------------------------------------+ |Interface Definition|Description | +====================+==============================================================================+ -|URI |{serverRoot}/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId} | +|URI |/onap/so/infra/serviceInstantiation/serviceInstances/v6/{serviceInstanceId}/vnfs/{vnfInstanceId} | +--------------------+------------------------------------------------------------------------------+ |Operation Type |DELETE | +--------------------+------------------------------------------------------------------------------+ @@ -847,7 +847,7 @@ GET Orchestration Request +--------------------+--------------------------------------------------------------+ |Interface Definition|Description | +====================+==============================================================+ -|URI |{serverRoot}/orchestrationRequests/v6/{request-id} | +|URI |/onap/so/infra/serviceInstantiation/orchestrationRequests/v6/{request-id} | +--------------------+--------------------------------------------------------------+ |Operation Type |GET | +--------------------+--------------------------------------------------------------+ @@ -998,7 +998,7 @@ GET Orchestration Requests +--------------------+--------------------------------------------------------------+ |Interface Definition|Description | +====================+==============================================================+ -|URI |{serverRoot}/orchestrationRequests/v6 | +|URI |/onap/so/infra/serviceInstantiation/orchestrationRequests/v6 | +--------------------+--------------------------------------------------------------+ |Operation Type |GET | +--------------------+--------------------------------------------------------------+ @@ -1751,7 +1751,7 @@ Create E2E service instance +--------------------+-------------------------------------+ |Interface Definition|Description | +====================+=====================================+ -|URI |{serverRoot}/e2eServiceInstances/v3 | +|URI |/onap/so/infra/serviceInstantiation/e2eServiceInstances/v3 | +--------------------+-------------------------------------+ |Operation Type |POST | +--------------------+-------------------------------------+ @@ -1848,7 +1848,7 @@ Delete E2E service instance +--------------------+-----------------------------------------------+ |Interface Definition|Description | +====================+===============================================+ -|URI |{serverRoot}/e2eServiceInstances/v3/{serviceId}| +|URI |/onap/so/infra/serviceInstantiation/e2eServiceInstances/v3/{serviceId}| +--------------------+-----------------------------------------------+ |Operation Type |DELETE | +--------------------+-----------------------------------------------+ @@ -1877,7 +1877,7 @@ Query E2E service operation result +--------------------+------------------------------------------------------------------------+ |Interface Definition|Description | +====================+========================================================================+ -|URI |{serverRoot}/e2eServiceInstances/v3/{serviceId}/operations/{operationId}| +|URI |/onap/so/infra/serviceInstantiation/e2eServiceInstances/v3/{serviceId}/operations/{operationId}| +--------------------+------------------------------------------------------------------------+ |Operation Type |GET | +--------------------+------------------------------------------------------------------------+ diff --git a/docs/api/offered_consumed_apis.rst b/docs/api/offered_consumed_apis.rst index 6f8b7fcb89..0cf7e0f341 100644 --- a/docs/api/offered_consumed_apis.rst +++ b/docs/api/offered_consumed_apis.rst @@ -5,11 +5,20 @@ SO Offered and Consumed APIs ===================================== -SO APIs --------- -All the Service Orchestrator APIs, both inward and outward are documented in the below link of onap wiki. - -.. toctree:: - :maxdepth: 1 - - SO_Interface.rst +The list of APIs that SO offerers could be find in the following table: + +.. |yml-icon| image:: swagger/images/yaml.png + :width: 40px + +.. |swagger-icon| image:: swagger/images/swagger.png + :width: 40px + +.. |html-icon| image:: swagger/images/html.png + :width: 40px + +.. csv-table:: + :header: "|Swagger-icon|", "|html-icon|", "|yml-icon|" + :widths: 60,60,60 + + "swagger json file", "html doc", "yaml doc" + ":download:`link <swagger/swagger.json>`", ":download:`link <swagger/swagger.html>`", ":download:`link <swagger/swagger.yaml>`" diff --git a/docs/api/swagger.json b/docs/api/swagger.json new file mode 100644 index 0000000000..65d7ff0d11 --- /dev/null +++ b/docs/api/swagger.json @@ -0,0 +1,2302 @@ +{ + "swagger": "2.0", + "info": { + "version": "3.1.2", + "title": "SO Casablanca APIs" + }, + "tags": [ + { + "name": "e2eServiceInstances" + }, + { + "name": "globalhealthcheck" + }, + { + "name": "nodehealthcheck" + }, + { + "name": "onapsoinfraorchestrationRequests" + }, + { + "name": "onapsoinfraserviceInstantiation" + }, + { + "name": "onapsoinfratasks" + }, + { + "name": "onapsoinfracloudResources" + }, + { + "name": "onapsoinfracloudResourcesRequests" + }, + { + "name": "onapsoinframodelDistributions" + } + ], + "schemes": [ + "https" + ], + "paths": { + "/e2eServiceInstances/{version}": { + "post": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Create an E2E Service Instance on a version provided", + "description": "", + "operationId": "createE2EServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/e2eServiceInstances/{version}/{serviceId}": { + "put": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Update an E2E Service Instance on a version provided and serviceId", + "description": "", + "operationId": "updateE2EServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + }, + { + "name": "serviceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + }, + "delete": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Delete E2E Service Instance on a specified version and serviceId", + "description": "", + "operationId": "deleteE2EServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + }, + { + "name": "serviceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/e2eServiceInstances/{version}/{serviceId}/operations/{operationId}": { + "get": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Find e2eServiceInstances Requests for a given serviceId and operationId", + "description": "", + "operationId": "getE2EServiceInstances", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "serviceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + }, + { + "name": "operationId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/e2eServiceInstances/{version}/{serviceId}/scale": { + "post": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Scale E2E Service Instance on a specified version", + "description": "", + "operationId": "scaleE2EServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + }, + { + "name": "serviceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/e2eServiceInstances/{version}/{serviceId}/modeldifferences": { + "post": { + "tags": [ + "e2eServiceInstances" + ], + "summary": "Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId ", + "description": "", + "operationId": "compareModelwithTargetVersion", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "serviceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][3-5]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/globalhealthcheck": { + "get": { + "tags": [ + "globalhealthcheck" + ], + "summary": "Performing global health check", + "description": "", + "operationId": "globalHealthcheck", + "produces": [ + "text/html" + ], + "parameters": [ + { + "name": "enableBpmn", + "in": "query", + "required": false, + "type": "boolean", + "default": true + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/nodehealthcheck": { + "get": { + "tags": [ + "nodehealthcheck" + ], + "summary": "Performing node health check", + "description": "", + "operationId": "nodeHealthcheck", + "produces": [ + "text/html" + ], + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/orchestrationRequests/{version}": { + "get": { + "tags": [ + "onapsoinfraorchestrationRequests" + ], + "summary": "Find Orchestrated Requests for a URI Information", + "description": "", + "operationId": "getOrchestrationRequest", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][4-7]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/orchestrationRequests/{version}/{requestId}": { + "get": { + "tags": [ + "onapsoinfraorchestrationRequests" + ], + "summary": "Find Orchestrated Requests for a given requestId", + "description": "", + "operationId": "getOrchestrationRequestForReqId", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "requestId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][4-7]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/orchestrationRequests/{version}/{requestId}/unlock": { + "post": { + "tags": [ + "onapsoinfraorchestrationRequests" + ], + "summary": "Unlock Orchestrated Requests for a given requestId", + "description": "", + "operationId": "unlockOrchestrationRequest", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "requestId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][4-7]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/deactivateAndCloudDelete": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Deactivate and Cloud Delete VfModule instance", + "description": "", + "operationId": "deactivateAndCloudDeleteVfModuleInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vfmoduleInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/enablePort": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Enable Port Mirroring", + "description": "", + "operationId": "enablePort", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "configurationInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/disablePort": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Disable Port Mirroring", + "description": "", + "operationId": "disablePort", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "configurationInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/activate": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Activate Port Mirroring", + "description": "", + "operationId": "activatePort", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "configurationInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/deactivate": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Deactivate Port Mirroring", + "description": "", + "operationId": "deactivatePort", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "configurationInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/addRelationships": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Add Relationships to a Service Instance", + "description": "", + "operationId": "addRelationships", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][6-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "VF Auto Scale Out", + "description": "", + "operationId": "scaleOutVfModule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/inPlaceSoftwareUpdate": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Perform VNF software update", + "description": "", + "operationId": "inPlaceSoftwareUpdate", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][6-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/applyUpdatedConfig": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Apply updated configuration", + "description": "", + "operationId": "applyUpdatedConfig", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][6-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create a Service Instance on a version provided", + "description": "", + "operationId": "createServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/activate": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Activate provided Service Instance", + "description": "", + "operationId": "activateServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/deactivate": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Deactivate provided Service Instance", + "description": "", + "operationId": "deactivateServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}": { + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided Service Instance", + "description": "", + "operationId": "deleteServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/assign": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Assign Service Instance", + "description": "", + "operationId": "assignServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][7]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/unassign": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Unassign Service Instance", + "description": "", + "operationId": "unassignServiceInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create Port Mirroring Configuration", + "description": "", + "operationId": "createPortConfiguration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}": { + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided Port", + "description": "", + "operationId": "deletePortConfiguration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "configurationInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/removeRelationships": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Remove Relationships from Service Instance", + "description": "", + "operationId": "removeRelationships", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][6-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create VNF on a specified version and serviceInstance", + "description": "", + "operationId": "createVnfInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Replace provided VNF instance", + "description": "", + "operationId": "replaceVnfInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}": { + "put": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Update VNF on a specified version, serviceInstance and vnfInstance", + "description": "", + "operationId": "updateVnfInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + }, + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided VNF instance", + "description": "", + "operationId": "deleteVnfInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create VfModule on a specified version, serviceInstance and vnfInstance", + "description": "", + "operationId": "createVfModuleInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/replace": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create VfModule on a specified version, serviceInstance and vnfInstance", + "description": "", + "operationId": "replaceVfModuleInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vfmoduleInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}": { + "put": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Update VfModule on a specified version, serviceInstance, vnfInstance and vfModule", + "description": "", + "operationId": "updateVfModuleInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vfmoduleInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + }, + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided VfModule instance", + "description": "", + "operationId": "deleteVfModuleInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vfmoduleInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create VolumeGroup on a specified version, serviceInstance, vnfInstance", + "description": "", + "operationId": "createVolumeGroupInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}": { + "put": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Update VolumeGroup on a specified version, serviceInstance, vnfInstance and volumeGroup", + "description": "", + "operationId": "updateVolumeGroupInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "volumeGroupInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + }, + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided VolumeGroup instance", + "description": "", + "operationId": "deleteVolumeGroupInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "vnfInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "volumeGroupInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/networks": { + "post": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Create NetworkInstance on a specified version and serviceInstance ", + "description": "", + "operationId": "createNetworkInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/serviceInstantiation/{version}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}": { + "put": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Update VolumeGroup on a specified version, serviceInstance, networkInstance", + "description": "", + "operationId": "updateNetworkInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "networkInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + }, + "delete": { + "tags": [ + "onapsoinfraserviceInstantiation" + ], + "summary": "Delete provided Network instance", + "description": "", + "operationId": "deleteNetworkInstance", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][5-7]" + }, + { + "name": "serviceInstanceId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "networkInstanceId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/tasks/{version}": { + "get": { + "tags": [ + "onapsoinfratasks" + ], + "summary": "Finds Manual Tasks", + "description": "", + "operationId": "queryFilters", + "parameters": [ + { + "name": "taskId", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "originalRequestId", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "subscriptionServiceType", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "nfRole", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "buildingBlockName", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "originalRequestDate", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "originalRequestorId", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV]1" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/cloudResources/{version}/operationalEnvironments": { + "post": { + "tags": [ + "onapsoinfracloudResources" + ], + "summary": "Create an Operational Environment", + "description": "", + "operationId": "createOperationEnvironment", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/cloudResources/{version}/operationalEnvironments/{operationalEnvironmentId}/activate": { + "post": { + "tags": [ + "onapsoinfracloudResources" + ], + "summary": "Activate an Operational Environment", + "description": "", + "operationId": "activateOperationEnvironment", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + }, + { + "name": "operationalEnvironmentId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/cloudResources/{version}/operationalEnvironments/{operationalEnvironmentId}/deactivate": { + "post": { + "tags": [ + "onapsoinfracloudResources" + ], + "summary": "Deactivate an Operational Environment", + "description": "", + "operationId": "deactivateOperationEnvironment", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + }, + { + "name": "operationalEnvironmentId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/cloudResourcesRequests/{version}/{requestId}/unlock": { + "post": { + "tags": [ + "onapsoinfracloudResourcesRequests" + ], + "summary": "Unlock CloudOrchestration requests for a specified requestId", + "description": "", + "operationId": "unlockOrchestrationRequestForReqId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "requestId", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/cloudResourcesRequests/{version}": { + "get": { + "tags": [ + "onapsoinfracloudResourcesRequests" + ], + "summary": "Get status of an Operational Environment based on filter criteria", + "description": "", + "operationId": "getOperationEnvironmentStatusFilter", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/onap/so/infra/modelDistributions/{version}/distributions/{distributionId}": { + "post": { + "tags": [ + "onapsoinframodelDistributions" + ], + "summary": "Update model distribution status", + "description": "", + "operationId": "updateModelDistributionStatus", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "version", + "in": "path", + "required": true, + "type": "string", + "pattern": "[vV][1]" + }, + { + "name": "distributionId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "default": { + "description": "successful operation" + } + } + } + } + } +}
\ No newline at end of file diff --git a/docs/architecture/architecture.rst b/docs/architecture/architecture.rst index 7965e1d50f..6ca11cd6b3 100644 --- a/docs/architecture/architecture.rst +++ b/docs/architecture/architecture.rst @@ -89,10 +89,10 @@ SO Sub-Components **SO Monitoring** Monitor BPMN Workflow execution by providing - * Service list search based on search criteria - * Service statistic - * Service Process Instance Rendering and Detail - + * Service list search based on search criteria + * Service statistic + * Service Process Instance Rendering and Detail + Third Party and Open Source --------------------------- diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst index 8613f2605c..61be8f006f 100644 --- a/docs/developer_info/developer_information.rst +++ b/docs/developer_info/developer_information.rst @@ -8,13 +8,13 @@ SO Developer Information .. toctree:: :maxdepth: 1 -.. developer_info/developer_info_Project_Structure.rst - developer_info/Camunda_Modeler.rst -.. developer_info/developer_info_Main_Process_Flows.rst -.. developer_info/developer_info_Subprocess_Process_Flows.rst -.. developer_info/developer_info_Project_Deployment_Strategy.rst - developer_info/Building_SO.rst - developer_info/Working_with_SO_Docker.rst - developer_info/Camunda_Cockpit_Community_Edition.rst - developer_info/Camunda_Cockpit_Enterprise_Edition.rst +.. developer_info_Project_Structure.rst + Camunda_Modeler.rst +.. developer_info_Main_Process_Flows.rst +.. developer_info_Subprocess_Process_Flows.rst +.. developer_info_Project_Deployment_Strategy.rst + Building_SO.rst + Working_with_SO_Docker.rst + Camunda_Cockpit_Community_Edition.rst + Camunda_Cockpit_Enterprise_Edition.rst
\ No newline at end of file diff --git a/docs/release_notes/release-notes.rst b/docs/release_notes/release-notes.rst index d3448497cf..f9c7002e8a 100644 --- a/docs/release_notes/release-notes.rst +++ b/docs/release_notes/release-notes.rst @@ -19,7 +19,7 @@ Temp release for Casablanca at M4. * Support PNF resource type. * Extend the support of homing to vFW, VDNS usecases. * Workflow Designer Integration. -* Monitoring BPMN worflow capabiliities through UI. +* Monitoring BPMN worflow capabilities through UI. * Support to the CCVPN Usecase. * SO internal architecture improvements @@ -35,7 +35,7 @@ The Beijing release is the second release of the Service Orchestrator (SO) proje * Enhance Platform maturity by improving SO maturity matrix see `Wiki <https://wiki.onap.org/display/DW/Beijing+Release+Platform+Maturity>`_. * Manual scaling of network services and VNFs. -* Homing and placement capabiliities through OOF interaction. +* Homing and placement capabilities through OOF interaction. * Ability to perform change management. * Integrated to APPC * Integrated to OOF @@ -102,7 +102,7 @@ It executes end-to-end service activities by processing workflows and business l The orchestration engine is a reusable service. Any component of the architecture can execute SO orchestration capabilities. * Orchestration services will process workflows based on defined models and recipe. -* The service model maintains consistency and reusability across all orchestration activities and ensures consistent methods, structure and version of the workflow execution environment. +* The service model maintains consistency and re-usability across all orchestration activities and ensures consistent methods, structure and version of the workflow execution environment. * Orchestration processes interact with other platform components or external systems via standard and well-defined APIs. diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java index 9a5334081f..29fa1a34b3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java @@ -76,8 +76,8 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ private final int retryCountThree = 3; private final int retryCountTwo = 2; private final int retryCountZero = 0; + private final String sdcDistributionId1 = "TEST_distributionId1"; private final String sdcDistributionId = "TEST_distributionId"; - private final String sdcDistributionId1 = "TEST_distributionId1"; private final String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString(); private final String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); private final String statusSent = "SENT"; @@ -221,12 +221,12 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ .withBody(mapper.writeValueAsString(iar)) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) - .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) - .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); @@ -290,12 +290,11 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) - .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId1\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) - .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); @@ -491,12 +490,12 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ .withBody(mapper.writeValueAsString(iar)) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) - .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"SKIP\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"SKIP\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) - .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql index 70c0791055..afcd7330f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql @@ -275,7 +275,16 @@ VALUES ('vfModule', 'replaceInstance', '1', 'Gr api recipe to replace vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), ('vfModule', 'deactivateAndCloudDelete', '1', 'Gr api recipe to deactivateAndCloudDelete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), ('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT'); +INSERT INTO requestdb.activate_operational_env_service_model_distribution_status (OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID,SERVICE_MOD_VER_FINAL_DISTR_STATUS,RECOVERY_ACTION,RETRY_COUNT_LEFT,WORKLOAD_CONTEXT, CREATE_TIME, MODIFY_TIME) +VALUES +('1234', 'TEST1234', '00032ab7-3fb3-42e5-965d-8ea592502017', "Test", "Test", 1, 'DEFAULT', '2018-08-14 16:50:59', '2018-08-14 16:50:59'); +INSERT INTO requestdb.activate_operational_env_service_model_distribution_status (OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID,SERVICE_MOD_VER_FINAL_DISTR_STATUS,RECOVERY_ACTION,RETRY_COUNT_LEFT,WORKLOAD_CONTEXT, CREATE_TIME, MODIFY_TIME) +VALUES +('1234', 'TEST1235', '00032ab7-3fb3-42e5-965d-8ea592502017', "Test", "Test", 2, 'DEFAULT', '2018-08-14 16:50:59', '2018-08-14 16:50:59'); +INSERT INTO requestdb.activate_operational_env_per_distributionid_status (DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, DISTRIBUTION_ID_ERROR_REASON, CREATE_TIME, MODIFY_TIME, OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID) +VALUES +('111', 'TEST', 'ERROR', '2018-09-12 19:29:24', '2018-09-12 19:29:25', '1234', 'TEST1234', '00032ab7-3fb3-42e5-965d-8ea592502017'); UPDATE vnf_components_recipe SET vf_module_model_uuid = 'VNF-API-DEFAULT' diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java index 5b6fbc8378..9bb5cab9b5 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; -@SpringBootApplication(scanBasePackages = { "org.onap.so.db" }) +@SpringBootApplication(scanBasePackages = { "org.onap.so" }) @Profile("test") public class TestApplication { public static void main(String... args) { @@ -35,8 +35,4 @@ public class TestApplication { System.getProperties().setProperty("mso.db", "MARIADB"); System.getProperties().setProperty("server.name", "Springboot"); } - @Bean - public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); - } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 6ab92853d1..07d185b3af 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -20,6 +20,17 @@ package org.onap.so.db.request.client; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; + import org.apache.http.HttpStatus; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -36,36 +47,20 @@ import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.http.HttpRequest; +import org.springframework.http.ResponseEntity; import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; -import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; -import uk.co.blackpepper.bowman.RestTemplateConfigurer; - -import javax.annotation.PostConstruct; -import javax.ws.rs.core.UriBuilder; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; @Component("RequestsDbClient") @Primary @@ -74,14 +69,10 @@ public class RequestsDbClient { private static final String SERVICE_ID = "SERVICE_ID"; private static final String OPERATION_ID = "OPERATION_ID"; private static final String SO_REQUEST_ID = "SO_REQUEST_ID"; - private static final String GROUPING_ID = "GROUPING_ID"; private static final String REQUEST_ID = "REQUEST_ID"; - private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENVIRONMENT_ID"; + private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENV_ID"; private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID"; - private static final String NAME = "NAME"; - private static final String VALUE = "VALUE"; - private static final String TAG = "TAG"; - + @Value("${mso.adapters.requestDb.endpoint}") protected String endpoint; @@ -112,9 +103,7 @@ public class RequestsDbClient { private String requestProcessingDataURI = "/requestProcessingData"; - private String findOneBySoRequestIdAndGroupingIdAndNameAndTagURI = "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndNameAndTag/"; - - private String findBySoRequestIdOrderByGroupingIdDesc = "/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"; + private final String findBySoRequestIdOrderByGroupingIdDesc = "/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc"; @Autowired @@ -137,8 +126,8 @@ public class RequestsDbClient { findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI; } - public ClientFactory getClientFactory(){ - URI baseUri = UriBuilder.fromUri(endpoint).build(); + private ClientFactory getClientFactory(){ + URI baseUri = UriBuilder.fromUri(endpoint).build(); ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { @@ -152,11 +141,10 @@ public class RequestsDbClient { }).build().buildClientFactory(); } - + public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){ URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); HttpEntity<Map> entity = new HttpEntity<>(orchestrationMap, headers); try{ return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); @@ -170,10 +158,8 @@ public class RequestsDbClient { public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { try { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - HttpEntity<?> entity = new HttpEntity<>(headers); - InfraActiveRequests infraActiveRequests = restTemplate.exchange(getUri(endpoint + "/infraActiveRequests/" + requestId), HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); + HttpEntity<?> entity = getHttpEntity(); + InfraActiveRequests infraActiveRequests = restTemplate.exchange(getUri(endpoint + "/infraActiveRequests/" + requestId), HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); if (infraActiveRequests != null) { infraActiveRequests.setRequestId(requestId); } @@ -187,28 +173,29 @@ public class RequestsDbClient { } public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(getOrchestrationFilterURI); HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(orchestrationMap, headers); return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); } public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - HttpEntity<?> entity = new HttpEntity<>(headers); + HttpEntity<?> entity = getHttpEntity(); URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId); return restTemplate.exchange(uri, HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); } public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName, String requestScope) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(checkInstanceNameDuplicate); HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); + ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class); + if(response != null && response.hasBody()) { + return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); + } else { + return null; + } }catch(HttpClientErrorException e){ if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ return null; @@ -220,13 +207,11 @@ public class RequestsDbClient { public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId) { try { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - HttpEntity<?> entity = new HttpEntity<>(headers); - OperationStatus operationStatus = restTemplate.exchange(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)) + HttpEntity<?> entity = getHttpEntity(); + OperationStatus operationStatus = restTemplate.exchange(getUri(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)) .queryParam(SERVICE_ID, serviceId) .queryParam(OPERATION_ID, operationId) - .build(), HttpMethod.GET, entity, OperationStatus.class).getBody(); + .build().toString()), HttpMethod.GET, entity, OperationStatus.class).getBody(); if (operationStatus != null) { operationStatus.setServiceId(serviceId); operationStatus.setOperationId(operationId); @@ -240,27 +225,49 @@ public class RequestsDbClient { throw e; } } - + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvironmentId, String serviceModelVersionId) { - return this.getSingleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdURI) - .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId) - .queryParam(SERVICE_MODEL_VERSION_ID,serviceModelVersionId) - .build()); + try { + HttpEntity<?> entity = getHttpEntity(); + OperationalEnvServiceModelStatus modelStatus = restTemplate.exchange(getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdURI) + .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId) + .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId) + .build().toString()), HttpMethod.GET, entity, OperationalEnvServiceModelStatus.class).getBody(); + if (null != modelStatus) { + modelStatus.setOperationalEnvId(operationalEnvironmentId); + modelStatus.setServiceModelVersionId(serviceModelVersionId); + } + return modelStatus; + }catch(HttpClientErrorException e){ + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } } public List<OperationalEnvServiceModelStatus> getAllByOperationalEnvIdAndRequestId(String operationalEnvironmentId, String requestId){ - return this.getMultipleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findAllByOperationalEnvIdAndRequestIdURI) + return this.getMultipleOperationalEnvServiceModelStatus(getUri(UriBuilder.fromUri(findAllByOperationalEnvIdAndRequestIdURI) .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId) .queryParam(REQUEST_ID,requestId) - .build()); + .build().toString())); } public OperationalEnvDistributionStatus getDistributionStatusById(String distributionId){ - return this.getSingleOperationalEnvDistributionStatus(UriBuilder.fromUri(operationalEnvDistributionStatusURI+distributionId).build()); - } - - private OperationalEnvServiceModelStatus getSingleOperationalEnvServiceModelStatus(URI uri){ - return getClientFactory().create(OperationalEnvServiceModelStatus.class).get(uri); + try { + HttpEntity<?> entity = getHttpEntity(); + OperationalEnvDistributionStatus distributionStatus = restTemplate.exchange(getUri(operationalEnvDistributionStatusURI + distributionId), + HttpMethod.GET, entity, OperationalEnvDistributionStatus.class).getBody(); + if(null != distributionStatus){ + distributionStatus.setDistributionId(distributionId); + } + return distributionStatus; + }catch(HttpClientErrorException e){ + if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ + return null; + } + throw e; + } } private List<OperationalEnvServiceModelStatus> getMultipleOperationalEnvServiceModelStatus(URI uri){ @@ -270,32 +277,23 @@ public class RequestsDbClient { statusIterator.forEachRemaining(serviceModelStatuses::add); return serviceModelStatuses; } - + public void save(InfraActiveRequests infraActiveRequests) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(infraActiveRequestURI); HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(infraActiveRequests, headers); restTemplate.postForLocation(uri, entity); } public <T> void save(T object){ - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(endpoint+classURLMapper.getURI(object.getClass())); HttpEntity<T> entity = new HttpEntity<>(object, headers); restTemplate.postForLocation(uri, entity); } - private OperationalEnvDistributionStatus getSingleOperationalEnvDistributionStatus(URI uri){ - return getClientFactory().create(OperationalEnvDistributionStatus.class).get(uri); - } - - public void updateInfraActiveRequests(InfraActiveRequests request) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - headers.set(HttpHeaders.CONTENT_TYPE,"application/json"); - headers.set(HttpHeaders.ACCEPT, "application/json"); + public void updateInfraActiveRequests(InfraActiveRequests request) { + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(infraActiveRequestURI+request.getRequestId()); HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); restTemplate.put(uri, entity); @@ -306,32 +304,18 @@ public class RequestsDbClient { } public void saveRequestProcessingData(RequestProcessingData requestProcessingData) { - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); + HttpHeaders headers = getHttpHeaders(); URI uri = getUri(endpoint + requestProcessingDataURI); HttpEntity<RequestProcessingData> entity = new HttpEntity<>(requestProcessingData, headers); restTemplate.postForLocation(uri, entity); } - - public RequestProcessingData getRequestProcessingDataBySoRequestIdAndGroupingIdAndNameAndTag(String soRequestId, - String groupingId, String name, String tag) { - return this.getSingleRequestProcessingData(UriBuilder.fromUri(endpoint + findOneBySoRequestIdAndGroupingIdAndNameAndTagURI) - .queryParam(SO_REQUEST_ID,soRequestId) - .queryParam(GROUPING_ID,groupingId) - .queryParam(NAME,name) - .queryParam(TAG,tag) - .build()); - } + public List<RequestProcessingData> getRequestProcessingDataBySoRequestId(String soRequestId) { - return this.getRequestProcessingData(UriBuilder.fromUri(endpoint + findBySoRequestIdOrderByGroupingIdDesc) + return this.getRequestProcessingData(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdOrderByGroupingIdDesc) .queryParam(SO_REQUEST_ID,soRequestId) - .build()); + .build().toString())); } - - public RequestProcessingData getSingleRequestProcessingData(URI uri){ - return getClientFactory().create(RequestProcessingData.class).get(uri); - } - + private List<RequestProcessingData> getRequestProcessingData(URI uri) { Iterable<RequestProcessingData> requestProcessingDataIterator = getClientFactory().create(RequestProcessingData.class).getAll(uri); List<RequestProcessingData> requestProcessingDataList = new ArrayList<>(); @@ -339,15 +323,6 @@ public class RequestsDbClient { it.forEachRemaining(requestProcessingDataList::add); return requestProcessingDataList; } - - public List<RequestProcessingData> getAllRequestProcessingData() { - - return (List<RequestProcessingData>) this.getAllRequestProcessingData(UriBuilder.fromUri(endpoint + "/requestProcessingData").build()); - } - - private Iterable<RequestProcessingData> getAllRequestProcessingData(URI uri) { - return getClientFactory().create(RequestProcessingData.class).getAll(uri); - } @Component static class ClassURLMapper { @@ -385,4 +360,18 @@ public class RequestsDbClient { public void removePortFromEndpoint() { endpoint = endpoint.substring(0, endpoint.lastIndexOf(':') + 1); } + + private HttpHeaders getHttpHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + return headers; + } + + private HttpEntity<?> getHttpEntity() { + HttpHeaders headers = getHttpHeaders(); + return new HttpEntity<>(headers); + } + } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java index 9cce212c36..a56abff927 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java @@ -21,14 +21,19 @@ package org.onap.so.db.catalog.beans; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Date; import com.fasterxml.jackson.annotation.JsonProperty; import com.openpojo.business.annotation.BusinessKey; +import com.openpojo.reflection.java.packageloader.impl.URLToFileSystemAdapter; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import uk.co.blackpepper.bowman.annotation.RemoteResource; +import uk.co.blackpepper.bowman.annotation.ResourceId; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -40,6 +45,7 @@ import javax.persistence.OneToOne; import javax.persistence.PrePersist; import javax.persistence.Table; import javax.persistence.Temporal; +import javax.persistence.Transient; import javax.persistence.TemporalType; /** @@ -48,6 +54,7 @@ import javax.persistence.TemporalType; * object, of which it is a component * */ +@RemoteResource("/cloudSite") @Entity @Table(name = "cloud_sites") public class CloudSite { @@ -115,6 +122,9 @@ public class CloudSite { @Temporal(TemporalType.TIMESTAMP) private Date updated; + @Transient + private URI uri; + public CloudSite() { } @@ -135,8 +145,8 @@ public class CloudSite { this.regionId = site.getRegionId(); this.identityServiceId = site.getIdentityServiceId(); } - - + + public String getId() { return this.id; } @@ -145,6 +155,13 @@ public class CloudSite { this.id = id; } + @ResourceId + public URI getUri() {return this.uri;} + + public void setUri(URI uri) { + this.uri = uri; + } + public String getRegionId() { return regionId; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 84e4156efa..9742a0c85b 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -27,7 +27,6 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.CvnfcCustomization; -import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -291,6 +290,47 @@ public class CatalogDbClient { controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); } + public CatalogDbClient(String baseUri, String auth) { + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); + + ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { + restTemplate.getInterceptors().add((new SpringClientFilter())); + + restTemplate.getInterceptors().add((request, body, execution) -> { + + request.getHeaders().add(HttpHeaders.AUTHORIZATION, auth); + request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY); + return execution.execute(request, body); + }); + }).build().buildClientFactory(); + serviceClient = clientFactory.create(Service.class); + networkRecipeClient = clientFactory.create(NetworkRecipe.class); + networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class); + vnfResourceClient = clientFactory.create(VnfResource.class); + vnfResourceCustomizationClient = clientFactory.create(VnfResourceCustomization.class); + vnfRecipeClient = clientFactory.create(VnfRecipe.class); + orchestrationClient = clientFactory.create(OrchestrationFlow.class); + vfModuleCustomizationClient = clientFactory.create(VfModuleCustomization.class); + vfModuleClient = clientFactory.create(VfModule.class); + vnfComponentsRecipeClient = clientFactory.create(VnfComponentsRecipe.class); + northBoundRequestClient = clientFactory.create(NorthBoundRequest.class); + rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class); + buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class); + orchestrationStatusStateTransitionDirectiveClient = clientFactory + .create(OrchestrationStatusStateTransitionDirective.class); + vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class); + collectionResourceInstanceGroupCustomizationClient = clientFactory + .create(CollectionResourceInstanceGroupCustomization.class); + instanceGroupClient = clientFactory.create(InstanceGroup.class); + networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); + collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); + cloudSiteClient = clientFactory.create(CloudSite.class); + cloudifyManagerClient = clientFactory.create(CloudifyManager.class); + serviceRecipeClient = clientFactory.create(ServiceRecipe.class); + cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); + controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); + } + public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { NetworkCollectionResourceCustomization networkCollectionResourceCustomization = this.getSingleResource(networkCollectionResourceCustomizationClient, getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID)); @@ -422,11 +462,11 @@ public class CatalogDbClient { public RainyDayHandlerStatus getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( String flowName, String serviceType, String vnfType, String errorCode, String workStep) { - return this.getSingleResource(rainyDayHandlerStatusClient, UriBuilder + return this.getSingleResource(rainyDayHandlerStatusClient, getUri(UriBuilder .fromUri(findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep) .queryParam(FLOW_NAME, flowName).queryParam(SERVICE_TYPE, serviceType) .queryParam(VNF_TYPE, vnfType).queryParam(ERROR_CODE, errorCode).queryParam(WORK_STEP, workStep) - .build()); + .build().toString())); } public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action){ @@ -504,6 +544,11 @@ public class CatalogDbClient { return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id)); } + public void postCloudSite(CloudSite cloudSite){ + this.postSingleResource(cloudSiteClient, cloudSite); + } + + public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){ return this.getSingleResource(cloudSiteClient, getUri(UriBuilder .fromUri(findByClliAndCloudVersion) @@ -547,6 +592,10 @@ public class CatalogDbClient { it.forEachRemaining(list::add); return list; } + + private <T> URI postSingleResource(Client<T> client, T type){ + return client.post(type); + } public List<CvnfcCustomization> getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(String vnfCustomizationUUID, String vfModuleCustomizationUUID){ return this.getMultipleVnfcCustomizations( diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 3147c0206d..c2e6fe3961 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -394,7 +394,7 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.so-monitoring</groupId> + <groupId>org.onap.so.monitoring</groupId> <artifactId>so-monitoring-service</artifactId> <version>${project.version}</version> </dependency> @@ -724,7 +724,7 @@ <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> - <version>1.15</version> + <version>1.23</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -800,6 +800,7 @@ <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> + <version>9.4.12.v20180830</version> </dependency> <dependency> <groupId>com.h2database</groupId> diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java index 914e5d676e..a30628b1d5 100644 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java @@ -17,6 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.onap.so.montoring.configuration.rest; import java.util.concurrent.TimeUnit; |