diff options
163 files changed, 2691 insertions, 8162 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index 6346983f96..2453c18f1a 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -103,11 +103,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.onap.so</groupId> - <artifactId>cloudify-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> 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 deleted file mode 100644 index 42b77baeeb..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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. - * 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.Map; - -/* - * 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 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 + '\'' + '}'; - } - -} - 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 deleted file mode 100644 index 072bf404e7..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============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) { - if (deploymentOutputs != null) { - 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 (("install").equals(lastAction)) { - if (("terminated").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.INSTALLED; - } else if (("failed").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.FAILED; - } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.INSTALLING; - } else { - this.deploymentStatus = DeploymentStatus.UNKNOWN; - } - } else if (("uninstall").equals(lastAction)) { - if (("terminated").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.CREATED; - } else if (("failed").equals(actionStatus)) { - this.deploymentStatus = DeploymentStatus.FAILED; - } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) { - 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/beans/DeploymentStatus.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentStatus.java deleted file mode 100644 index f7d6a9d214..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.beans; - - -/* - * Enum status values to capture the state of a deployment, based on last known workflow (assume only INSTALL and - * UNINSTALL at this point). - */ -public enum DeploymentStatus { - NOTFOUND, CREATED, INSTALLED, FAILED, INSTALLING, UNINSTALLING, UNKNOWN -} - diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java deleted file mode 100644 index 95912994bc..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoBlueprintAlreadyExists.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.exceptions; - -public class MsoBlueprintAlreadyExists extends MsoCloudifyException { - - private static final long serialVersionUID = 1L; - - // Constructor to create a new MsoCloudifyException instance - public MsoBlueprintAlreadyExists(String blueprintId, String cloud) { - // Set the detailed error as the Exception 'message' - super(409, "Conflict", - "Blueprint " + blueprintId + " already exists in Cloudify Manager supporting cloud site + " + cloud); - } - -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java deleted file mode 100644 index 441bd4dc07..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyException.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.exceptions; - -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * OpenStack exception. - */ -public class MsoCloudifyException extends MsoException { - - /** - * Serialization id. - */ - private static final long serialVersionUID = 3313636124141766495L; - - private int statusCode; - private String statusMessage; - private String errorDetail; - private boolean pendingWorkflow; - - /** - * Constructor to create a new MsoOpenstackException instance - * - * @param code the error code - * @param message the error message - * @param detail error details - */ - public MsoCloudifyException(int code, String message, String detail) { - // Set the detailed error as the Exception 'message' - super(detail); - super.category = MsoExceptionCategory.OPENSTACK; - - this.statusCode = code; - this.statusMessage = message; - this.errorDetail = detail; - this.pendingWorkflow = false; - } - - /** - * Constructor to propagate the caught exception (mostly for stack trace) - * - * @param code the error code - * @param message the error message - * @param detail error details - * @param e the cause - */ - public MsoCloudifyException(int code, String message, String detail, Exception e) { - // Set the detailed error as the Exception 'message' - super(detail, e); - super.category = MsoExceptionCategory.OPENSTACK; - - this.statusCode = code; - this.statusMessage = message; - this.errorDetail = detail; - this.pendingWorkflow = false; - } - - public void setPendingWorkflow(boolean pendingWorkflow) { - this.pendingWorkflow = pendingWorkflow; - } - - @Override - public String toString() { - String error = "" + statusCode + " " + statusMessage + ": " + errorDetail - + (pendingWorkflow ? " [workflow pending]" : ""); - return error; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java deleted file mode 100644 index 99b6ade326..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeout.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.exceptions; - -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * MSO Exception when a Cloudify workflow execution times out waiting for completion. Exception includes the last known - * state of the workflow execution. - */ -public class MsoCloudifyTimeout extends MsoException { - - /** - * Serialization id. - */ - private static final long serialVersionUID = 3313636124141766495L; - - private Execution execution; - - /** - * Constructor to create a new MsoOpenstackException instance - * - * @param code the error code - * @param message the error message - * @param detail error details - */ - public MsoCloudifyTimeout(Execution execution) { - // Set the detailed error as the Exception 'message' - super("Cloudify Workflow Timeout for workflow " + execution.getWorkflowId() + " on deployment " - + execution.getDeploymentId()); - super.category = MsoExceptionCategory.OPENSTACK; - - this.execution = execution; - } - - public Execution getExecution() { - return this.execution; - } - - @Override - public String toString() { - String error = "Workflow timeout: workflow=" + execution.getWorkflowId() + ",deployment=" - + execution.getDeploymentId(); - return error; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java deleted file mode 100644 index 2251575671..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.exceptions; - -/** - * Reports an error with a Cloudify Workflow execution. - * - * @author JC1348 - * - */ -public class MsoCloudifyWorkflowException extends MsoCloudifyException { - - private static final long serialVersionUID = 1L; - - private String workflowStatus; - private boolean workflowStillRunning = false; - - // Constructor to create a new MsoCloudifyException instance - public MsoCloudifyWorkflowException(String message, String deploymentId, String workflowId, String workflowStatus) { - super(0, "Workflow Exception", - "Workflow " + workflowId + " failed on deployment " + deploymentId + ": " + message); - this.workflowStatus = workflowStatus; - if (("pending").equals(workflowStatus) || ("started").equals(workflowStatus) - || ("cancelling").equals(workflowStatus) || ("force_cancelling").equals(workflowStatus)) { - workflowStillRunning = true; - } - } - - public String getWorkflowStatus() { - return workflowStatus; - } - - public boolean isWorkflowStillRunning() { - return workflowStillRunning; - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoDeploymentAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoDeploymentAlreadyExists.java deleted file mode 100644 index 62112f4feb..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoDeploymentAlreadyExists.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.exceptions; - -public class MsoDeploymentAlreadyExists extends MsoCloudifyException { - - private static final long serialVersionUID = 1L; - - // Constructor to create a new MsoCloudifyException instance - public MsoDeploymentAlreadyExists(String deploymentId, String cloud) { - // Set the detailed error as the Exception 'message' - super(409, "Conflict", - "Deployment " + deploymentId + " already exists in Cloudify Manager suppporting cloud " + cloud); - } - -} 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 deleted file mode 100644 index 446c725e48..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ /dev/null @@ -1,1356 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.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; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -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; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduException; -import org.onap.so.adapters.vdu.VduInstance; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vdu.VduPlugin; -import org.onap.so.adapters.vdu.VduStateType; -import org.onap.so.adapters.vdu.VduStatus; -import org.onap.so.cloud.CloudConfig; -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; -import org.onap.so.cloudify.exceptions.MsoDeploymentAlreadyExists; -import org.onap.so.cloudify.v3.client.BlueprintsResource.GetBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.UploadBlueprint; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.client.DeploymentsResource.CreateDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.DeleteDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeploymentOutputs; -import org.onap.so.cloudify.v3.client.ExecutionsResource.CancelExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.GetExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.ListExecutions; -import org.onap.so.cloudify.v3.client.ExecutionsResource.StartExecution; -import org.onap.so.cloudify.v3.model.AzureConfig; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.CloudifyError; -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -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.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.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.exceptions.MsoAdapterException; -import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.onap.so.openstack.exceptions.MsoIOException; -import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.openstack.utils.MsoCommonUtils; -import org.onap.so.utils.CryptoUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { - - private static final String CLOUDIFY = "Cloudify"; - private static final String CREATE_DEPLOYMENT = "CreateDeployment"; - private static final String DELETE_DEPLOYMENT = "DeleteDeployment"; - private static final String TERMINATED = "terminated"; - private static final String CANCELLED = "cancelled"; - private static final String UNINSTALL = "uninstall"; - private static final String UPLOAD_BLUEPRINT = "UPLOAD_BLUEPRINT"; - - // Fetch cloud configuration each time (may be cached in CloudConfig class) - @Autowired - protected CloudConfig cloudConfig; - - @Autowired - private Environment environment; - - @Autowired - private PoConfig poConfig; - - private static final Logger logger = LoggerFactory.getLogger(MsoCloudifyUtils.class); - - // Properties names and variables (with default values) - protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - - protected String createPollIntervalDefault = "15"; - private String deletePollIntervalDefault = "15"; - - private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - - /** - * Create a new Deployment from a specified blueprint, and install it in the specified cloud location and tenant. - * The blueprint identifier and parameter map are passed in as arguments, along with the cloud access credentials. - * The blueprint should have been previously uploaded to Cloudify. - * - * It is expected that parameters have been validated and contain at minimum the required parameters for the given - * template with no extra (undefined) parameters.. - * - * The deployment ID supplied by the caller must be unique in the scope of the Cloudify tenant (not the Openstack - * tenant). However, it should also be globally unique, as it will be the identifier for the resource going forward - * in Inventory. This latter is managed by the higher levels invoking this function. - * - * This function executes the "install" workflow on the newly created workflow. Cloudify will be polled for - * completion unless the client requests otherwise. - * - * An error will be thrown if the requested Deployment already exists in the specified Cloudify instance. - * - * @param cloudSiteId The cloud (may be a region) in which to create the stack. - * @param tenantId The Openstack ID of the tenant in which to create the Stack - * @param deploymentId The identifier (name) of the deployment to create - * @param blueprintId The blueprint from which to create the deployment. - * @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 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. - * @throws MsoIOException Thrown on Cloudify connection errors. - */ - - public DeploymentInfo createAndInstallDeployment(String cloudSiteId, String tenantId, String deploymentId, - String blueprintId, Map<String, ? extends Object> inputs, boolean pollForCompletion, int timeoutMinutes, - boolean backout) throws MsoException { - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - logger.debug("Ready to Create Deployment ({}) with input params: {}", deploymentId, inputs); - - // Build up the inputs, including: - // - from provided "environment" file - // - passed in by caller - // - special input for cloud-specific Credentials - Map<String, Object> expandedInputs = new HashMap<>(inputs); - - String platform = cloudSite.get().getPlatform(); - if (platform == null || platform.isEmpty() || ("OPENSTACK").equalsIgnoreCase(platform)) { - // Create the Cloudify OpenstackConfig with the credentials - OpenstackConfig openstackConfig = getOpenstackConfig(cloudSite.get(), tenantId); - expandedInputs.put("openstack_config", openstackConfig); - } else if (("AZURE").equalsIgnoreCase(platform)) { - // Create Cloudify AzureConfig with the credentials - AzureConfig azureConfig = getAzureConfig(cloudSite.get(), tenantId); - expandedInputs.put("azure_config", azureConfig); - } - - // Build up the parameters to create a new deployment - CreateDeploymentParams deploymentParams = new CreateDeploymentParams(); - deploymentParams.setBlueprintId(blueprintId); - deploymentParams.setInputs(expandedInputs); - - Deployment deployment = null; - try { - CreateDeployment createDeploymentRequest = cloudify.deployments().create(deploymentId, deploymentParams); - logger.debug(createDeploymentRequest.toString()); - - deployment = executeAndRecordCloudifyRequest(createDeploymentRequest); - } catch (CloudifyResponseException e) { - // Since this came on the 'Create Deployment' command, nothing was changed - // in the cloud. Return the error as an exception. - if (e.getStatus() == 409) { - // Deployment already exists. Return a specific error for this case - MsoException me = new MsoDeploymentAlreadyExists(deploymentId, cloudSiteId); - me.addContext(CREATE_DEPLOYMENT); - throw me; - } else { - // Convert the CloudifyResponseException to an MsoException - logger.debug("ERROR STATUS = {},\n{}\n{}", e.getStatus(), e.getMessage(), e.getLocalizedMessage()); - MsoException me = cloudifyExceptionToMsoException(e, CREATE_DEPLOYMENT); - me.setCategory(MsoExceptionCategory.OPENSTACK); - throw me; - } - } catch (CloudifyConnectException e) { - // Error connecting to Cloudify instance. Convert to an MsoException - throw cloudifyExceptionToMsoException(e, CREATE_DEPLOYMENT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, CREATE_DEPLOYMENT); - } - - /* - * It can take some time for Cloudify to be ready to execute a workflow on the deployment. Sleep 30 seconds - * based on observation of behavior in a Cloudify VM instance (delay due to "create_deployment_environment"). - */ - sleep(30000); - - /* - * Next execute the "install" workflow. Note - this assumes there are no additional parameters required for the - * workflow. - */ - int createPollInterval = - Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault)); - int pollTimeout = (timeoutMinutes * 60) + createPollInterval; - - Execution installWorkflow = null; - - try { - installWorkflow = executeWorkflow(cloudify, deploymentId, "install", null, pollForCompletion, pollTimeout, - createPollInterval); - - if (installWorkflow.getStatus().equals(TERMINATED)) { - // Success! - // Create and return a DeploymentInfo structure. Include the Runtime outputs - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(installWorkflow).build(); - } else { - // The workflow completed with errors. Must try to back it out. - if (!backout) { - logger.warn("{} Deployment installation failed, backout deletion suppressed {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), - "Exception in Deployment Installation, backout suppressed"); - } else { - // Poll on delete if we rollback - use same values for now - int deletePollInterval = createPollInterval; - int deletePollTimeout = pollTimeout; - - try { - // Run the uninstall to undo the install - Execution uninstallWorkflow = executeWorkflow(cloudify, deploymentId, UNINSTALL, null, - pollForCompletion, deletePollTimeout, deletePollInterval); - - if (uninstallWorkflow.getStatus().equals(TERMINATED)) { - // The uninstall completed. Delete the deployment itself - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - executeAndRecordCloudifyRequest(deleteRequest); - } else { - // Didn't uninstall successfully. Log this error - logger.error("{} Create Deployment: Cloudify error rolling back deployment install: {} {}", - MessageEnum.RA_CREATE_STACK_ERR, installWorkflow.getError(), - ErrorCode.BusinessProcessError.getValue()); - } - } catch (Exception e) { - // Catch-all for backout errors trying to uninstall/delete - // Log this error, and return the original exception - logger.error("{} Create Stack: Nested exception rolling back deployment install: {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); - } - } - - MsoCloudifyException me = - new MsoCloudifyException(0, "Workflow Execution Failed", installWorkflow.getError()); - me.addContext(CREATE_DEPLOYMENT); - - throw me; - } - } catch (MsoException me) { - // Install failed. Unless requested otherwise, back out the deployment - - if (!backout) { - logger.warn("{} Deployment installation failed, backout deletion suppressed {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); - } else { - // Poll on delete if we rollback - use same values for now - int deletePollInterval = createPollInterval; - int deletePollTimeout = pollTimeout; - - try { - // Run the uninstall to undo the install. - // Always try to run it, as it should be idempotent - executeWorkflow(cloudify, deploymentId, UNINSTALL, null, pollForCompletion, deletePollTimeout, - deletePollInterval); - - // Delete the deployment itself - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - executeAndRecordCloudifyRequest(deleteRequest); - } catch (Exception e) { - // Catch-all for backout errors trying to uninstall/delete - // Log this error, and return the original exception - logger.error("{} Create Stack: Nested exception rolling back deployment install: {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); - } - } - - // Propagate the original exception from Stack Query. - me.addContext(CREATE_DEPLOYMENT); - - throw me; - } - } - - - /* - * Get the runtime Outputs of a deployment. Return the Map of tag/value outputs. - */ - private Optional<Map<String, Object>> getDeploymentOutputs(Cloudify cloudify, String deploymentId) - throws MsoException { - // Build and send the Cloudify request - DeploymentOutputs deploymentOutputs; - try { - GetDeploymentOutputs queryDeploymentOutputs = cloudify.deployments().outputsById(deploymentId); - logger.debug(queryDeploymentOutputs.toString()); - - deploymentOutputs = executeAndRecordCloudifyRequest(queryDeploymentOutputs); - if (deploymentOutputs != null) { - return Optional.ofNullable(deploymentOutputs.getOutputs()); - } else { - return Optional.empty(); - } - } catch (CloudifyConnectException ce) { - // Couldn't connect to Cloudify - logger.error("{} QueryDeploymentOutputs: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), ce); - throw new MsoIOException(ce.getMessage(), ce); - } catch (CloudifyResponseException re) { - if (re.getStatus() == 404) { - // No Outputs - return Optional.empty(); - } - throw new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); - } catch (Exception e) { - // Catch-all - throw new MsoAdapterException(e.getMessage(), e); - } - } - - /* - * Execute a workflow on a deployment. Handle polling for completion with timeout. Return the final Execution object - * with status. Throw an exception on Errors. Question - how does the client know whether rollback needs to be done? - */ - private Execution executeWorkflow(Cloudify cloudify, String deploymentId, String workflowId, - Map<String, Object> workflowParams, boolean pollForCompletion, int timeout, int pollInterval) - throws MsoCloudifyException { - logger.debug("Executing '{}' workflow on deployment '{}'", workflowId, deploymentId); - - StartExecutionParams executeParams = new StartExecutionParams(); - executeParams.setWorkflowId(workflowId); - executeParams.setDeploymentId(deploymentId); - executeParams.setParameters(workflowParams); - - Execution execution = null; - String executionId = null; - String command = "start"; - Exception savedException = null; - - try { - StartExecution executionRequest = cloudify.executions().start(executeParams); - logger.debug(executionRequest.toString()); - execution = executeAndRecordCloudifyRequest(executionRequest); - executionId = execution.getId(); - - if (!pollForCompletion) { - // Client did not request polling, so just return the Execution object - return execution; - } - - // Enter polling loop - boolean timedOut = false; - int pollTimeout = timeout; - - String status = execution.getStatus(); - - // Create a reusable cloudify query request - GetExecution queryExecution = cloudify.executions().byId(executionId); - command = "query"; - - while (!timedOut && !(status.equals(TERMINATED) || ("failed").equals(status) || status.equals(CANCELLED))) { - // workflow is still running; check for timeout - if (pollTimeout <= 0) { - logger.debug("workflow {} timed out on deployment {}", execution.getWorkflowId(), - execution.getDeploymentId()); - timedOut = true; - continue; - } - - sleep(pollInterval * 1000L); - - pollTimeout -= pollInterval; - logger.debug("pollTimeout remaining: " + pollTimeout); - - execution = queryExecution.execute(); - if (execution != null) { - status = execution.getStatus(); - } else { - status = TERMINATED; - } - } - - // Broke the loop. Check again for a terminal state - if (status.equals(TERMINATED)) { - // Success! - logger.debug("Workflow '{}' completed successfully on deployment '{}'", workflowId, deploymentId); - return execution; - } else if (("failed").equals(status)) { - // Workflow failed. Log it and return the execution object (don't throw exception here) - logger.error("{} Cloudify workflow failure: {} {} Execute Workflow: Failed: {}", - MessageEnum.RA_CREATE_STACK_ERR, execution.getError(), - ErrorCode.BusinessProcessError.getValue(), execution.getError()); - return execution; - } else if (status.equals(CANCELLED)) { - // Workflow was cancelled, leaving the deployment in an indeterminate state. Log it and return the - // execution object (don't throw exception here) - logger.error("{} Cloudify workflow cancelled. Deployment is in an indeterminate state {} {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), - "Execute Workflow cancelled: ", workflowId); - return execution; - } else { - // Can only get here after a timeout - logger.error("{} Cloudify workflow timeout {} Execute Workflow: Timed Out", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); - } - } catch (CloudifyConnectException ce) { - logger.error("{} {} Execute Workflow ({} {}): Cloudify connection failure {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), command, ce); - savedException = ce; - } catch (CloudifyResponseException re) { - logger.error("{} {} Execute Workflow ({}): Cloudify response error {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), command, re.getMessage(), re); - savedException = re; - } catch (RuntimeException e) { - // Catch-all - logger.error("{} {} Execute Workflow ({}): Internal error {}", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), command, e.getMessage(), e); - savedException = e; - } - - // Get to this point ONLY on an error or timeout - // The cloudify execution is still running (we've not received a terminal status), - // so try to Cancel it. - CancelExecutionParams cancelParams = new CancelExecutionParams(); - cancelParams.setAction("cancel"); - // TODO: Use force_cancel? - - Execution cancelExecution = null; - - try { - CancelExecution cancelRequest = cloudify.executions().cancel(executionId, cancelParams); - logger.debug(cancelRequest.toString()); - cancelExecution = cancelRequest.execute(); - - // Enter polling loop - boolean timedOut = false; - int cancelTimeout = timeout; // TODO: For now, just use same timeout - - String status = null; - if (cancelExecution != null) { - status = cancelExecution.getStatus(); - } - // Poll for completion. Create a reusable cloudify query request - GetExecution queryExecution = cloudify.executions().byId(executionId); - - while (!timedOut && !CANCELLED.equals(status)) { - // workflow is still running; check for timeout - if (cancelTimeout <= 0) { - logger.debug("Cancel timeout for workflow {} on deployment {}", workflowId, deploymentId); - timedOut = true; - continue; - } - - sleep(pollInterval * 1000L); - - cancelTimeout -= pollInterval; - logger.debug("pollTimeout remaining: {}", cancelTimeout); - - execution = queryExecution.execute(); - if (execution != null) { - status = execution.getStatus(); - } - } - - // Broke the loop. Check again for a terminal state - if (CANCELLED.equals(status)) { - // Finished cancelling. Return the original exception - logger.debug("Cancel workflow {} completed on deployment {}", workflowId, deploymentId); - throw new MsoCloudifyException(-1, "", "", savedException); - } else { - // Can only get here after a timeout - logger.debug("Cancel workflow {} timeout out on deployment {}", workflowId, deploymentId); - MsoCloudifyException exception = new MsoCloudifyException(-1, "", "", savedException); - exception.setPendingWorkflow(true); - throw exception; - } - } catch (Exception e) { - // Catch-all. Log the message and throw the original exception - logger.debug("Cancel workflow {} failed for deployment {} :", workflowId, deploymentId, e); - MsoCloudifyException exception = new MsoCloudifyException(-1, "", "", savedException); - exception.setPendingWorkflow(true); - throw exception; - } - } - - - - /** - * Query for a Cloudify Deployment (by Name). This call will always return a DeploymentInfo object. If the - * deployment does not exist, an "empty" DeploymentInfo will be returned - containing only the deployment ID and a - * special status of NOTFOUND. - * - * @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 - * @return A StackInfo object - * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. - */ - public DeploymentInfo queryDeployment(String cloudSiteId, String tenantId, String deploymentId) - throws MsoException { - logger.debug("Query Cloudify Deployment: {} in tenant {}", deploymentId, tenantId); - - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - // Build and send the Cloudify request - Deployment deployment = new Deployment(); - try { - GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId); - logger.debug(queryDeployment.toString()); - deployment = executeAndRecordCloudifyRequest(queryDeployment); - - // Next look for the latest execution - ListExecutions listExecutions = - cloudify.executions().listFiltered("deployment_id=" + deploymentId, "-created_at"); - Executions executions = listExecutions.execute(); - - // If no executions, does this give NOT_FOUND or empty set? - if (executions == null || executions.getItems().isEmpty()) { - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()).build(); - } else { - return new DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(executions.getItems().get(0)).build(); - } - } catch (CloudifyConnectException ce) { - // Couldn't connect to Cloudify - logger.error("{} QueryDeployment: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcessError.getValue(), ce); - throw new MsoIOException(ce.getMessage(), ce); - } catch (CloudifyResponseException re) { - if (re.getStatus() == 404) { - // 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 DeploymentInfoBuilder().withId(deployment.getId()) - .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()).build(); - } else { - // Deployment not found. Default status of a DeploymentInfo object is NOTFOUND - return new DeploymentInfoBuilder().withId(deploymentId).build(); - } - } - throw new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); - } catch (Exception e) { - // Catch-all - throw new MsoAdapterException(e.getMessage(), e); - } - } - - - /** - * Delete a Cloudify deployment (by ID). If the deployment is not found, it will be considered a successful - * deletion. The return value is a DeploymentInfo object which contains the last deployment status. - * - * There is no rollback from a successful deletion. A deletion failure will also result in an undefined deployment - * state - the components may or may not have been all or partially deleted, so the resulting deployment must be - * considered invalid. - * - * @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. - * @return A StackInfo object - * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. - * @throws MsoCloudSiteNotFound - */ - public DeploymentInfo uninstallAndDeleteDeployment(String cloudSiteId, String tenantId, String deploymentId, - int timeoutMinutes) throws MsoException { - // Obtain the cloud site information where we will create the stack - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - logger.debug("Ready to Uninstall/Delete Deployment ({})", deploymentId); - - // Query first to save the trouble if deployment not found - try { - GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId); - logger.debug(queryDeploymentRequest.toString()); - - // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); - } catch (CloudifyResponseException e) { - // Since this came on the 'Create Deployment' command, nothing was changed - // in the cloud. Return the error as an exception. - if (e.getStatus() == 404) { - // 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 DeploymentInfoBuilder().withId(deploymentId).withStatus(DeploymentStatus.NOTFOUND).build(); - } else { - // Convert the CloudifyResponseException to an MsoOpenstackException - logger.debug("ERROR STATUS = {}, \n {}\n {}\n {}", e.getStatus(), e.getMessage(), - e.getLocalizedMessage(), e); - MsoException me = cloudifyExceptionToMsoException(e, DELETE_DEPLOYMENT); - me.setCategory(MsoExceptionCategory.INTERNAL); - throw me; - } - } catch (CloudifyConnectException e) { - // Error connecting to Cloudify instance. Convert to an MsoException - throw cloudifyExceptionToMsoException(e, DELETE_DEPLOYMENT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, DELETE_DEPLOYMENT); - } - - /* - * Query the outputs before deleting so they can be returned as well - */ - // DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); - - /* - * Next execute the "uninstall" workflow. Note - this assumes there are no additional parameters required for - * the workflow. - */ - // TODO: No deletePollInterval that I'm aware of. Use the create interval - int deletePollInterval = - Integer.parseInt(this.environment.getProperty(deletePollIntervalProp, deletePollIntervalDefault)); - int pollTimeout = (timeoutMinutes * 60) + deletePollInterval; - - Execution uninstallWorkflow = null; - - try { - uninstallWorkflow = - executeWorkflow(cloudify, deploymentId, UNINSTALL, null, true, pollTimeout, deletePollInterval); - - if (uninstallWorkflow.getStatus().equals(TERMINATED)) { - // Successful uninstall. - logger.debug("Uninstall successful for deployment {}", deploymentId); - } else { - // The uninstall workflow completed with an error. Must fail the request, but will - // leave the deployment in an indeterminate state, as cloud resources may still exist. - MsoCloudifyException me = - new MsoCloudifyException(0, "Uninstall Workflow Failed", uninstallWorkflow.getError()); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } - } catch (MsoException me) { - // Uninstall workflow has failed. - // Must fail the deletion... may leave the deployment in an inconclusive state - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } - - // At this point, the deployment has been successfully uninstalled. - // Next step is to delete the deployment itself - Deployment deployment; - try { - DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); - logger.debug(deleteRequest.toString()); - - // The delete request returns the deleted deployment - deployment = deleteRequest.execute(); - - } catch (CloudifyConnectException ce) { - // Failed to delete. Must fail the request, but will leave the (uninstalled) - // deployment in Cloudify DB. - MsoCloudifyException me = new MsoCloudifyException(0, "Deployment Delete Failed", ce.getMessage(), ce); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } catch (CloudifyResponseException re) { - // Failed to delete. Must fail the request, but will leave the (uninstalled) - // deployment in the Cloudify DB. - MsoCloudifyException me = new MsoCloudifyException(re.getStatus(), re.getMessage(), re.getMessage(), re); - me.addContext(DELETE_DEPLOYMENT); - - throw me; - } catch (Exception e) { - // Catch-all - MsoAdapterException ae = new MsoAdapterException(e.getMessage(), e); - ae.addContext(DELETE_DEPLOYMENT); - - throw ae; - } - - // Return the deleted deployment info (with runtime outputs) along with the completed uninstall workflow status - return new DeploymentInfoBuilder().withId(deployment.getId()).withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) - .fromExecution(uninstallWorkflow).build(); - } - - - /** - * Check if a blueprint is available for use at a targeted cloud site. This requires checking the Cloudify Manager - * which is servicing that cloud site to see if the specified blueprint has been loaded. - * - * @param cloudSiteId The cloud site where the blueprint is needed - * @param blueprintId The ID for the blueprint in Cloudify - */ - public boolean isBlueprintLoaded(String cloudSiteId, String blueprintId) throws MsoException { - // Obtain the cloud site information where we will load the blueprint - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId); - try { - Blueprint bp = getRequest.execute(); - if (bp != null) { - logger.debug("Blueprint exists: {}", bp.getId()); - return true; - } else { - logger.debug("Null blueprint!"); - return false; - } - } catch (CloudifyResponseException ce) { - if (ce.getStatus() == 404) { - return false; - } else { - throw ce; - } - } - } - - /** - * Upload a blueprint to the Cloudify Manager that is servicing a Cloud Site. The blueprint currently must be - * structured as a single directory with all of the required files. One of those files is designated the "main file" - * for the blueprint. Files are provided as byte arrays, though expect only text files will be distributed from ASDC - * and stored by MSO. - * - * Cloudify requires a single root directory in its blueprint zip files. The requested blueprint ID will also be - * used as the directory. All of the files will be added to this directory in the zip file. - */ - public void uploadBlueprint(String cloudSiteId, String blueprintId, String mainFileName, - Map<String, byte[]> blueprintFiles, boolean failIfExists) throws MsoException { - // Obtain the cloud site information where we will load the blueprint - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSite.isPresent()) { - throw new MsoCloudSiteNotFound(cloudSiteId); - } - - Cloudify cloudify = getCloudifyClient(cloudSite.get()); - - boolean blueprintUploaded = uploadBlueprint(cloudify, blueprintId, mainFileName, blueprintFiles); - - if (!blueprintUploaded && failIfExists) { - throw new MsoAdapterException("Blueprint already exists"); - } - } - - /* - * Common method to load a blueprint. May be called from - */ - protected boolean uploadBlueprint(Cloudify cloudify, String blueprintId, String mainFileName, - Map<String, byte[]> blueprintFiles) throws MsoException { - // Check if it already exists. If so, return false. - GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId); - try { - Blueprint bp = getRequest.execute(); - if (bp != null) { - logger.debug("Blueprint {} already exists.", bp.getId()); - return false; - } else { - logger.debug("Null blueprint!"); - } - } catch (CloudifyResponseException ce) { - if (ce.getStatus() == 404) { - // This is the expected result. - logger.debug("Verified that Blueprint doesn't exist yet"); - } else { - throw ce; - } - } - - // Create a blueprint ZIP file in memory - ByteArrayOutputStream zipBuffer = new ByteArrayOutputStream(); - ZipOutputStream zipOut = new ZipOutputStream(zipBuffer); - - try { - // Put the root directory - String rootDir = blueprintId + (blueprintId.endsWith("/") ? "" : "/"); - zipOut.putNextEntry(new ZipEntry(rootDir)); - zipOut.closeEntry(); - - for (String fileName : blueprintFiles.keySet()) { - ZipEntry ze = new ZipEntry(rootDir + fileName); - zipOut.putNextEntry(ze); - zipOut.write(blueprintFiles.get(fileName)); - zipOut.closeEntry(); - } - zipOut.close(); - } catch (IOException e) { - // Since we're writing to a byte array, this should never happen - } - logger.debug("Blueprint zip file size: {}", zipBuffer.size()); - - // Ready to upload the blueprint zip - - try (InputStream blueprintStream = new ByteArrayInputStream(zipBuffer.toByteArray())) { - UploadBlueprint uploadRequest = - cloudify.blueprints().uploadFromStream(blueprintId, mainFileName, blueprintStream); - Blueprint blueprint = uploadRequest.execute(); - logger.debug("Successfully uploaded blueprint {}", blueprint.getId()); - } catch (CloudifyResponseException | CloudifyConnectException e) { - throw cloudifyExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } catch (RuntimeException e) { - // Catch-all - throw runtimeExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } catch (IOException e) { - // for try-with-resources - throw ioExceptionToMsoException(e, UPLOAD_BLUEPRINT); - } - - return true; - } - - - - // --------------------------------------------------------------- - // PRIVATE FUNCTIONS FOR USE WITHIN THIS CLASS - - /** - * Get a Cloudify client for the specified cloud site. Everything that is required can be found in the Cloud Config. - * - * @param cloudSite - * @return a Cloudify object - */ - public Cloudify getCloudifyClient(CloudSite cloudSite) throws MsoException { - CloudifyManager cloudifyConfig = cloudConfig.getCloudifyManager(cloudSite.getCloudifyId()); - if (cloudifyConfig == null) { - throw new MsoCloudifyManagerNotFound(cloudSite.getId()); - } - - // Get a Cloudify client - // Set a Token Provider to fetch tokens from Cloudify itself. - String cloudifyUrl = cloudifyConfig.getCloudifyUrl(); - Cloudify cloudify = new Cloudify(cloudifyUrl); - cloudify.setTokenProvider(new CloudifyClientTokenProvider(cloudifyUrl, cloudifyConfig.getUsername(), - CryptoUtils.decryptCloudConfigPassword(cloudifyConfig.getPassword()))); - - return cloudify; - } - - - /* - * Query for a Cloudify Deployment. This function is needed in several places, so a common method is useful. This - * method takes an authenticated CloudifyClient (which internally identifies the cloud & tenant to search), and - * returns a Deployment object if found, Null if not found, or an MsoCloudifyException if the Cloudify API call - * fails. - * - * @param cloudifyClient an authenticated Cloudify client - * - * @param deploymentId the deployment to query - * - * @return a Deployment object or null if the requested deployment doesn't exist. - * - * @throws MsoCloudifyException Thrown if the Cloudify API call returns an exception - */ - protected Deployment queryDeployment(Cloudify cloudify, String deploymentId) throws MsoException { - if (deploymentId == null) { - return null; - } - try { - GetDeployment request = cloudify.deployments().byId(deploymentId); - return executeAndRecordCloudifyRequest(request); - } catch (CloudifyResponseException e) { - if (e.getStatus() == 404) { - logger.debug("queryDeployment - not found: {}", deploymentId); - return null; - } else { - // Convert the CloudifyResponseException to an MsoCloudifyException - throw cloudifyExceptionToMsoException(e, "QueryDeployment"); - } - } catch (CloudifyConnectException e) { - // Connection to Openstack failed - throw cloudifyExceptionToMsoException(e, "QueryDeployment"); - } - } - - - public void copyStringOutputsToInputs(Map<String, String> inputs, Map<String, Object> otherStackOutputs, - boolean overWrite) { - if (inputs == null || otherStackOutputs == null) - return; - - for (Map.Entry<String, Object> entry : otherStackOutputs.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - - if (value instanceof JsonNode) { - // This is a bit of mess - but I think it's the least impacting - // let's convert it BACK to a string - then it will get converted back later - try { - inputs.put(key, this.convertNode((JsonNode) value)); - } catch (Exception e) { - logger.debug("WARNING: unable to convert JsonNode output value for {}", key); - // effect here is this value will not have been copied to the inputs - and therefore will error out - // downstream - } - } else if (value instanceof java.util.LinkedHashMap) { - logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); - try { - inputs.put(key, JSON_MAPPER.writeValueAsString(value)); - } catch (Exception e) { - logger.debug("WARNING: unable to convert LinkedHashMap output value for {}", key); - } - } else { - // just try to cast it - could be an integer or some such - try { - inputs.put(key, (String) value); - } catch (Exception e) { - logger.debug("WARNING: unable to convert output value for {}", key); - // effect here is this value will not have been copied to the inputs - and therefore will error out - // downstream - } - } - } - return; - } - - /* - * Normalize an input value to an Object, based on the target parameter type. If the type is not recognized, it will - * just be returned unchanged (as a string). - */ - public Object convertInputValue(Object inputValue, HeatTemplateParam templateParam) { - String type = templateParam.getParamType(); - logger.debug("Parameter: {} is of type {}", templateParam.getParamName(), type); - - if (("number").equalsIgnoreCase(type)) { - try { - return Integer.valueOf(inputValue.toString()); - } catch (Exception e) { - logger.debug("Unable to convert {} to an integer!", inputValue); - return null; - } - } else if (("json").equalsIgnoreCase(type)) { - try { - if (inputValue instanceof String) { - return JSON_MAPPER.readTree(inputValue.toString()); - } - // will already marshal to json without intervention - return inputValue; - } catch (Exception e) { - logger.debug("Unable to convert {} to a JsonNode!", inputValue); - return null; - } - } else if (("boolean").equalsIgnoreCase(type)) { - return Boolean.valueOf(inputValue.toString()); - } - - // Nothing else matched. Return the original string - return inputValue; - } - - - private String convertNode(final JsonNode node) { - try { - final Object obj = JSON_MAPPER.treeToValue(node, Object.class); - return JSON_MAPPER.writeValueAsString(obj); - } catch (JsonParseException jpe) { - logger.debug("Error converting json to string {}", jpe); - } catch (Exception e) { - logger.debug("Error converting json to string {}", e); - } - return "[Error converting json to string]"; - } - - - /* - * Method to execute a Cloudify command and track its execution time. For the metrics log, a category of "Cloudify" - * is used along with a sub-category that identifies the specific call (using the real cloudify-client classname of - * the CloudifyRequest<T> parameter). - */ - - - protected <T> T executeAndRecordCloudifyRequest(CloudifyRequest<T> request) { - - String requestType; - if (request.getClass().getEnclosingClass() != null) { - requestType = - request.getClass().getEnclosingClass().getSimpleName() + "." + request.getClass().getSimpleName(); - } else { - requestType = request.getClass().getSimpleName(); - } - - int retryDelay = poConfig.getRetryDelay(); - int retryCount = poConfig.getRetryCount(); - String retryCodes = poConfig.getRetryCodes(); - - // Run the actual command. All exceptions will be propagated - while (true) { - try { - return request.execute(); - } catch (CloudifyResponseException e) { - boolean retry = false; - if (retryCodes != null) { - int code = e.getStatus(); - logger.debug("Config values RetryDelay: {} RetryCount:{} RetryCodes:{} ResponseCode:{}", retryDelay, - retryCount, retryCodes, code); - for (String rCode : retryCodes.split(",")) { - try { - if (retryCount > 0 && code == Integer.parseInt(rCode)) { - retryCount--; - retry = true; - logger.debug( - "CloudifyResponseException ResponseCode:{} request:{} Retry indicated. Attempts remaining:{}", - code, requestType, retryCount); - break; - } - } catch (NumberFormatException e1) { - logger.error("{} No retries. Exception in parsing retry code in config:{} {}", - MessageEnum.RA_CONFIG_EXC, rCode, ErrorCode.SchemaError.getValue()); - throw e; - } - } - } - if (retry) { - sleep(retryDelay * 1000L); - } else - throw e; // exceeded retryCount or code is not retryable - } catch (CloudifyConnectException e) { - // Connection to Cloudify failed - if (retryCount > 0) { - retryCount--; - logger.debug(" request: {} Retry indicated. Attempts remaining:{}", requestType, retryCount); - sleep(retryDelay * 1000L); - } else - throw e; - - } - } - } - - /* - * Convert an Exception on a Cloudify call to an MsoCloudifyException. This method supports - * CloudifyResponseException and CloudifyConnectException. - */ - protected MsoException cloudifyExceptionToMsoException(CloudifyBaseException e, String context) { - MsoException me = null; - - if (e instanceof CloudifyResponseException) { - CloudifyResponseException re = (CloudifyResponseException) e; - - try { - // Failed Cloudify calls return an error entity body. - CloudifyError error = re.getResponse().getErrorEntity(CloudifyError.class); - logger.error("{} {} {} Exception - Cloudify Error on {}: {}", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, ErrorCode.DataError.getValue(), context, error.getErrorCode()); - String fullError = error.getErrorCode() + ": " + error.getMessage(); - logger.debug(fullError); - me = new MsoCloudifyException(re.getStatus(), re.getMessage(), fullError); - } catch (Exception e2) { - // Couldn't parse the body as a "CloudifyError". Report the original HTTP error. - logger.error("{} {} {} Exception - HTTP Error on {}: {}, {} ", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); - me = new MsoCloudifyException(re.getStatus(), re.getMessage(), ""); - } - - // Add the context of the error - me.addContext(context); - - // Generate an alarm for 5XX and higher errors. - if (re.getStatus() >= 500) { - - } - } else if (e instanceof CloudifyConnectException) { - CloudifyConnectException ce = (CloudifyConnectException) e; - - me = new MsoIOException(ce.getMessage()); - me.addContext(context); - - // Generate an alarm for all connection errors. - - logger.error("{} {} {} Cloudify connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, CLOUDIFY, - ErrorCode.DataError.getValue(), context, e); - } - - return me; - } - - - - /******************************************************************************* - * - * Methods (and associated utilities) to implement the VduPlugin interface - * - *******************************************************************************/ - - /** - * VduPlugin interface for instantiate function. - * - * This one is a bit more complex, in that it will first upload the blueprint if needed, then create the Cloudify - * deployment and execute the install workflow. - * - * This implementation also merges any parameters defined in the ENV file with the other other input parameters for - * any undefined parameters). The basic MsoCloudifyUtils separates blueprint management from deploument actions, but - * the VduPlugin does not declare blueprint management operations. - */ - @Override - public VduInstance instantiateVdu(CloudInfo cloudInfo, String instanceName, Map<String, Object> inputs, - VduModelInfo vduModel, boolean rollbackOnFailure) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - // Translate the VDU ModelInformation structure to that which is needed for - // creating and uploading a blueprint. Use the model customization UUID as - // the blueprint identifier. - - String blueprintId = vduModel.getModelCustomizationUUID(); - - try { - - if (!isBlueprintLoaded(cloudSiteId, blueprintId)) { - logger.debug("Blueprint {} is not loaded. Will upload it now.", blueprintId); - - // Prepare the blueprint inputs. Need the set of blueprint templates and files, - // plus the main blueprint name. - Map<String, byte[]> blueprintFiles = new HashMap<>(); - String mainTemplate = ""; - - // Add all of the blueprint artifacts from the VDU model - List<VduArtifact> vduArtifacts = vduModel.getArtifacts(); - for (VduArtifact vduArtifact : vduArtifacts) { - // Add all artifacts to the blueprint, with one exception. - // ENVIRONMENT files will be processed later as additional parameters. - - ArtifactType artifactType = vduArtifact.getType(); - if (artifactType != ArtifactType.ENVIRONMENT) { - blueprintFiles.put(vduArtifact.getName(), vduArtifact.getContent()); - - if (artifactType == ArtifactType.MAIN_TEMPLATE) { - mainTemplate = vduArtifact.getName(); - } - } - } - - // Upload the blueprint package - uploadBlueprint(cloudSiteId, blueprintId, mainTemplate, blueprintFiles, false); - } - } catch (Exception e) { - throw new VduException("CloudifyUtils (instantiateVDU): blueprint Exception", e); - } - - - // Next, create and install a new deployment based on the blueprint. - // For Cloudify, the deploymentId is specified by the client. Just use the instance name - // as the ID. - - try { - // Query the Cloudify Deployment object and populate a VduInstance - DeploymentInfo deployment = - createAndInstallDeployment(cloudSiteId, tenantId, instanceName, blueprintId, inputs, true, // (poll - // for - // completion) - vduModel.getTimeoutMinutes(), rollbackOnFailure); - - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("CloudifyUtils (instantiateVDU): Create-and-install-deployment Exception", e); - } - } - - - /** - * VduPlugin interface for query function. - */ - @Override - public VduInstance queryVdu(CloudInfo cloudInfo, String instanceId) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - try { - // Query the Cloudify Deployment object and populate a VduInstance - DeploymentInfo deployment = queryDeployment(cloudSiteId, tenantId, instanceId); - - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("Query VDU Exception", e); - } - } - - - /** - * VduPlugin interface for delete function. - */ - @Override - public VduInstance deleteVdu(CloudInfo cloudInfo, String instanceId, int timeoutMinutes) throws VduException { - String cloudSiteId = cloudInfo.getCloudSiteId(); - String tenantId = cloudInfo.getTenantId(); - - try { - // Uninstall and delete the Cloudify Deployment - DeploymentInfo deployment = uninstallAndDeleteDeployment(cloudSiteId, tenantId, instanceId, timeoutMinutes); - - // Populate a VduInstance based on the deleted Cloudify Deployment object - return deploymentInfoToVduInstance(deployment); - } catch (Exception e) { - throw new VduException("Delete VDU Exception", e); - } - } - - - /** - * VduPlugin interface for update function. - * - * Update is currently not supported in the MsoCloudifyUtils implementation. Just return a VduException. - * - */ - @Override - public VduInstance updateVdu(CloudInfo cloudInfo, String instanceId, Map<String, Object> inputs, - VduModelInfo vduModel, boolean rollbackOnFailure) throws VduException { - throw new VduException("CloudifyUtils: updateVDU interface not supported"); - } - - - /* - * Convert the local DeploymentInfo object (Cloudify-specific) to a generic VduInstance object - */ - protected VduInstance deploymentInfoToVduInstance(DeploymentInfo deployment) { - VduInstance vduInstance = new VduInstance(); - - // only one ID in Cloudify, use for both VDU name and ID - vduInstance.setVduInstanceId(deployment.getId()); - vduInstance.setVduInstanceName(deployment.getId()); - - // Copy inputs and outputs - vduInstance.setInputs(deployment.getInputs()); - vduInstance.setOutputs(deployment.getOutputs()); - - // Translate the status elements - vduInstance.setStatus(deploymentStatusToVduStatus(deployment)); - - return vduInstance; - } - - protected VduStatus deploymentStatusToVduStatus(DeploymentInfo deployment) { - VduStatus vduStatus = new VduStatus(); - - // Determine the status based on last action & status - // DeploymentInfo object should be enhanced to report a better status internally. - DeploymentStatus status = deployment.getStatus(); - - if (status == null) { - vduStatus.setState(VduStateType.UNKNOWN); - } else if (status == DeploymentStatus.NOTFOUND) { - vduStatus.setState(VduStateType.NOTFOUND); - } else if (status == DeploymentStatus.INSTALLED) { - vduStatus.setState(VduStateType.INSTANTIATED); - } else if (status == DeploymentStatus.CREATED) { - // Deployment exists but is not installed. This shouldn't really happen, - // since create + install or uninstall + delete are always done together. - // But account for it anyway, assuming the operation is still in progress. - String lastAction = deployment.getLastAction(); - if (lastAction == null) - vduStatus.setState(VduStateType.INSTANTIATING); - else - vduStatus.setState(VduStateType.DELETING); - } else if (status == DeploymentStatus.FAILED) { - vduStatus.setState(VduStateType.FAILED); - } else { - vduStatus.setState(VduStateType.UNKNOWN); - } - - vduStatus.setErrorMessage(deployment.getErrorMessage()); - vduStatus.setLastAction(new PluginAction(deployment.getLastAction(), deployment.getActionStatus(), - deployment.getErrorMessage())); - - return vduStatus; - } - - /* - * Return an OpenstackConfig object as expected by Cloudify Openstack Plug-in. Base the values on the CloudSite - * definition. - */ - protected OpenstackConfig getOpenstackConfig(CloudSite cloudSite, String tenantId) { - OpenstackConfig openstackConfig = new OpenstackConfig(); - openstackConfig.setRegion(cloudSite.getRegionId()); - openstackConfig.setAuthUrl(cloudSite.getIdentityService().getIdentityUrl()); - openstackConfig.setUsername(cloudSite.getIdentityService().getMsoId()); - openstackConfig - .setPassword(CryptoUtils.decryptCloudConfigPassword(cloudSite.getIdentityService().getMsoPass())); - openstackConfig.setTenantName(tenantId); - return openstackConfig; - } - - /* - * Return an Azure object as expected by Cloudify Azure Plug-in. Base the values on the CloudSite definition. - */ - protected AzureConfig getAzureConfig(CloudSite cloudSite, String tenantId) { - AzureConfig azureConfig = new AzureConfig(); - // TODO: Use adminTenant for now, instead of adding another element - azureConfig.setSubscriptionId(cloudSite.getIdentityService().getAdminTenant()); - azureConfig.setTenantId(tenantId); - azureConfig.setClientId(cloudSite.getIdentityService().getMsoId()); - azureConfig.setClientSecret(cloudSite.getIdentityService().getMsoPass()); - return azureConfig; - } - - private void sleep(long time) { - try { - Thread.sleep(time); - } catch (InterruptedException e) { - logger.debug("Thread interrupted while sleeping!", e); - Thread.currentThread().interrupt(); - } - } -} 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 index 16671bbe50..6eb7e3d56d 100644 --- 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 @@ -22,11 +22,11 @@ package org.onap.so.openstack.utils; import java.io.Serializable; import java.util.List; +import org.apache.commons.lang3.builder.ToStringBuilder; 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"}) 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 index 1f55aa92a2..f9a8093de6 100644 --- 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 @@ -21,11 +21,11 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; 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) 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 index 9fa4557a45..dcc4f50b45 100644 --- 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 @@ -21,13 +21,13 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) 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 index c575304ade..ba5e449034 100644 --- 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 @@ -21,12 +21,12 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; 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 com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"template_type", "workload_id", "workload_status", "workload_status_reason"}) 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 index 95dd48caa6..d679b0303e 100644 --- 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 @@ -21,12 +21,12 @@ package org.onap.so.openstack.utils; import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonNode; import com.woorea.openstack.heat.model.CreateStackParam; -import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"generic-vnf-id", "vf-module-id", "vf-module-model-invariant-id", "vf-module-model-version-id", 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 deleted file mode 100644 index 9fbb45a2c3..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * ============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); - } - - @Test - public void shouldSetEmptyOutputsMapWhenInputIsNull() { - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withDeploymentOutputs(null).build(); - assertThat(deploymentInfo.getOutputs()).isEmpty(); - } - - 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); - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java deleted file mode 100644 index 1506fda817..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyExceptionTest.java +++ /dev/null @@ -1,34 +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.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyExceptionTest { - - @Test - public void test() { - Exception e = null; - boolean pendingWorkflow = true; - MsoCloudifyException mce = new MsoCloudifyException(200, "message", "detail"); - MsoCloudifyException mcl = new MsoCloudifyException(200, "message", "detail", e); - mce.setPendingWorkflow(pendingWorkflow); - assert (mcl.toString() != null); - assertNotNull(mce); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java deleted file mode 100644 index 25dcae3c2c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTest.java +++ /dev/null @@ -1,30 +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.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyTest { - - @Test - public void test() { - MsoBlueprintAlreadyExists mbae = new MsoBlueprintAlreadyExists("blueprintId", "cloud"); - MsoCloudifyManagerNotFound mcm = new MsoCloudifyManagerNotFound("cloudSiteId"); - MsoDeploymentAlreadyExists mdae = new MsoDeploymentAlreadyExists("deploymentId", "cloud"); - assertNotNull((mbae)); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java deleted file mode 100644 index dc74d83d04..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyTimeoutTest.java +++ /dev/null @@ -1,33 +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.exceptions; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import org.junit.Test; -import org.onap.so.cloudify.v3.model.Execution; - -public class MsoCloudifyTimeoutTest { - - @Test - public void test() { - Execution execution = mock(Execution.class); - MsoCloudifyTimeout mct = new MsoCloudifyTimeout(execution); - mct.getExecution(); - assert (mct.toString() != null); - assertNotNull(mct); - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java deleted file mode 100644 index b8b2c97a65..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowExceptionTest.java +++ /dev/null @@ -1,31 +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.exceptions; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class MsoCloudifyWorkflowExceptionTest { - - @Test - public void test() { - MsoCloudifyWorkflowException mcw = - new MsoCloudifyWorkflowException("message", "id", "workflowId", "workflowStatus"); - mcw.getWorkflowStatus(); - assertFalse(mcw.isWorkflowStillRunning()); - - } - -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java deleted file mode 100644 index d14115971c..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java +++ /dev/null @@ -1,336 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.cloudify.utils; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.so.adapters.vdu.CloudInfo; -import org.onap.so.adapters.vdu.PluginAction; -import org.onap.so.adapters.vdu.VduArtifact; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduInstance; -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.DeploymentInfo; -import org.onap.so.cloudify.beans.DeploymentInfoBuilder; -import org.onap.so.cloudify.beans.DeploymentStatus; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.model.AzureConfig; -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.HeatTemplateParam; -import org.onap.so.openstack.exceptions.MsoAdapterException; -import org.onap.so.openstack.exceptions.MsoException; -import org.skyscreamer.jsonassert.JSONAssert; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class MsoCloudifyUtilsTest { - - private static final String CLOUD_SITE_ID = "cloudSiteIdTest"; - private static final String BLUEPRINT_ID = "bluePrintIdTest"; - private static final String FILE_NAME = "fileName"; - - @Test - public void instantiateVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.INSTANTIATED); - status.setLastAction(new PluginAction(null, null, null)); - expected.setStatus(status); - - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - CloudSite site = new CloudSite(); - Optional<CloudSite> opSite = Optional.ofNullable(site); - CloudConfig config = Mockito.mock(CloudConfig.class); - cloudify.cloudConfig = config; - Cloudify cloudifyClient = new Cloudify("cloudSite"); - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - VduModelInfo vduModel = new VduModelInfo(); - vduModel.setModelCustomizationUUID("blueprintId"); - vduModel.setTimeoutMinutes(1); - VduArtifact artifact = new VduArtifact(); - artifact.setName("name"); - artifact.setType(ArtifactType.MAIN_TEMPLATE); - byte[] content = new byte[1]; - artifact.setContent(content); - List<VduArtifact> artifacts = new ArrayList<>(); - artifacts.add(artifact); - vduModel.setArtifacts(artifacts); - 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"; - Map<String, Object> inputs = new HashMap<>(); - boolean rollbackOnFailure = true; - - when(config.getCloudSite(cloudInfo.getCloudSiteId())).thenReturn(opSite); - doReturn(false).when(cloudify).isBlueprintLoaded(cloudInfo.getCloudSiteId(), - vduModel.getModelCustomizationUUID()); - doReturn(cloudifyClient).when(cloudify).getCloudifyClient(site); - doReturn(true).when(cloudify).uploadBlueprint(cloudifyClient, vduModel.getModelCustomizationUUID(), - artifact.getName(), blueprintFiles); - doReturn(deployment).when(cloudify).createAndInstallDeployment(cloudInfo.getCloudSiteId(), - cloudInfo.getTenantId(), instanceName, vduModel.getModelCustomizationUUID(), inputs, true, - vduModel.getTimeoutMinutes(), rollbackOnFailure); - - VduInstance actual = cloudify.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure); - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void queryVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.INSTANTIATED); - status.setLastAction(new PluginAction(null, null, null)); - expected.setStatus(status); - - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - DeploymentInfo deployment = - new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.INSTALLED).build(); - String instanceId = "instanceId"; - - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - - doReturn(deployment).when(cloudify).queryDeployment(cloudInfo.getCloudSiteId(), cloudInfo.getTenantId(), - instanceId); - - VduInstance actual = cloudify.queryVdu(cloudInfo, instanceId); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deleteVduTest() throws MsoException { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.DELETING); - status.setLastAction(new PluginAction("deleting", null, null)); - expected.setStatus(status); - - CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("cloudSiteId"); - cloudInfo.setTenantId("tenantId"); - String instanceId = "instanceId"; - int timeoutMinutes = 1; - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class); - doReturn(deploymentInfo).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(), - cloudInfo.getTenantId(), instanceId, timeoutMinutes); - - VduInstance actual = cloudify.deleteVdu(cloudInfo, instanceId, timeoutMinutes); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deploymentInfoToVduInstanceTest() { - VduInstance expected = new VduInstance(); - expected.setVduInstanceId("id"); - expected.setVduInstanceName("id"); - VduStatus status = new VduStatus(); - status.setState(VduStateType.DELETING); - status.setLastAction(new PluginAction("deleting", null, null)); - expected.setStatus(status); - - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - - VduInstance actual = cloudify.deploymentInfoToVduInstance(deploymentInfo); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void deploymentStatusToVduStatusTest() { - VduStatus expected = new VduStatus(); - expected.setState(VduStateType.DELETING); - expected.setLastAction(new PluginAction("deleting", null, null)); - - DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withId("id").withStatus(DeploymentStatus.CREATED) - .withLastAction("deleting").build(); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - - VduStatus actual = cloudify.deploymentStatusToVduStatus(deploymentInfo); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void getAzureConfigTest() { - AzureConfig expected = new AzureConfig(); - expected.setSubscriptionId("subscriptionId"); - expected.setTenantId("tenantId"); - expected.setClientId("msoId"); - expected.setClientSecret("msoPass"); - - MsoCloudifyUtils cloudify = new MsoCloudifyUtils(); - CloudSite cloudSite = Mockito.mock(CloudSite.class); - CloudIdentity cloudIdentity = Mockito.mock(CloudIdentity.class); - when(cloudSite.getIdentityService()).thenReturn(cloudIdentity); - when(cloudIdentity.getAdminTenant()).thenReturn("subscriptionId"); - when(cloudIdentity.getMsoId()).thenReturn("msoId"); - when(cloudIdentity.getMsoPass()).thenReturn("msoPass"); - String tenantId = "tenantId"; - AzureConfig actual = cloudify.getAzureConfig(cloudSite, tenantId); - - assertThat(actual, sameBeanAs(expected)); - } - - @Test - public void uploadBlueprintSuccessful() throws MsoException { - // given - MsoCloudifyUtils testedObjectSpy = spy(MsoCloudifyUtils.class); - testedObjectSpy.cloudConfig = mock(CloudConfig.class); - Map<String, byte[]> blueprints = new HashMap<>(); - - mockCloudConfig(testedObjectSpy); - doReturn(true).when(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), - eq(blueprints)); - // when - testedObjectSpy.uploadBlueprint(CLOUD_SITE_ID, BLUEPRINT_ID, FILE_NAME, blueprints, true); - // then - verify(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), eq(blueprints)); - } - - @Test - public void uploadBlueprint_exceptionThrown_blueprintExists() throws MsoException { - // given - MsoCloudifyUtils testedObjectSpy = spy(MsoCloudifyUtils.class); - testedObjectSpy.cloudConfig = mock(CloudConfig.class); - Map<String, byte[]> blueprints = new HashMap<>(); - - mockCloudConfig(testedObjectSpy); - doReturn(false).when(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), - eq(blueprints)); - // when - try { - testedObjectSpy.uploadBlueprint(CLOUD_SITE_ID, BLUEPRINT_ID, FILE_NAME, blueprints, true); - // then - fail("MsoAdapterException should be thrown"); - } catch (MsoAdapterException e) { - Assert.assertEquals(e.getMessage(), "Blueprint already exists"); - } - verify(testedObjectSpy).uploadBlueprint(any(Cloudify.class), eq(BLUEPRINT_ID), eq(FILE_NAME), eq(blueprints)); - } - - @Test - public void convertInputValueTest() throws JsonParseException, JsonMappingException, IOException { - MsoCloudifyUtils utils = new MsoCloudifyUtils(); - ObjectMapper mapper = new ObjectMapper(); - HeatTemplateParam paramNum = new HeatTemplateParam(); - paramNum.setParamType("number"); - paramNum.setParamName("my-number"); - - HeatTemplateParam paramString = new HeatTemplateParam(); - paramString.setParamType("string"); - paramString.setParamName("my-string"); - - HeatTemplateParam paramJson = new HeatTemplateParam(); - paramJson.setParamType("json"); - paramJson.setParamName("my-json"); - - HeatTemplateParam paramJsonEscaped = new HeatTemplateParam(); - paramJsonEscaped.setParamType("json"); - paramJsonEscaped.setParamName("my-json-escaped"); - - Map<String, Object> jsonMap = - mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>() {}); - - assertEquals(3, utils.convertInputValue("3", paramNum)); - assertEquals("hello", utils.convertInputValue("hello", paramString)); - assertTrue("expect no change in type", utils.convertInputValue(jsonMap, paramJson) instanceof Map); - assertTrue("expect string to become jsonNode", - utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped) instanceof JsonNode); - - JSONAssert.assertEquals(getJson("free-form.json"), - mapper.writeValueAsString(utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped)), false); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/MsoHeatUtils/" + filename))); - } - - private void mockCloudConfig(MsoCloudifyUtils testedObjectSpy) { - CloudifyManager cloudifyManager = createCloudifyManager(); - when(testedObjectSpy.cloudConfig.getCloudSite(CLOUD_SITE_ID)).thenReturn(Optional.of(createCloudSite())); - when(testedObjectSpy.cloudConfig.getCloudifyManager(CLOUD_SITE_ID)).thenReturn(cloudifyManager); - } - - private CloudifyManager createCloudifyManager() { - CloudifyManager cloudifyManager = new CloudifyManager(); - cloudifyManager.setCloudifyUrl("cloudUrlTest"); - cloudifyManager.setPassword("546573746F736973546573746F736973"); - return cloudifyManager; - } - - private CloudSite createCloudSite() { - CloudSite cloudSite = new CloudSite(); - cloudSite.setCloudifyId(CLOUD_SITE_ID); - return cloudSite; - } - -} diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index ea371f54f7..e4810840f1 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -33,6 +33,12 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'), ('VNF-Config-Update', 'applyUpdatedConfig', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); +-- +-- northbound_request_ref_lookup for updateInstance (Macro Flow) +-- +INSERT INTO northbound_request_ref_lookup(ID, REQUEST_SCOPE, MACRO_ACTION, ACTION, IS_ALACARTE, MIN_API_VERSION, MAX_API_VERSION, IS_TOPLEVELFLOW, CLOUD_OWNER, SERVICE_TYPE) +VALUES (500, 'Vnf', 'VNF-Macro-Modify', 'updateInstance', 0, 7, 7, 1, 'k8scloudowner4', '*'); + INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES ('Service-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -211,6 +217,15 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')); +-- +-- orchestration_flow_reference for updateInstance (Macro Flow) +-- +insert into orchestration_flow_reference (id,COMPOSITE_ACTION,SEQ_NO,FLOW_NAME,FLOW_VERSION,NB_REQ_REF_LOOKUP_ID,SCOPE,ACTION) +values (901, 'VNF-Macro-Modify',1,'ControllerExecutionBB',1,500,'vnf','config-assign'); +insert into orchestration_flow_reference (id,COMPOSITE_ACTION,SEQ_NO,FLOW_NAME,FLOW_VERSION,NB_REQ_REF_LOOKUP_ID,SCOPE,ACTION) +values (902, 'VNF-Macro-Modify',2,'ControllerExecutionBB',1,500,'vnf','config-deploy'); + + INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES ('Service-Macro-Create', '10', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-assign'); 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 1663fdd6a8..388d3c8b49 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 @@ -33,6 +33,8 @@ 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 (2,'deleteInstance','1','VID_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','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); 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 (3,'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','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); 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 (4,'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','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); +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 (500,'updateInstance','1.0','Gr api recipe to update service-instance', '/mso/async/services/WorkflowActionBB', NULL, 180, NULL, '2017-10-05 18:52:03', 'd88da85c-d9e8-4f73-b837-3a72a431622b'); + -- -- Custom Reciepe for the VoLTE service added temporarily @@ -60,6 +62,7 @@ INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF 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 (11,NULL,'vfModule','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleInfra',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 (12,NULL,'vfModule','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleInfra',null,180,'2017-10-05 18:52:03'); + -- -- Default Reciepe for the VNF componnets added start #SO-334, to unblock the VNF operations -- diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java index e762bc04e8..28789f2a98 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -50,7 +50,7 @@ public class NssmfAdapterConsts { private final static String EXTERNAL_TN_DEALLOCATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{sliceProfileId}"; - private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{SliceProfileId}"; + private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{sliceProfileId}"; private final static String INTERNAL_DEALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deAllocate"; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index 0d2f2dfdeb..ef979a660f 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -41,7 +41,9 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { @Override protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return marshal(nbiRequest.getAllocateAnNssi().getSliceProfile()); + Map<String, Object> request = new HashMap<>(); + request.put("attributeListIn", nbiRequest.getAllocateAnNssi().getSliceProfile()); + return marshal(request); } @Override diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java index a9c732e6e3..67cd913b3e 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -54,7 +54,7 @@ import org.onap.so.beans.nsmf.NssiAllocateRequest; import org.onap.so.beans.nsmf.NssiDeAllocateRequest; import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.PerfReq; -import org.onap.so.beans.nsmf.PerfReqEmbbList; +import org.onap.so.beans.nsmf.PerfReqEmbb; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; @@ -289,7 +289,7 @@ public class NssmfAdapterRestTest { assertEquals(all.getAllocateCnNssi().getSliceProfile().getResourceSharingLevel(), NON_SHARED); assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq()); assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList()); - PerfReqEmbbList embb = + PerfReqEmbb embb = all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList().iterator().next(); assertNotNull(embb); assertEquals(embb.getActivityFactor(), 50); @@ -302,9 +302,9 @@ public class NssmfAdapterRestTest { List<String> plmn = new LinkedList<>(); plmn.add("460-00"); plmn.add("460-01"); - PerfReqEmbbList embb = new PerfReqEmbbList(); + PerfReqEmbb embb = new PerfReqEmbb(); embb.setActivityFactor(50); - List<PerfReqEmbbList> embbList = new LinkedList<>(); + List<PerfReqEmbb> embbList = new LinkedList<>(); embbList.add(embb); PerfReq perfReq = new PerfReq(); perfReq.setPerfReqEmbbList(embbList); diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java index 3108ade5a6..4a659e1ca3 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java @@ -191,9 +191,9 @@ public class NssmfManagerServiceImplTest { List<String> plmn = new LinkedList<>(); plmn.add("460-00"); plmn.add("460-01"); - PerfReqEmbbList embb = new PerfReqEmbbList(); + PerfReqEmbb embb = new PerfReqEmbb(); embb.setActivityFactor(50); - List<PerfReqEmbbList> embbList = new LinkedList<>(); + List<PerfReqEmbb> embbList = new LinkedList<>(); embbList.add(embb); PerfReq perfReq = new PerfReq(); perfReq.setPerfReqEmbbList(embbList); diff --git a/adapters/mso-oof-adapter/.gitignore b/adapters/mso-oof-adapter/.gitignore new file mode 100644 index 0000000000..549e00a2a9 --- /dev/null +++ b/adapters/mso-oof-adapter/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/adapters/mso-oof-adapter/pom.xml b/adapters/mso-oof-adapter/pom.xml new file mode 100644 index 0000000000..98150d39e0 --- /dev/null +++ b/adapters/mso-oof-adapter/pom.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.7.1-SNAPSHOT</version> + </parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-oof-adapter</artifactId> + <name>mso-oof-adapter</name> + <description>mso oof adapter</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${springboot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-webflux</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>org.onap.so.adapters.oof.MsoOofAdapterApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> + </build> +</project> diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java index 652df6ff0d..78fbe6e271 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/MsoOofAdapterApplication.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -18,11 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.adapters.oof; -@FunctionalInterface -public interface CloudifyClientConnector { +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; - public <T> CloudifyResponse request(CloudifyRequest<T> request); +@SpringBootApplication +public class MsoOofAdapterApplication { + public static void main(String[] args) { + SpringApplication.run(MsoOofAdapterApplication.class, args); + } } diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java new file mode 100644 index 0000000000..5e13c592b7 --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/OofAdapterClientConfig.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class OofAdapterClientConfig { + + @Bean + public RestTemplate getRestTemplate() { + HttpComponentsClientHttpRequestFactory requestFactory = + new HttpComponentsClientHttpRequestFactory(getHttpsClient()); + requestFactory.setConnectTimeout(60000); + requestFactory.setReadTimeout(60000); + return new RestTemplate(requestFactory); + } + + private HttpClient getHttpsClient() { + TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + }}; + + // Install the all-trusting trust manager + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc, + new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, hostnameVerifier); + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyManagerNotFound.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java index bc6fd6204c..9a07b0119f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyManagerNotFound.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/WebSecurityConfig.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,16 +18,20 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.exceptions; +package org.onap.so.adapters.oof; -public class MsoCloudifyManagerNotFound extends MsoCloudifyException { +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - private static final long serialVersionUID = 1L; +@EnableWebSecurity +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - // Constructor to create a new MsoCloudifyException instance - public MsoCloudifyManagerNotFound(String cloudSiteId) { - // Set the detailed error as the Exception 'message' - super(0, "Cloudify Manager Not Found", "No Cloudify Manager configured for cloud site " + cloudSiteId); + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable(); } } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseStatus.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java index ccdd7a4168..5d91bf38f8 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseStatus.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/constants/Constants.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -17,21 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.adapters.oof.constants; -package org.onap.so.cloudify.base.client; +public class Constants { -public class CloudifyResponseStatus { - - public static final int OK = 200; - - public static final int ACCEPTED = 201; - - public static final int BAD_REQUEST = 400; - - public static final int NOT_AUTHORIZED = 401; - - public static final int NOT_FOUND = 404; - - public static final int CONFLICT = 409; + public static final String OOF_ENDPOINT = "mso.oof.endpoint"; + public static final String OOF_AUTH = "mso.oof.auth"; + public static final String MSO_KEY = "mso.msoKey"; + public static final String CAMUNDA_URL = "mso.camundaURL"; + public static final String CAMUNDA_AUTH = "mso.camundaAuth"; + public static final String WORKFLOW_MESSAGE_ENPOINT = "mso.workflow.message.endpoint"; } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifySimpleTokenProvider.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java index 0c1e42d0e8..ff16d7442c 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifySimpleTokenProvider.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/exceptions/OofAdapterException.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.adapters.oof.exceptions; -public class CloudifySimpleTokenProvider implements CloudifyTokenProvider { +public class OofAdapterException extends Exception { - String token; + private static final long serialVersionUID = 1L; - public CloudifySimpleTokenProvider(String token) { - this.token = token; + public OofAdapterException(String message) { + super(message); } - @Override - public String getToken() { - return this.token; + public OofAdapterException(Throwable e) { + super(e); } - @Override - public void expireToken() {} + public OofAdapterException(String message, Throwable e) { + super(message, e); + } } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CancelExecutionParams.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java index 7f96b8f7c6..1eb694fd96 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CancelExecutionParams.java +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/model/OofRequest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -17,34 +17,36 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.adapters.oof.model; -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CancelExecutionParams implements Serializable { +/** + * POJO representing generic request payload from BPMN processes + */ +public class OofRequest { - private static final long serialVersionUID = 1L; + private String apiPath; - @JsonProperty("action") - private String action; + private Object requestDetails; - public static final String CANCEL_ACTION = "cancel"; - public static final String FORCE_CANCEL_ACTION = "force-cancel"; + public String getApiPath() { + return apiPath; + } - public String getAction() { - return action; + public void setApiPath(String apiPath) { + this.apiPath = apiPath; } - public void setAction(String action) { - this.action = action; + public Object getRequestDetails() { + return requestDetails; } + public void setRequestDetails(Object requestDetails) { + this.requestDetails = requestDetails; + } @Override public String toString() { - return "CancelExecutionParams{" + "action='" + action + '\'' + '}'; + return "{\"apiPath:\"\"" + apiPath + "\"\", requestDetails:\"\"" + requestDetails + "}"; } } diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java new file mode 100644 index 0000000000..f8da6c6d2e --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofCallbackHandler.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.rest; + +import org.onap.so.adapters.oof.exceptions.OofAdapterException; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +/** + * A generic call back handler to receive async response from OOF + */ +@RestController +@RequestMapping("/so/adapters/oof/callback/") +public class OofCallbackHandler { + + @Autowired + OofUtils utils; + + @Autowired + RestTemplate restTemplate; + + private static final Logger logger = LoggerFactory.getLogger(OofCallbackHandler.class); + + @PostMapping("/{version:[vV][1]}/{messageEventName}/{correlator}") + public ResponseEntity<String> processCallback(@PathVariable("messageEventName") String messageEventName, + @PathVariable("correlator") String correlator, @RequestBody String oofCallbackRequest) + throws OofAdapterException { + logger.debug("Oof Async response received for event : {} , callback request body : {} ", messageEventName, + oofCallbackRequest); + String camundaMsgUrl = utils.getCamundaMsgUrl(messageEventName, correlator); + HttpEntity<String> request = new HttpEntity<String>(oofCallbackRequest, utils.getCamundaHeaders()); + try { + ResponseEntity<String> response = restTemplate.postForEntity(camundaMsgUrl, request, String.class); + logger.debug("Response from BPMN : {} ", response); + return response; + } catch (Exception e) { + logger.warn("Error injecting message event into BPMN {} {} ", e.getCause(), e.getMessage()); + throw new OofAdapterException(e); + } + + } + +} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java new file mode 100644 index 0000000000..3a91ec495e --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/rest/OofClient.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.rest; + +import org.onap.so.adapters.oof.exceptions.OofAdapterException; +import org.onap.so.adapters.oof.model.OofRequest; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +/** + * A generic client class to call OOF with request from BPMN + */ +@RestController +@RequestMapping("/so/adapters/oof/") +public class OofClient { + + @Autowired + RestTemplate restTemplate; + + @Autowired + OofUtils utils; + + private static final Logger logger = LoggerFactory.getLogger(OofClient.class); + + @PostMapping("/{version:[vV][1]}") + public ResponseEntity<String> callOof(@RequestBody OofRequest oofRequest) throws OofAdapterException { + try { + logger.debug("Received Request from BPEL {} ", oofRequest); + String oofUrl = utils.getOofurl(oofRequest.getApiPath()); + HttpEntity<?> request = new HttpEntity<>(oofRequest.getRequestDetails(), utils.getOofHttpHeaders()); + ResponseEntity<String> response = restTemplate.postForEntity(oofUrl, request, String.class); + logger.debug("Response from OOF : {} ", response); + return response; + } catch (Exception e) { + logger.warn("Error while calling OOF {} {} ", e.getCause(), e.getMessage()); + throw new OofAdapterException(e); + } + } + +} diff --git a/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java new file mode 100644 index 0000000000..f45baa30fe --- /dev/null +++ b/adapters/mso-oof-adapter/src/main/java/org/onap/so/adapters/oof/utils/OofUtils.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.utils; + +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.DatatypeConverter; +import org.onap.so.adapters.oof.constants.Constants; +import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; + +@Component +public class OofUtils { + private static Logger logger = LoggerFactory.getLogger(OofUtils.class); + + @Autowired + private Environment env; + + /** + * @param messageEventName + * @param correlator + * @return + */ + public String getCamundaMsgUrl(String messageEventName, String correlator) { + System.out.println(env); + String camundaMsgUrl = new StringBuilder(env.getRequiredProperty(Constants.WORKFLOW_MESSAGE_ENPOINT)) + .append("/").append(messageEventName).append("/").append(correlator).toString(); + return camundaMsgUrl; + } + + /** + * @return + */ + public HttpHeaders getCamundaHeaders() { + HttpHeaders headers = new HttpHeaders(); + List<MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(MediaType.ALL); + headers.setAccept(acceptableMediaTypes); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add(HttpHeaders.AUTHORIZATION, addAuthorizationHeader(env.getRequiredProperty(Constants.CAMUNDA_AUTH), + env.getRequiredProperty(Constants.MSO_KEY))); + return headers; + } + + /** + * @param auth + * @param msoKey + * @return + */ + protected String addAuthorizationHeader(String auth, String msoKey) { + String basicAuth = null; + try { + String userCredentials = CryptoUtils.decrypt(auth, msoKey); + if (userCredentials != null) { + basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + } + } catch (GeneralSecurityException e) { + logger.error("Security exception", e); + } + return basicAuth; + } + + /** + * @return + * @throws Exception + */ + public HttpHeaders getOofHttpHeaders() throws Exception { + HttpHeaders headers = new HttpHeaders(); + List<MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + headers.setContentType(MediaType.APPLICATION_JSON); + return headers; + } + + /** + * @param apiPath + * @return + */ + public String getOofurl(String apiPath) { + return new StringBuilder(env.getRequiredProperty(Constants.OOF_ENDPOINT)).append(apiPath).toString(); + } + + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java new file mode 100644 index 0000000000..3a2f7f5e11 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofCallbackHandlerTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.rest; + +import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; +import org.junit.Before; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.databind.ObjectMapper; + + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class OofCallbackHandlerTest { + + @Autowired + TestRestTemplate restTemplate; + + @MockBean + OofUtils oofutils; + + @MockBean + RestTemplate mockrestTemplate; + + @Before + void prepareMocks() throws Exception { + ResponseEntity<Object> responseEntity = new ResponseEntity<>(HttpStatus.OK); + when(oofutils.getCamundaHeaders()).thenReturn(new HttpHeaders()); + when(oofutils.getCamundaMsgUrl(Mockito.anyString(), Mockito.anyString())).thenReturn("oofurl"); + when(mockrestTemplate.postForEntity(Mockito.anyString(), Mockito.any(), Mockito.any())) + .thenReturn(responseEntity); + } + + @Test + void processCallbackTest() throws Exception { + Object request = prepareOofResponse(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity<Object> entity = new HttpEntity<Object>(request, headers); + ResponseEntity<String> response = restTemplate.postForEntity( + "/so/adapters/oof/callback/v1/NSISelectionResponse/d88da85c-d9e8-4f73-b837-3a72a431622a", entity, + String.class); + Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + private Object prepareOofResponse() throws IOException { + File file = new ClassPathResource("testInputs/NsiSelectionResponse.json").getFile(); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(file, Object.class); + } + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java new file mode 100644 index 0000000000..ff38a9af63 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/rest/OofClientTest.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.rest; + +import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; +import org.junit.Before; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.so.adapters.oof.model.OofRequest; +import org.onap.so.adapters.oof.utils.OofUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class OofClientTest { + + @Autowired + TestRestTemplate restTemplate; + + @MockBean + OofUtils oofutils; + + @MockBean + RestTemplate mockrestTemplate; + + @Before + void prepareMocks() throws Exception { + ResponseEntity<Object> responseEntity = new ResponseEntity<>(HttpStatus.OK); + when(oofutils.getOofHttpHeaders()).thenReturn(new HttpHeaders()); + when(oofutils.getOofurl(Mockito.anyString())).thenReturn("oofurl"); + when(mockrestTemplate.postForEntity(Mockito.anyString(), Mockito.any(), Mockito.any())) + .thenReturn(responseEntity); + } + + @Test + void callOofTest() throws Exception { + OofRequest request = prepareOofRequest(); + System.out.println(request); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity<OofRequest> entity = new HttpEntity<OofRequest>(request, headers); + ResponseEntity<String> response = restTemplate.postForEntity("/so/adapters/oof/v1", entity, String.class); + Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + private OofRequest prepareOofRequest() throws IOException { + File file = new ClassPathResource("testInputs/NsiSelectionOofRequest.json").getFile(); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(file, OofRequest.class); + } + + +} diff --git a/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java new file mode 100644 index 0000000000..e68fa10c3e --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/java/org/onap/so/adapters/oof/utils/OofUtilsTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. 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.oof.utils; + +import static org.mockito.Mockito.when; +import java.security.GeneralSecurityException; +import javax.xml.bind.DatatypeConverter; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.so.utils.CryptoUtils; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class OofUtilsTest { + + @InjectMocks + OofUtils oofUtils; + + @Mock + Environment env; + + @Test + void testGetCamundaMsgUrl() { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + String camundamsgUrl = oofUtils.getCamundaMsgUrl("samplemessage", "sampleCorrelator"); + Assertions.assertNotNull(camundamsgUrl); + } + + + void testGetCamundaHeaders() throws GeneralSecurityException { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + when(CryptoUtils.decrypt(Mockito.anyString(), Mockito.anyString())).thenReturn("decryptedString"); + HttpHeaders headers = oofUtils.getCamundaHeaders(); + Assertions.assertNotNull(headers); + } + + + @Test + void testGetOofHttpHeaders() throws Exception { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + HttpHeaders headers = oofUtils.getOofHttpHeaders(); + Assertions.assertNotNull(headers); + } + + @Test + void testGetOofurl() { + when(env.getRequiredProperty(Mockito.anyString())).thenReturn("dummyString"); + String oofurl = oofUtils.getOofurl("/api/v1/"); + Assertions.assertNotNull(oofurl); + } + +} diff --git a/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json new file mode 100644 index 0000000000..569aae9f38 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionOofRequest.json @@ -0,0 +1,84 @@ +{ + "apiPath":"/api/oof/selection/nsi/v1", + "requestDetails":{ + "serviceProfile":{ + "blob":"content" + }, + "requestInfo":{ + "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl":"myDomain.com/myCallback", + "callbackHeader":{ + "blob":"content" + }, + "sourceId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "timeout":5, + "numSolutions":1 + }, + "NSTInfo":{ + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa1", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-nst" + }, + "NSSTInfo":[ + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2", + "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-an-nf" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3", + "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-cn" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4", + "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-fh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5", + "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-mh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-bh" + } + ], + "preferReuse":false, + "subnetCapabilities":[ + { + "domainType":"AN-NF", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"CN", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-FH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-MH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-BH", + "capabilityDetails":{ + "blob":"content" + } + } + ] +} +}
\ No newline at end of file diff --git a/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json new file mode 100644 index 0000000000..4ddca3eaf9 --- /dev/null +++ b/adapters/mso-oof-adapter/src/test/resources/testInputs/NsiSelectionResponse.json @@ -0,0 +1,20 @@ +{ + "transactionId": "s4r0f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "r500f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "completed", + "solutions": [ + { + "existingNSI": false, + "newNSISolution": { + "sliceProfiles": [ + { + "domainType":"CN" + } + ], + "matchLevel": { + "blob": "content" + } + } + } + ] +} diff --git a/adapters/pom.xml b/adapters/pom.xml index 3c71b3c031..49f25b8102 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -24,6 +24,7 @@ <module>mso-openstack-adapters</module> <module>etsi-sol003-adapter</module> <module>mso-nssmf-adapter</module> + <module>mso-oof-adapter</module> <module>so-appc-orchestrator</module> </modules> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy new file mode 100644 index 0000000000..ebc5f4ac58 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.scripts + +import javax.ws.rs.core.Response + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.oof.adapter.beans.payload.OofRequest +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import com.fasterxml.jackson.databind.ObjectMapper + + +import static org.onap.so.bpmn.common.scripts.GenericUtils.* + + +class DoHandleOofRequest extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(DoHandleOofRequest.class) + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug("In Preprocess Oof Request Handler") + String apiPath = execution.getVariable("apiPath") + if (isBlank(apiPath)) { + String msg = "Cannot process OOF adapter call : API PATH is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //msoRequestId is used for correlation + String requestId = execution.getVariable("correlator") + if (isBlank(requestId)) { + String msg = "Cannot process OOF adapter call : correlator is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String messageType = execution.getVariable("messageType") + if (isBlank(messageType)) { + String msg = "Cannot process OOF adapter call : messageType is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String timeout = execution.getVariable("timeout") + if (isBlank(timeout)) { + timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + if (isBlank(timeout)) { + logger.debug("Setting OOF timeout to default : PT30M") + timeout = "PT30M" + } + } + + Object requestDetails = execution.getVariable("oofRequest") + OofRequest oofRequestPayload = new OofRequest() + oofRequestPayload.setApiPath(apiPath) + oofRequestPayload.setRequestDetails(requestDetails) + ObjectMapper objectMapper = new ObjectMapper() + String requestJson = objectMapper.writeValueAsString(oofRequestPayload) + execution.setVariable("oofRequestPayload", requestJson) + } + + public void callOofAdapter(DelegateExecution execution) { + logger.debug("Start callOofAdapter") + String requestId = execution.getVariable("msoRequestId") + String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) + String basicAuthCred = execution.getVariable("BasicAuthHeaderValue") + URL requestUrl = new URL(oofAdapterEndpoint) + String oofRequest = execution.getVariable("oofRequestPayload") + logger.debug("oofRequest : " + oofRequest) + HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(oofRequest) + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 69dfacd9bc..2c96e7d3bb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -22,42 +22,28 @@ package org.onap.so.bpmn.common.scripts -import com.fasterxml.jackson.databind.ObjectMapper +import static org.onap.so.bpmn.common.scripts.GenericUtils.* + +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.so.bpmn.core.domain.HomingSolution import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.Resource -import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.logging.filter.base.ONAPComponents; -import org.springframework.http.HttpEntity -import org.springframework.http.HttpHeaders -import org.springframework.http.HttpMethod -import org.springframework.http.ResponseEntity -import org.springframework.http.client.BufferingClientHttpRequestFactory -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory -import org.springframework.web.client.RestTemplate -import org.springframework.web.util.UriComponentsBuilder import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.core.MediaType -import javax.ws.rs.core.Response -import javax.ws.rs.core.UriBuilder - -import static org.onap.so.bpmn.common.scripts.GenericUtils.* +import com.fasterxml.jackson.databind.ObjectMapper class OofUtils { private static final Logger logger = LoggerFactory.getLogger( OofUtils.class); @@ -530,10 +516,11 @@ class OofUtils { return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() } - public String buildSelectNSTRequest(String requestId, Map<String, Object> profileInfo) { + public String buildSelectNSTRequest(String requestId,String messageType, Map<String, Object> profileInfo) { def transactionId = requestId logger.debug( "transactionId is: " + transactionId) - String callbackUrl = "http://0.0.0.0:9000/callback/" + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator ObjectMapper objectMapper = new ObjectMapper() String json = objectMapper.writeValueAsString(profileInfo) StringBuilder response = new StringBuilder() @@ -554,11 +541,12 @@ class OofUtils { return response.toString() } - public String buildSelectNSIRequest(String requestId, String nstInfo, Map<String, Object> profileInfo){ + public String buildSelectNSIRequest(String requestId, String nstInfo,String messageType, Map<String, Object> profileInfo){ def transactionId = requestId logger.debug( "transactionId is: " + transactionId) - String callbackUrl = "http://0.0.0.0:9000/callback/" + String correlator = requestId + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(profileInfo); StringBuilder response = new StringBuilder(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java index 0193469d93..12abec0b77 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java @@ -57,6 +57,16 @@ public class RequestContext implements Serializable { private List<Map<String, String>> configurationParameters = new ArrayList<>(); @JsonProperty("application-id") private String applicationId; + @JsonProperty("is-helm") + private Boolean isHelm; + + public Boolean getIsHelm() { + return isHelm; + } + + public void setIsHelm(Boolean isHelm) { + this.isHelm = isHelm; + } public String getServiceURI() { return serviceURI; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 009686d0fc..5a8244266b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -193,6 +193,12 @@ public class BBInputSetup implements JavaDelegate { execution.setVariable(GBB_INPUT_VAR_NAME, outputBB); execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap); + if (outputBB.getRequestContext().getIsHelm()) { + execution.setVariable("isHelm", true); + } else { + execution.setVariable("isHelm", false); + } + BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution); execution.setVariable("gBuildingBlockExecution", gBuildingBlockExecution); execution.setVariable("RetryCount", 1); @@ -431,7 +437,8 @@ public class BBInputSetup implements JavaDelegate { protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { // @TODO: this will populate the instanceGroup model info. - // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups + // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter + // to support VNF Groups } protected void populateConfiguration(BBInputSetupParameter parameter) { @@ -613,6 +620,10 @@ public class BBInputSetup implements JavaDelegate { parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); } } + if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null + && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { + parameter.setIsHelm(true); + } } else { logger.debug("Related VNF instance Id not found: {}", parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID)); @@ -1018,7 +1029,6 @@ public class BBInputSetup implements JavaDelegate { if (requestDetails.getOwningEntity() != null) owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity()); - Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); if (service == null) { @@ -1094,6 +1104,7 @@ public class BBInputSetup implements JavaDelegate { RequestContext requestContext = mapperLayer.mapRequestContext(parameter.getRequestDetails()); requestContext.setAction(parameter.getRequestAction()); requestContext.setMsoRequestId(parameter.getExecuteBB().getRequestId()); + requestContext.setIsHelm(parameter.getIsHelm()); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(parameter.getRequestDetails().getCloudConfiguration()); CloudRegion cloudRegion = @@ -1852,8 +1863,9 @@ public class BBInputSetup implements JavaDelegate { } private void mapRelationship(ServiceInstance serviceInstance, Relationships relationships) { - this.mapProject(relationships.getByType(AAIObjectType.PROJECT), serviceInstance); - this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance); + this.mapProject(relationships.getByType(AAIObjectType.PROJECT, uri -> uri.nodesOnly(true)), serviceInstance); + this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY, uri -> uri.nodesOnly(true)), + serviceInstance); this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); this.mapPnfs(relationships.getRelatedAAIUris(AAIObjectType.PNF), serviceInstance.getPnfs()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java index 36ac0969ee..1290f2aeef 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupParameter.java @@ -45,6 +45,7 @@ public class BBInputSetupParameter { private String applicationId; private boolean isReplace; private ServiceModel serviceModel; + private boolean isHelm; private BBInputSetupParameter(Builder builder) { this.cloudConfiguration = builder.cloudConfiguration; @@ -74,6 +75,7 @@ public class BBInputSetupParameter { this.applicationId = builder.applicationId; this.isReplace = builder.isReplace; this.serviceModel = builder.serviceModel; + this.isHelm = builder.isHelm; } @@ -331,6 +333,15 @@ public class BBInputSetupParameter { this.serviceModel = serviceModel; } + protected boolean getIsHelm() { + return isHelm; + } + + + protected void setIsHelm(boolean isHelm) { + this.isHelm = isHelm; + } + public static class Builder { private CloudConfiguration cloudConfiguration; private ConfigurationResourceKeys configurationResourceKeys; @@ -359,6 +370,7 @@ public class BBInputSetupParameter { private String applicationId; private boolean isReplace; private ServiceModel serviceModel; + private boolean isHelm; public Builder setCloudConfiguration(CloudConfiguration cloudConfiguration) { this.cloudConfiguration = cloudConfiguration; @@ -495,6 +507,15 @@ public class BBInputSetupParameter { return this; } + protected boolean getIsHelm() { + return isHelm; + } + + + protected void setIsHelm(boolean isHelm) { + this.isHelm = isHelm; + } + public BBInputSetupParameter build() { return new BBInputSetupParameter(this); } diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateExecutionParams.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/oof/adapter/beans/payload/OofRequest.java index 3f49b90626..9d81332ed7 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateExecutionParams.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/oof/adapter/beans/payload/OofRequest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Wipro Limited. 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. @@ -17,31 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +package org.onap.so.client.oof.adapter.beans.payload; -package org.onap.so.cloudify.v3.model; +public class OofRequest { -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; + private String apiPath; -public class UpdateExecutionParams implements Serializable { + private Object requestDetails; - private static final long serialVersionUID = 1L; - - @JsonProperty("status") - private String status; + public String getApiPath() { + return apiPath; + } - public String getStatus() { - return status; + public void setApiPath(String apiPath) { + this.apiPath = apiPath; } - public void setStatus(String status) { - this.status = status; + public Object getRequestDetails() { + return requestDetails; } + public void setRequestDetails(Object requestDetails) { + this.requestDetails = requestDetails; + } @Override public String toString() { - return "UpdateExecutionParams{" + "status='" + status + '\'' + '}'; + return "OofRequest [apiPath=" + apiPath + ", requestDetails=" + requestDetails + "]"; } } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index fe33308d78..7662b995e4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -8,7 +8,8 @@ "userParams": [], "aLaCarte": true }, - "configurationParameters": [] + "configurationParameters": [], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index b18cad0620..2f26913ffc 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -33,7 +33,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json index f07f060b06..0137d42009 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json @@ -43,7 +43,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json index f55717fc91..d8294c0a17 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json @@ -14,7 +14,8 @@ "requestParameters": { }, - "configurationParameters": [] + "configurationParameters": [], + "is-helm": false }, "orchContext": { "is-rollback-enabled": true diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json index ca2b76e4bf..e7fa4debeb 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockWithVnf.json @@ -33,7 +33,8 @@ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" } - ] + ], + "is-helm": false }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java deleted file mode 100644 index 58d0c6d374..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.onap.so.bpmn.common.workflow.service; - -import java.util.ArrayList; -import java.util.List; -import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.engine.RepositoryService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.migration.MigrationInstruction; -import org.camunda.bpm.engine.migration.MigrationPlan; -import org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder; -import org.camunda.bpm.engine.repository.ProcessDefinition; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -@Service -public class AutoProcessInstanceMigrationService { - - private static Logger logger = LoggerFactory.getLogger(AutoProcessInstanceMigrationService.class); - - @Autowired - private Environment env; - @Autowired - protected ProcessEngine processEngine; - - @Value("${migration.autoMigrationEnabled:false}") - private boolean autoMigrationEnabled; - - private RuntimeService runtimeService; - private RepositoryService repositoryService; - private List<String> processDefinitionKeys; - - @EventListener(ApplicationReadyEvent.class) - protected void executeAutoProcessInstanceMigrations() { - if (autoMigrationEnabled) { - runtimeService = processEngine.getRuntimeService(); - repositoryService = processEngine.getRepositoryService(); - for (ProcessDefinition definition : getProcessDefinitions()) { - for (ProcessDefinition procDefOld : getOldProcessDefinitions(definition.getKey(), - definition.getVersion())) { - migrate(procDefOld.getId(), definition.getId()); - } - } - } - } - - protected List<ProcessDefinition> getProcessDefinitions() { - - List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>(); - processDefinitionKeys = env.getProperty("migration.processDefinitionKeys", List.class, new ArrayList<String>()); - for (String key : processDefinitionKeys) { - processDefinitions.add(repositoryService.createProcessDefinitionQuery().processDefinitionKey(key) - .latestVersion().singleResult()); - } - return processDefinitions; - } - - private void migrate(String sourceProcessDefinitionId, String targetProcessDefinitionId) { - MigrationPlan migrationPlan = - runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId) - .mapEqualActivities().updateEventTriggers().build(); - List<String> activityIds = new ArrayList<>(); - - for (MigrationInstruction instruction : migrationPlan.getInstructions()) { - activityIds.add(instruction.getSourceActivityId()); - } - for (String activityId : activityIds) { - ProcessInstanceQuery activeProcessInstancesQuery = runtimeService.createProcessInstanceQuery() - .processDefinitionId(sourceProcessDefinitionId).activityIdIn(activityId).active(); - if (!activeProcessInstancesQuery.list().isEmpty()) { - logger.info("Migrating {} process instance(s) from {} to {}", - Long.valueOf(activeProcessInstancesQuery.count()), sourceProcessDefinitionId, - targetProcessDefinitionId); - MigrationPlanExecutionBuilder migration = - runtimeService.newMigration(migrationPlan).processInstanceQuery(activeProcessInstancesQuery); - migration.executeAsync(); - } - } - suspendEmptyProcessDefinition(sourceProcessDefinitionId); - } - - private void suspendEmptyProcessDefinition(String sourceProcessDefinitionId) { - List<ProcessInstance> activeProcessInstances = runtimeService.createProcessInstanceQuery() - .processDefinitionId(sourceProcessDefinitionId).active().list(); - if (activeProcessInstances.isEmpty()) { - repositoryService.suspendProcessDefinitionById(sourceProcessDefinitionId); - } else { - logger.info("Unable to migrate {} process instance(s) from {}", - Integer.valueOf(activeProcessInstances.size()), sourceProcessDefinitionId); - } - } - - protected List<ProcessDefinition> getOldProcessDefinitions(String key, int version) { - List<ProcessDefinition> processDefinitions = - repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list(); - List<ProcessDefinition> oldProcessDefinitions = new ArrayList<>(); - for (ProcessDefinition processDef : processDefinitions) { - if (!processDef.isSuspended() && (processDef.getVersion() != version)) { - oldProcessDefinitions.add(processDef); - } - } - return oldProcessDefinitions; - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java deleted file mode 100644 index 36e828448d..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.bpmn.common.workflow.service; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; -import java.util.ArrayList; -import java.util.List; -import org.camunda.bpm.engine.ProcessEngine; -import org.camunda.bpm.engine.RepositoryService; -import org.camunda.bpm.engine.repository.ProcessDefinition; -import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.core.env.Environment; - -@RunWith(MockitoJUnitRunner.class) -public class AutoProcessInstanceMigrationServiceTest { - - @Mock - private ProcessEngine processEngine; - - @Mock - private ProcessDefinition outdated; - - @Mock - private ProcessDefinition newDef; - - @Mock - private ProcessDefinition key; - - @Mock - private ProcessDefinition testKey; - - @Mock - private ProcessDefinition suspendedDef; - - @Mock - private RepositoryService repositoryService; - - @Mock - private ProcessDefinitionQuery query; - - @Mock - private ProcessDefinitionQuery keyQuery; - - @Mock - private Environment env; - - @Spy - @InjectMocks - private AutoProcessInstanceMigrationService migrationService; - - - @Test - public void getOldProcessDefinitionsTest() { - List<ProcessDefinition> expectedList = new ArrayList<>(); - expectedList.add(outdated); - - List<ProcessDefinition> defList = new ArrayList<>(); - defList.add(outdated); - defList.add(newDef); - defList.add(suspendedDef); - - - doReturn(query).when(repositoryService).createProcessDefinitionQuery(); - doReturn(query).when(query).processDefinitionKey("test"); - doReturn(defList).when(query).list(); - doReturn(3).when(outdated).getVersion(); - doReturn(4).when(newDef).getVersion(); - doReturn(true).when(suspendedDef).isSuspended(); - List<ProcessDefinition> outdatedList = migrationService.getOldProcessDefinitions("test", 4); - - assertEquals(expectedList, outdatedList); - } - - @Test - public void getProcessDefinitionsTest() { - List<ProcessDefinition> expected = new ArrayList<ProcessDefinition>(); - expected.add(testKey); - expected.add(key); - - List<String> processDefinitionKeys = new ArrayList<String>(); - processDefinitionKeys.add("testKey"); - processDefinitionKeys.add("key"); - - doReturn(processDefinitionKeys).when(env).getProperty("migration.processDefinitionKeys", List.class, - new ArrayList<String>()); - - doReturn(query).when(repositoryService).createProcessDefinitionQuery(); - doReturn(query).when(query).processDefinitionKey("testKey"); - doReturn(query).when(query).latestVersion(); - doReturn(testKey).when(query).singleResult(); - - doReturn(keyQuery).when(query).processDefinitionKey("key"); - doReturn(keyQuery).when(keyQuery).latestVersion(); - doReturn(key).when(keyQuery).singleResult(); - - List<ProcessDefinition> actualProcessDefinitions = migrationService.getProcessDefinitions(); - - assertEquals(expected, actualProcessDefinitions); - } -} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 61c870b956..7638f34a59 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,29 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="CreateVfModuleBB" name="CreateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="CreateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1xr6chl</bpmn:outgoing> </bpmn:startEvent> <bpmn:serviceTask id="QueryVfModule" name=" SDNC Get (vf module) " camunda:expression="${SDNCQueryTasks.queryVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1s4rpyp</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_15hn8si</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ig2ix4</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1xr6chl" sourceRef="CreateVfModuleBB_Start" targetRef="QueryVnf" /> <bpmn:endEvent id="CreateVfModuleBB_End"> <bpmn:incoming>SequenceFlow_1vbwdaw</bpmn:incoming> </bpmn:endEvent> <bpmn:serviceTask id="CreateVfModule" name="Prepare Request" camunda:expression="${VnfAdapterCreateTasks.createVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_15hn8si</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_16g4dz0</bpmn:outgoing> + <bpmn:incoming>NoHelm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dehck5</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_15hn8si" sourceRef="QueryVfModule" targetRef="CreateVfModule" /> <bpmn:sequenceFlow id="SequenceFlow_1s4rpyp" sourceRef="QueryVnf" targetRef="QueryVfModule" /> <bpmn:serviceTask id="QueryVnf" name=" SDNC Get (vnf) " camunda:expression="${SDNCQueryTasks.queryVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1xr6chl</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1s4rpyp</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_16g4dz0" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> - <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="ServiceTask_01zrt6x" /> <bpmn:callActivity id="VnfAdapter" name="Vnf Adapter" calledElement="VnfAdapter"> <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> @@ -35,8 +32,8 @@ <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_0dehck5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uetprw</bpmn:outgoing> </bpmn:callActivity> <bpmn:serviceTask id="UpdateVfModuleStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusCreatedVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0rds4rj</bpmn:incoming> @@ -80,7 +77,8 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_15do1tu" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> <bpmn:serviceTask id="ServiceTask_01zrt6x" name=" Create Cloud Variable " camunda:expression="${CreateVFModule.createInventoryVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1mg8eym</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0uetprw</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1io8r33</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1io8r33" sourceRef="ServiceTask_01zrt6x" targetRef="ServiceTask_00d84m7" /> @@ -89,6 +87,23 @@ <bpmn:outgoing>SequenceFlow_1yn8o6d</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1yn8o6d" sourceRef="ServiceTask_00d84m7" targetRef="CreateNetworkPolicies" /> + <bpmn:exclusiveGateway id="CheckIfIsHelm" name="Check If Is Helm"> + <bpmn:incoming>SequenceFlow_1ig2ix4</bpmn:incoming> + <bpmn:outgoing>YesHelm</bpmn:outgoing> + <bpmn:outgoing>NoHelm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:serviceTask id="CnfAdapter" name="Cnf Adapter" camunda:expression="${CnfAdapterCreateTasks.createInstance(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>YesHelm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1mg8eym</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="YesHelm" name="Yes Helm" sourceRef="CheckIfIsHelm" targetRef="CnfAdapter"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isHelm")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1mg8eym" sourceRef="CnfAdapter" targetRef="ServiceTask_01zrt6x" /> + <bpmn:sequenceFlow id="SequenceFlow_1ig2ix4" sourceRef="QueryVfModule" targetRef="CheckIfIsHelm" /> + <bpmn:sequenceFlow id="NoHelm" name="No Helm" sourceRef="CheckIfIsHelm" targetRef="CreateVfModule" /> + <bpmn:sequenceFlow id="SequenceFlow_0dehck5" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> + <bpmn:sequenceFlow id="SequenceFlow_0uetprw" sourceRef="VnfAdapter" targetRef="ServiceTask_01zrt6x" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> @@ -102,31 +117,24 @@ <dc:Bounds x="513" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> - <di:waypoint x="192" y="106" /> - <di:waypoint x="313" y="106" /> + <di:waypoint xsi:type="dc:Point" x="192" y="106" /> + <di:waypoint xsi:type="dc:Point" x="313" y="106" /> <bpmndi:BPMNLabel> <dc:Bounds x="156" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1215" y="293" width="36" height="36" /> + <dc:Bounds x="1300" y="450" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1136" y="333" width="0" height="0" /> + <dc:Bounds x="1176" y="446" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> - <dc:Bounds x="709" y="66" width="100" height="80" /> + <dc:Bounds x="794" y="66" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15hn8si_di" bpmnElement="SequenceFlow_15hn8si"> - <di:waypoint x="613" y="106" /> - <di:waypoint x="709" y="106" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="519" y="91" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1s4rpyp_di" bpmnElement="SequenceFlow_1s4rpyp"> - <di:waypoint x="413" y="106" /> - <di:waypoint x="513" y="106" /> + <di:waypoint xsi:type="dc:Point" x="413" y="106" /> + <di:waypoint xsi:type="dc:Point" x="513" y="106" /> <bpmndi:BPMNLabel> <dc:Bounds x="321" y="91" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -134,124 +142,166 @@ <bpmndi:BPMNShape id="ServiceTask_1frb5h2_di" bpmnElement="QueryVnf"> <dc:Bounds x="313" y="66" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_16g4dz0_di" bpmnElement="SequenceFlow_16g4dz0"> - <di:waypoint x="809" y="106" /> - <di:waypoint x="887" y="106" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="751" y="91" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ecr393_di" bpmnElement="SequenceFlow_0ecr393"> - <di:waypoint x="987" y="107" /> - <di:waypoint x="1091" y="107" /> - <di:waypoint x="1091" y="209" /> - <di:waypoint x="680" y="209" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="534" y="194" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="887" y="66" width="100" height="80" /> + <dc:Bounds x="959" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1039" y="271" width="100" height="80" /> + <dc:Bounds x="1124" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="874" y="271" width="100" height="80" /> + <dc:Bounds x="959" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1getwnf_di" bpmnElement="SubProcess_1getwnf" isExpanded="true"> - <dc:Bounds x="233" y="439" width="231" height="135" /> + <dc:Bounds x="202" y="556" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1c8o652_di" bpmnElement="StartEvent_1c8o652"> - <dc:Bounds x="272" y="497" width="36" height="36" /> + <dc:Bounds x="241" y="614" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="148" y="533" width="0" height="0" /> + <dc:Bounds x="72" y="606" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1emam1w_di" bpmnElement="EndEvent_1emam1w"> - <dc:Bounds x="409" y="497" width="36" height="36" /> + <dc:Bounds x="378" y="614" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="285" y="533" width="0" height="0" /> + <dc:Bounds x="209" y="606" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gcots6_di" bpmnElement="SequenceFlow_0gcots6"> - <di:waypoint x="308" y="515" /> - <di:waypoint x="409" y="515" /> + <di:waypoint xsi:type="dc:Point" x="277" y="632" /> + <di:waypoint xsi:type="dc:Point" x="378" y="632" /> <bpmndi:BPMNLabel> - <dc:Bounds x="262" y="494" width="0" height="0" /> + <dc:Bounds x="186" y="567" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> - <di:waypoint x="974" y="311" /> - <di:waypoint x="1039" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1124" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="910" y="296" width="0" height="0" /> + <dc:Bounds x="950" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> - <di:waypoint x="1139" y="311" /> - <di:waypoint x="1180" y="311" /> - <di:waypoint x="1180" y="311" /> - <di:waypoint x="1215" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1224" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1265" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1265" y="468" /> + <di:waypoint xsi:type="dc:Point" x="1300" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1098" y="311" width="0" height="0" /> + <dc:Bounds x="1138" y="424" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> - <dc:Bounds x="239" y="271" width="100" height="80" /> + <dc:Bounds x="324" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> - <di:waypoint x="339" y="311" /> - <di:waypoint x="392" y="311" /> + <di:waypoint xsi:type="dc:Point" x="424" y="468" /> + <di:waypoint xsi:type="dc:Point" x="477" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="269" y="296" width="0" height="0" /> + <dc:Bounds x="309" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="392" y="271" width="100" height="80" /> + <dc:Bounds x="477" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> - <di:waypoint x="492" y="311" /> - <di:waypoint x="561" y="311" /> + <di:waypoint xsi:type="dc:Point" x="577" y="468" /> + <di:waypoint xsi:type="dc:Point" x="646" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="430" y="296" width="0" height="0" /> + <dc:Bounds x="470" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="561" y="271" width="100" height="80" /> + <dc:Bounds x="646" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1i03uy2_di" bpmnElement="SequenceFlow_1i03uy2"> - <di:waypoint x="661" y="311" /> - <di:waypoint x="709" y="311" /> + <di:waypoint xsi:type="dc:Point" x="746" y="468" /> + <di:waypoint xsi:type="dc:Point" x="794" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="588" y="296" width="0" height="0" /> + <dc:Bounds x="628" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="709" y="271" width="100" height="80" /> + <dc:Bounds x="794" y="428" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> - <di:waypoint x="809" y="311" /> - <di:waypoint x="874" y="311" /> + <di:waypoint xsi:type="dc:Point" x="894" y="468" /> + <di:waypoint xsi:type="dc:Point" x="959" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="745" y="286" width="0" height="0" /> + <dc:Bounds x="785" y="399" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_01zrt6x_di" bpmnElement="ServiceTask_01zrt6x"> - <dc:Bounds x="580" y="169" width="100" height="80" /> + <dc:Bounds x="665" y="326" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1io8r33_di" bpmnElement="SequenceFlow_1io8r33"> - <di:waypoint x="580" y="209" /> - <di:waypoint x="478" y="209" /> + <di:waypoint xsi:type="dc:Point" x="665" y="366" /> + <di:waypoint xsi:type="dc:Point" x="563" y="366" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="569" y="297" width="90" height="20" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_00d84m7_di" bpmnElement="ServiceTask_00d84m7"> - <dc:Bounds x="378" y="169" width="100" height="80" /> + <dc:Bounds x="463" y="326" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1yn8o6d_di" bpmnElement="SequenceFlow_1yn8o6d"> - <di:waypoint x="378" y="209" /> - <di:waypoint x="170" y="209" /> - <di:waypoint x="170" y="306" /> - <di:waypoint x="239" y="306" /> + <di:waypoint xsi:type="dc:Point" x="463" y="366" /> + <di:waypoint xsi:type="dc:Point" x="255" y="366" /> + <di:waypoint xsi:type="dc:Point" x="255" y="463" /> + <di:waypoint xsi:type="dc:Point" x="324" y="463" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="225" y="361" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1g3vemz_di" bpmnElement="CheckIfIsHelm" isMarkerVisible="true"> + <dc:Bounds x="690.2114427860697" y="81.35572139303483" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="673" y="48" width="84" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0tag50w_di" bpmnElement="CnfAdapter"> + <dc:Bounds x="665" y="166" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0q1janp_di" bpmnElement="YesHelm"> + <di:waypoint xsi:type="dc:Point" x="715" y="131" /> + <di:waypoint xsi:type="dc:Point" x="715" y="166" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="730" y="136" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1mg8eym_di" bpmnElement="SequenceFlow_1mg8eym"> + <di:waypoint xsi:type="dc:Point" x="715" y="246" /> + <di:waypoint xsi:type="dc:Point" x="715" y="326" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="846" y="291.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ig2ix4_di" bpmnElement="SequenceFlow_1ig2ix4"> + <di:waypoint xsi:type="dc:Point" x="613" y="106" /> + <di:waypoint xsi:type="dc:Point" x="691" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="652" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g7zahc_di" bpmnElement="NoHelm"> + <di:waypoint xsi:type="dc:Point" x="740" y="106" /> + <di:waypoint xsi:type="dc:Point" x="794" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="767" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0dehck5_di" bpmnElement="SequenceFlow_0dehck5"> + <di:waypoint xsi:type="dc:Point" x="894" y="106" /> + <di:waypoint xsi:type="dc:Point" x="959" y="106" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="926.5" y="85" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0uetprw_di" bpmnElement="SequenceFlow_0uetprw"> + <di:waypoint xsi:type="dc:Point" x="1009" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1009" y="366" /> + <di:waypoint xsi:type="dc:Point" x="765" y="366" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1024" y="228" width="0" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 15a0f34482..389f0a089c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -178,60 +178,36 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { logger.debug("Finish preProcessRequest") } - public void getNSTSelection(DelegateExecution execution) { - logger.debug("Start getNSTSelection") + public void prepareSelectNSTRequest(DelegateExecution execution) { + logger.debug("Start prepareSelectNSTRequest") String requestId = execution.getVariable("msoRequestId") + String messageType = "NSTSelectionResponse" Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") - String oofUrl = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) - - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) - String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - - String basicAuthValue = utils.encrypt(basicAuth, msokey) - if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue", authHeader) - } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + - "encode username and password string") - } - } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + - "value null") - } - - URL requestUrl = new URL(oofUrl + "/api/oof/v1/selection/nst") - String oofRequest = oofUtils.buildSelectNSTRequest(requestId, serviceProfile) - HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF) - httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(oofRequest) - - int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) - - if(responseCode != 200){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - } - - Map<String, Object> nstSolution - try { - Map<String, Object> resMap = httpResponse.readEntity(Map.class) - List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions") - nstSolution = nstSolutions.get(0) - execution.setVariable("nstSolution", nstSolution) - } catch (Exception ex) { - logger.debug( "Failed to get NST solution suggested by OOF.") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.") - } - - logger.debug("Finish getNSTSelection") + execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst") + execution.setVariable("nstSelection_messageType",messageType) + execution.setVariable("nstSelection_correlator",requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nstSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSTRequest(requestId,messageType, serviceProfile) + execution.setVariable("nstSelection_oofRequest",oofRequest) + logger.debug("Finish prepareSelectNSTRequest") } + + public void processNSTSolutions(DelegateExecution execution) { + Map<String, Object> nstSolution + try { + logger.debug("Start processing NSTSolutions") + Map<String, Object> resMap = objectMapper.readValue(execution.getVariable("nstSelection_oofResponse"),Map.class) + List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions") + nstSolution = nstSolutions.get(0) + execution.setVariable("nstSolution", nstSolution) + } catch (Exception ex) { + logger.debug( "Failed to get NST solution suggested by OOF.") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.") + } + + } public void prepareDecomposeService(DelegateExecution execution) { logger.debug("Start prepareDecomposeService") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 081dddab99..88edd79d6d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -15,8 +15,8 @@ import org.onap.so.beans.nsmf.NetworkType import org.onap.so.beans.nsmf.NsiInfo import org.onap.so.beans.nsmf.NssiAllocateRequest import org.onap.so.beans.nsmf.PerfReq -import org.onap.so.beans.nsmf.PerfReqEmbbList -import org.onap.so.beans.nsmf.PerfReqUrllcList +import org.onap.so.beans.nsmf.PerfReqEmbb +import org.onap.so.beans.nsmf.PerfReqUrllc import org.onap.so.beans.nsmf.ResourceSharingLevel import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.beans.nsmf.TnSliceProfile @@ -411,20 +411,20 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask execution.setVariable("esrInfo",esrInfo) - PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + PerfReqEmbb perfReqEmbb = new PerfReqEmbb() perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) - List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>() listPerfReqEmbbList.add(perfReqEmbb) PerfReq perfReq = new PerfReq() perfReq.setPerfReqEmbbList(listPerfReqEmbbList) - PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + PerfReqUrllc perfReqUrllc = new PerfReqUrllc() perfReqUrllc.setConnDensity(0) perfReqUrllc.setTrafficDensity(0) perfReqUrllc.setExpDataRate(0) @@ -436,7 +436,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask perfReqUrllc.setPayloadSize("0") perfReqUrllc.setServiceAreaDimension("") - List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>() perfReqUrllcList.add(perfReqUrllc) perfReq.setPerfReqUrllcList(perfReqUrllcList) @@ -558,20 +558,20 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask execution.setVariable("esrInfo",esrInfo) - PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + PerfReqEmbb perfReqEmbb = new PerfReqEmbb() perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) - List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + List<PerfReqEmbb> listPerfReqEmbbList = new ArrayList<>() listPerfReqEmbbList.add(perfReqEmbb) PerfReq perfReq = new PerfReq() perfReq.setPerfReqEmbbList(listPerfReqEmbbList) - PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + PerfReqUrllc perfReqUrllc = new PerfReqUrllc() perfReqUrllc.setConnDensity(0) perfReqUrllc.setTrafficDensity(0) perfReqUrllc.setExpDataRate(0) @@ -583,7 +583,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask perfReqUrllc.setPayloadSize("0") perfReqUrllc.setServiceAreaDimension("") - List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + List<PerfReqUrllc> perfReqUrllcList = new ArrayList<>() perfReqUrllcList.add(perfReqUrllc) perfReq.setPerfReqUrllcList(perfReqUrllcList) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index ec9596e7f3..9b78afba03 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -64,38 +64,16 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - void getNSIOptionfromOOF(DelegateExecution execution) { + void prepareSelectNSIRequest(DelegateExecution execution) { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) boolean isNSISuggested = true execution.setVariable("isNSISuggested",isNSISuggested) - - //Prepare auth for OOF - Begin - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) - String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - - String basicAuthValue = utils.encrypt(basicAuth, msokey) - if (basicAuthValue != null) { - logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) - try { - authHeader = utils.getBasicAuth(basicAuthValue, msokey) - execution.setVariable("BasicAuthHeaderValue", authHeader) - } catch (Exception ex) { - logger.debug( "Unable to encode username and password string: " + ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + - "encode username and password string") - } - } else { - logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") - exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + - "value null") - } - //Prepare auth for OOF - End - String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") Map<String, Object> nstSolution = execution.getVariable("nstSolution") logger.debug("Get NST selection from OOF: " + nstSolution.toString()) @@ -104,36 +82,21 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ "modelVersionId":"${nstSolution.UUID}", "modelName":"${nstSolution.NSTName}" }""" - - String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, profileInfo) - logger.debug("Sending request to OOF: " + oofRequest) - - //send request to get NSI option - Begin - URL url = new URL(urlString+"/api/oof/selection/nsi/v1") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) - httpClient.addAdditionalHeader("Authorization", authHeader) - Response httpResponse = httpClient.post(oofRequest) - - processOOFResponse(httpResponse, execution) - - //解析sliceProfile - logger.debug("start parseServiceProfile") - parseServiceProfile(execution) - logger.debug("end parseServiceProfile") + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType",messageType) + execution.setVariable("nsiSelection_correlator",requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nsiSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo) + execution.setVariable("nsiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) } - private void processOOFResponse(Response httpResponse, DelegateExecution execution) { + void processOOFResponse(Response httpResponse, DelegateExecution execution) { int responseCode = httpResponse.getStatus() - logger.debug("OOF sync response code is: " + responseCode) - - if (responseCode != 200) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - logger.debug("Info: No NSI suggested by OOF") - } - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") - if (httpResponse.hasEntity()) { - String OOFResponse = httpResponse.readEntity(String.class) + String OOFResponse = execution.getVariable("nsiSelection_oofResponse") logger.debug("NSI OOFResponse is: " + OOFResponse) execution.setVariable("OOFResponse", OOFResponse) //This needs to be changed to derive a value when we add policy to decide the solution options. @@ -154,8 +117,11 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } execution.setVariable("sliceTaskParams", sliceTaskParams) logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) - } logger.debug("*** Completed options Call to OOF ***") + //解析sliceProfile + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") } private boolean hasSharedNSIsolutions( Map solutions){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy index 8e7a4f727d..89902209a0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy @@ -31,8 +31,8 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.WorkflowException import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.* -class PNFSoftwareUpgrade extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger(PNFSoftwareUpgrade.class) +class GenericPnfSoftwareUpgrade extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(GenericPnfSoftwareUpgrade.class) ExceptionUtil exceptionUtil = new ExceptionUtil() String prefix = "PnfSwUpgrade_" diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index f27794a389..27bd01bda9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="CreateSliceService" name="CreateSliceService" isExecutable="true"> <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Slice Service Creation Flow"> <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> @@ -34,12 +34,12 @@ css.processUserOptions(execution)</bpmn:script> def css = new CreateSliceService() css.processDecomposition(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_1eo3m4q" name="Get NST Selection" scriptFormat="groovy"> + <bpmn:scriptTask id="ScriptTask_1eo3m4q" name="Prepare NST Selection" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_046irye</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1o23s0i</bpmn:outgoing> + <bpmn:outgoing>Flow_1l8mfej</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def css = new CreateSliceService() -css.getNSTSelection(execution)</bpmn:script> +css.prepareSelectNSTRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_139l55g" name="Call DoCreateSliceServiceInstance " calledElement="DoCreateSliceServiceInstance"> <bpmn:extensionElements> @@ -176,7 +176,7 @@ css.prepareUpdateServiceOperationStatus(execution)</bpmn:script> <bpmn:outgoing>SequenceFlow_1t19ips</bpmn:outgoing> </bpmn:callActivity> <bpmn:scriptTask id="ScriptTask_0o2r07o" name="Prepare Decompose Service " scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1o23s0i</bpmn:incoming> + <bpmn:incoming>Flow_1u4srgq</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0q7yc2c</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new CreateSliceService() @@ -446,7 +446,6 @@ css.sendSyncResponse(execution)</bpmn:script> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_1aaozcg" sourceRef="CallActivity_0v4mw2x" targetRef="ScriptTask_0gb975b" /> <bpmn:sequenceFlow id="SequenceFlow_046irye" sourceRef="ServiceTask_0kd6p6p" targetRef="ScriptTask_1eo3m4q" /> - <bpmn:sequenceFlow id="SequenceFlow_1o23s0i" sourceRef="ScriptTask_1eo3m4q" targetRef="ScriptTask_0o2r07o" /> <bpmn:sequenceFlow id="SequenceFlow_0jrclmc" sourceRef="ScriptTask_0l3d1ai" targetRef="IntermediateThrowEvent_1ex8ke9" /> <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0n4xku8</bpmn:incoming> @@ -457,12 +456,205 @@ def css = new CreateSliceService() css.updateAAIOrchStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0kixzdj" sourceRef="ScriptTask_19uxoi8" targetRef="ScriptTask_1ef3voz" /> + <bpmn:sequenceFlow id="Flow_1l8mfej" sourceRef="ScriptTask_1eo3m4q" targetRef="Activity_1ge49xu" /> + <bpmn:callActivity id="Activity_1ge49xu" name="Handle NST Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nstSelectionUrl" target="apiPath" /> + <camunda:in source="nstSelection_correlator" target="correlator" /> + <camunda:in source="nstSelection_messageType" target="messageType" /> + <camunda:in source="nstSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nstSelection_oofResponse" /> + <camunda:in source="nstSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_1l8mfej</bpmn:incoming> + <bpmn:outgoing>Flow_0vq2rmw</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_0vq2rmw" sourceRef="Activity_1ge49xu" targetRef="Activity_12v8ykp" /> + <bpmn:scriptTask id="Activity_12v8ykp" name="Process NST Solutions" scriptFormat="groovy"> + <bpmn:incoming>Flow_0vq2rmw</bpmn:incoming> + <bpmn:outgoing>Flow_1u4srgq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def css = new CreateSliceService() +css.processNSTSolutions(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1u4srgq" sourceRef="Activity_12v8ykp" targetRef="ScriptTask_0o2r07o" /> </bpmn:process> <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSliceService"> + <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> + <di:waypoint x="745" y="801" /> + <di:waypoint x="823" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0jrclmc_di" bpmnElement="SequenceFlow_0jrclmc"> + <di:waypoint x="1540" y="121" /> + <di:waypoint x="1584" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_046irye_di" bpmnElement="SequenceFlow_046irye"> + <di:waypoint x="650" y="121" /> + <di:waypoint x="685" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1aaozcg_di" bpmnElement="SequenceFlow_1aaozcg"> + <di:waypoint x="1115" y="289" /> + <di:waypoint x="1193" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12qt5ci_di" bpmnElement="SequenceFlow_12qt5ci"> + <di:waypoint x="335" y="514" /> + <di:waypoint x="335" y="611" /> + <di:waypoint x="335" y="593" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16uz2t9_di" bpmnElement="SequenceFlow_16uz2t9"> + <di:waypoint x="385" y="456" /> + <di:waypoint x="467" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fk37v7_di" bpmnElement="SequenceFlow_1fk37v7"> + <di:waypoint x="214" y="456" /> + <di:waypoint x="285" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ey6m1e_di" bpmnElement="SequenceFlow_1ey6m1e"> + <di:waypoint x="930" y="289" /> + <di:waypoint x="1015" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1bevt3a_di" bpmnElement="SequenceFlow_1bevt3a"> + <di:waypoint x="214" y="801" /> + <di:waypoint x="285" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx"> + <di:waypoint x="1471" y="645" /> + <di:waypoint x="1584" y="645" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh"> + <di:waypoint x="1293" y="645" /> + <di:waypoint x="1371" y="645" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0h2oree_di" bpmnElement="SequenceFlow_0h2oree"> + <di:waypoint x="567" y="456" /> + <di:waypoint x="645" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975"> + <di:waypoint x="1471" y="456" /> + <di:waypoint x="1584" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny"> + <di:waypoint x="1293" y="456" /> + <di:waypoint x="1371" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1sq6kp6_di" bpmnElement="SequenceFlow_1sq6kp6"> + <di:waypoint x="385" y="289" /> + <di:waypoint x="467" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0q7yc2c_di" bpmnElement="SequenceFlow_0q7yc2c"> + <di:waypoint x="1240" y="121" /> + <di:waypoint x="1280" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> + <di:waypoint x="1297" y="801" /> + <di:waypoint x="1375" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lbdfmt_di" bpmnElement="SequenceFlow_0lbdfmt"> + <di:waypoint x="1105" y="801" /> + <di:waypoint x="1197" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1o1tu0f_di" bpmnElement="SequenceFlow_1o1tu0f"> + <di:waypoint x="214" y="289" /> + <di:waypoint x="285" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> + <di:waypoint x="510" y="121" /> + <di:waypoint x="550" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_11rbv41_di" bpmnElement="SequenceFlow_11rbv41"> + <di:waypoint x="1475" y="801" /> + <di:waypoint x="1585" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0klb3ey_di" bpmnElement="SequenceFlow_0klb3ey"> + <di:waypoint x="923" y="801" /> + <di:waypoint x="1005" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0n4xku8_di" bpmnElement="SequenceFlow_0n4xku8"> + <di:waypoint x="538" y="801" /> + <di:waypoint x="645" y="801" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="584" y="783" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1c6ka9h_di" bpmnElement="SequenceFlow_1c6ka9h"> + <di:waypoint x="513" y="826" /> + <di:waypoint x="513" y="926" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="521" y="832" width="15" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0mlrlbv_di" bpmnElement="SequenceFlow_0mlrlbv"> + <di:waypoint x="385" y="801" /> + <di:waypoint x="488" y="801" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_18kur12_di" bpmnElement="SequenceFlow_18kur12"> + <di:waypoint x="1293" y="289" /> + <di:waypoint x="1371" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0it2g9j_di" bpmnElement="SequenceFlow_0it2g9j"> + <di:waypoint x="1471" y="289" /> + <di:waypoint x="1584" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g8m7tq_di" bpmnElement="SequenceFlow_1g8m7tq"> + <di:waypoint x="745" y="289" /> + <di:waypoint x="830" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1p8vxo5_di" bpmnElement="SequenceFlow_1p8vxo5"> + <di:waypoint x="567" y="289" /> + <di:waypoint x="645" y="289" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1t19ips_di" bpmnElement="SequenceFlow_1t19ips"> + <di:waypoint x="1380" y="121" /> + <di:waypoint x="1440" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> + <di:waypoint x="1065" y="481" /> + <di:waypoint x="1065" y="645" /> + <di:waypoint x="1193" y="645" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1067" y="560" width="27" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> + <di:waypoint x="1090" y="456" /> + <di:waypoint x="1193" y="456" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1121.5" y="438" width="42" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> + <di:waypoint x="930" y="456" /> + <di:waypoint x="1040" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1cv0wop_di" bpmnElement="SequenceFlow_1cv0wop"> + <di:waypoint x="745" y="456" /> + <di:waypoint x="830" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> + <di:waypoint x="350" y="121" /> + <di:waypoint x="410" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> + <di:waypoint x="214" y="121" /> + <di:waypoint x="250" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1l8mfej_di" bpmnElement="Flow_1l8mfej"> + <di:waypoint x="785" y="121" /> + <di:waypoint x="830" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0vq2rmw_di" bpmnElement="Flow_0vq2rmw"> + <di:waypoint x="930" y="121" /> + <di:waypoint x="1000" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1u4srgq_di" bpmnElement="Flow_1u4srgq"> + <di:waypoint x="1100" y="121" /> + <di:waypoint x="1140" y="121" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> <dc:Bounds x="178" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -475,9 +667,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="168" y="481" width="60" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> - <dc:Bounds x="285" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1jgtb0y_di" bpmnElement="ScriptTask_1jgtb0y"> <dc:Bounds x="830" y="416" width="100" height="80" /> </bpmndi:BPMNShape> @@ -487,12 +676,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="1027" y="413" width="78" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0l3d1ai_di" bpmnElement="ScriptTask_0l3d1ai"> - <dc:Bounds x="1370" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1eo3m4q_di" bpmnElement="ScriptTask_1eo3m4q"> - <dc:Bounds x="830" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_139l55g_di" bpmnElement="CallActivity_139l55g"> <dc:Bounds x="645" y="249" width="100" height="80" /> </bpmndi:BPMNShape> @@ -514,9 +697,53 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="EndEvent_0x406rw_di" bpmnElement="EndEvent_0x406rw"> <dc:Bounds x="495" y="926" width="36" height="36" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0l3d1ai_di" bpmnElement="ScriptTask_0l3d1ai"> + <dc:Bounds x="1440" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1bnkmaz_di" bpmnElement="CallActivity_1bnkmaz"> + <dc:Bounds x="1280" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0o2r07o_di" bpmnElement="ScriptTask_0o2r07o"> + <dc:Bounds x="1140" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="250" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0yce5sp_di" bpmnElement="Activity_12v8ykp"> + <dc:Bounds x="1000" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0uymgnp_di" bpmnElement="Activity_1ge49xu"> + <dc:Bounds x="830" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1eo3m4q_di" bpmnElement="ScriptTask_1eo3m4q"> + <dc:Bounds x="685" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0kd6p6p_di" bpmnElement="ServiceTask_0kd6p6p"> + <dc:Bounds x="550" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> + <dc:Bounds x="410" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> <dc:Bounds x="685" y="1080" width="781" height="196" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1079" y="1184" /> + <di:waypoint x="1353" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="751" y="1184" /> + <di:waypoint x="979" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="715" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1353" y="1166" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="979" y="1144" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1ef3voz_di" bpmnElement="ScriptTask_1ef3voz"> <dc:Bounds x="823" y="761" width="100" height="80" /> </bpmndi:BPMNShape> @@ -526,9 +753,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <dc:Bounds x="1593" y="826" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1xxag1o_di" bpmnElement="ScriptTask_1xxag1o"> - <dc:Bounds x="468" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_1ex8ke9_di" bpmnElement="IntermediateThrowEvent_1ex8ke9"> <dc:Bounds x="1584" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -544,15 +768,6 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> <dc:Bounds x="1197" y="761" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0kd6p6p_di" bpmnElement="ServiceTask_0kd6p6p"> - <dc:Bounds x="645" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1bnkmaz_di" bpmnElement="CallActivity_1bnkmaz"> - <dc:Bounds x="1193" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0o2r07o_di" bpmnElement="ScriptTask_0o2r07o"> - <dc:Bounds x="1015" y="81" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0b7senu_di" bpmnElement="ScriptTask_0b7senu"> <dc:Bounds x="285" y="249" width="100" height="80" /> </bpmndi:BPMNShape> @@ -613,197 +828,18 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="EndEvent_0bh0kwx_di" bpmnElement="EndEvent_0bh0kwx"> <dc:Bounds x="317" y="593" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> - <di:waypoint x="214" y="121" /> - <di:waypoint x="285" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> - <di:waypoint x="385" y="121" /> - <di:waypoint x="468" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1cv0wop_di" bpmnElement="SequenceFlow_1cv0wop"> - <di:waypoint x="745" y="456" /> - <di:waypoint x="830" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> - <di:waypoint x="930" y="456" /> - <di:waypoint x="1040" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> - <di:waypoint x="1090" y="456" /> - <di:waypoint x="1193" y="456" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1121.5" y="438" width="42" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> - <di:waypoint x="1065" y="481" /> - <di:waypoint x="1065" y="645" /> - <di:waypoint x="1193" y="645" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1067" y="560" width="27" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1t19ips_di" bpmnElement="SequenceFlow_1t19ips"> - <di:waypoint x="1293" y="121" /> - <di:waypoint x="1370" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1p8vxo5_di" bpmnElement="SequenceFlow_1p8vxo5"> - <di:waypoint x="567" y="289" /> - <di:waypoint x="645" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1g8m7tq_di" bpmnElement="SequenceFlow_1g8m7tq"> - <di:waypoint x="745" y="289" /> - <di:waypoint x="830" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0it2g9j_di" bpmnElement="SequenceFlow_0it2g9j"> - <di:waypoint x="1471" y="289" /> - <di:waypoint x="1584" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_18kur12_di" bpmnElement="SequenceFlow_18kur12"> - <di:waypoint x="1293" y="289" /> - <di:waypoint x="1371" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0mlrlbv_di" bpmnElement="SequenceFlow_0mlrlbv"> - <di:waypoint x="385" y="801" /> - <di:waypoint x="488" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1c6ka9h_di" bpmnElement="SequenceFlow_1c6ka9h"> - <di:waypoint x="513" y="826" /> - <di:waypoint x="513" y="926" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="521" y="832" width="15" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0n4xku8_di" bpmnElement="SequenceFlow_0n4xku8"> - <di:waypoint x="538" y="801" /> - <di:waypoint x="645" y="801" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="584" y="783" width="18" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0klb3ey_di" bpmnElement="SequenceFlow_0klb3ey"> - <di:waypoint x="923" y="801" /> - <di:waypoint x="1005" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_11rbv41_di" bpmnElement="SequenceFlow_11rbv41"> - <di:waypoint x="1475" y="801" /> - <di:waypoint x="1585" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0t094g7_di" bpmnElement="SequenceFlow_0t094g7"> - <di:waypoint x="568" y="121" /> - <di:waypoint x="645" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1o1tu0f_di" bpmnElement="SequenceFlow_1o1tu0f"> - <di:waypoint x="214" y="289" /> - <di:waypoint x="285" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0lbdfmt_di" bpmnElement="SequenceFlow_0lbdfmt"> - <di:waypoint x="1105" y="801" /> - <di:waypoint x="1197" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> - <di:waypoint x="1297" y="801" /> - <di:waypoint x="1375" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0q7yc2c_di" bpmnElement="SequenceFlow_0q7yc2c"> - <di:waypoint x="1115" y="121" /> - <di:waypoint x="1193" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1sq6kp6_di" bpmnElement="SequenceFlow_1sq6kp6"> - <di:waypoint x="385" y="289" /> - <di:waypoint x="467" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny"> - <di:waypoint x="1293" y="456" /> - <di:waypoint x="1371" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975"> - <di:waypoint x="1471" y="456" /> - <di:waypoint x="1584" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0h2oree_di" bpmnElement="SequenceFlow_0h2oree"> - <di:waypoint x="567" y="456" /> - <di:waypoint x="645" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh"> - <di:waypoint x="1293" y="645" /> - <di:waypoint x="1371" y="645" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx"> - <di:waypoint x="1471" y="645" /> - <di:waypoint x="1584" y="645" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1bevt3a_di" bpmnElement="SequenceFlow_1bevt3a"> - <di:waypoint x="214" y="801" /> - <di:waypoint x="285" y="801" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ey6m1e_di" bpmnElement="SequenceFlow_1ey6m1e"> - <di:waypoint x="930" y="289" /> - <di:waypoint x="1015" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> - <dc:Bounds x="715" y="1166" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> - <dc:Bounds x="1353" y="1166" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> - <dc:Bounds x="979" y="1144" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> - <di:waypoint x="751" y="1184" /> - <di:waypoint x="979" y="1184" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> - <di:waypoint x="1079" y="1184" /> - <di:waypoint x="1353" y="1184" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ReceiveTask_0zkpdpa_di" bpmnElement="Task_1b5t88h"> <dc:Bounds x="285" y="416" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1fk37v7_di" bpmnElement="SequenceFlow_1fk37v7"> - <di:waypoint x="214" y="456" /> - <di:waypoint x="285" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_16uz2t9_di" bpmnElement="SequenceFlow_16uz2t9"> - <di:waypoint x="385" y="456" /> - <di:waypoint x="467" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="BoundaryEvent_15igwk2_di" bpmnElement="BoundaryEvent_0clo9pv"> - <dc:Bounds x="317" y="478" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_12qt5ci_di" bpmnElement="SequenceFlow_12qt5ci"> - <di:waypoint x="335" y="514" /> - <di:waypoint x="335" y="611" /> - <di:waypoint x="335" y="593" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0v4mw2x_di" bpmnElement="CallActivity_0v4mw2x"> <dc:Bounds x="1015" y="249" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1aaozcg_di" bpmnElement="SequenceFlow_1aaozcg"> - <di:waypoint x="1115" y="289" /> - <di:waypoint x="1193" y="289" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_046irye_di" bpmnElement="SequenceFlow_046irye"> - <di:waypoint x="745" y="121" /> - <di:waypoint x="830" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1o23s0i_di" bpmnElement="SequenceFlow_1o23s0i"> - <di:waypoint x="930" y="121" /> - <di:waypoint x="1015" y="121" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0jrclmc_di" bpmnElement="SequenceFlow_0jrclmc"> - <di:waypoint x="1470" y="121" /> - <di:waypoint x="1584" y="121" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> <dc:Bounds x="645" y="761" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> - <di:waypoint x="745" y="801" /> - <di:waypoint x="823" y="801" /> - </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BoundaryEvent_15igwk2_di" bpmnElement="BoundaryEvent_0clo9pv"> + <dc:Bounds x="317" y="478" width="36" height="36" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn index 1722137056..36f6221da9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn @@ -56,7 +56,7 @@ taskProcessor.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_05haut5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_09y0mpc</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_00psvtk" name="Call FalloutHandler" calledElement="FalloutHandler"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn index 5d523194bb..8b1b8367f8 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.0"> - <bpmn:process id="PNFSWUPDownload" name="PNFSWUPDownload" isExecutable="true"> + <bpmn:process id="GenericPnfSWUPDownload" name="GenericPnfSWUPDownload" isExecutable="true"> <bpmn:startEvent id="download_StartEvent" name="Start Flow"> <bpmn:outgoing>SequenceFlow_1fdclh0</bpmn:outgoing> </bpmn:startEvent> @@ -95,7 +95,7 @@ <bpmn:incoming>SequenceFlow_0swi04u</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ppn4a8</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_0ikcgtm" name="Call FalloutHandler" calledElement="FalloutHandler"> @@ -117,7 +117,7 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_0kusy70</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12155q6</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0kusy70" sourceRef="ServiceTask_1mpt2eq" targetRef="ScriptTask_1ankfw8" /> @@ -125,7 +125,7 @@ pnfSwUpgrade.sendResponse(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_1d2rfyx</bpmn:incoming> <bpmn:outgoing>SequenceFlow_183s0wo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_0tq2dug" name="Complete Process" calledElement="CompleteMsoProcess"> @@ -143,7 +143,7 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:process> <bpmn:error id="Error_1q14dnd" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSWUPDownload"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPnfSWUPDownload"> <bpmndi:BPMNShape id="StartEvent_1k8gssq_di" bpmnElement="download_StartEvent"> <dc:Bounds x="172" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn index 4ff0af4549..f4a6196fc1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.0"> - <bpmn:process id="PNFSoftwareUpgrade" name="PNFSoftwareUpgrade" isExecutable="true"> + <bpmn:process id="GenericPnfSoftwareUpgrade" name="GenericPnfSoftwareUpgrade" isExecutable="true"> <bpmn:startEvent id="softwareUpgrade_startEvent" name="Start Flow"> <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> </bpmn:startEvent> @@ -123,7 +123,7 @@ <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ks3p41</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0ks3p41" sourceRef="ScriptTask_10klpg8" targetRef="ServiceTask_0slpahe" /> @@ -131,7 +131,7 @@ pnfSwUpgrade.sendResponse(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_1atiydu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ipc3nt</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_0ipc3nt" sourceRef="ScriptTask_1igtc83" targetRef="CallActivity_0o1mi8u" /> @@ -152,7 +152,7 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_05haut5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_09y0mpc</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_00psvtk" name="Call FalloutHandler" calledElement="FalloutHandler"> @@ -173,7 +173,7 @@ pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:process> <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSoftwareUpgrade"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPnfSoftwareUpgrade"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="softwareUpgrade_startEvent"> <dc:Bounds x="162" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn index a1d4178962..3d37430723 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn @@ -55,14 +55,14 @@ <bpmn:incoming>Flow_1b392qs</bpmn:incoming> <bpmn:outgoing>Flow_1v0mxe7</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="Activity_1n4rk7m" name="Prepare Completion" scriptFormat="groovy"> <bpmn:incoming>Flow_0l67uzl</bpmn:incoming> <bpmn:outgoing>Flow_0frhsd0</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_1lz38px" name="Complete Process" calledElement="CompleteMsoProcess"> @@ -78,7 +78,7 @@ pnfSwUpgrade.prepareCompletion(execution)</bpmn:script> <bpmn:incoming>Flow_0iayg6u</bpmn:incoming> <bpmn:outgoing>Flow_0lb7zv5</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_0ai3z2q" name="Call FalloutHandler" calledElement="FalloutHandler"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index ad0732df4d..3ed1999d9a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -1,17 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="DoCreateSliceServiceOption" name="DoCreateSliceServiceOption" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent" name="createOption_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> </bpmn:startEvent> <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" /> <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="Task_09nzhwk" /> - <bpmn:scriptTask id="Task_09nzhwk" name="send request to OOF for NSI options" scriptFormat="groovy"> + <bpmn:scriptTask id="Task_09nzhwk" name="Prepare OOF Select NSI options request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1utpplq</bpmn:outgoing> + <bpmn:outgoing>Flow_15c2jcx</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() -dcso.getNSIOptionfromOOF(execution)</bpmn:script> +dcso.prepareSelectNSIRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> @@ -73,7 +73,6 @@ dcso.prepareNSSTDecompose(execution)</bpmn:script> <bpmn:outgoing>SequenceFlow_0a5f5y6</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_0a5f5y6" sourceRef="CallActivity_1rfnoe2" targetRef="ScriptTask_1mlytov" /> - <bpmn:sequenceFlow id="SequenceFlow_1utpplq" sourceRef="Task_09nzhwk" targetRef="ScriptTask_1umbyel" /> <bpmn:exclusiveGateway id="ExclusiveGateway_1skfk7w" default="SequenceFlow_0wy6oag"> <bpmn:incoming>SequenceFlow_0d774n5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0wy6oag</bpmn:outgoing> @@ -84,7 +83,7 @@ dcso.prepareNSSTDecompose(execution)</bpmn:script> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:scriptTask id="ScriptTask_1umbyel" name="prepare NST decomposition" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1utpplq</bpmn:incoming> + <bpmn:incoming>Flow_07ustqm</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0piifl1</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() @@ -112,124 +111,159 @@ dcso.prepareNSTDecompose(execution)</bpmn:script> def dcso = new DoCreateSliceServiceOption() dcso.processDecomposition(execution)</bpmn:script> </bpmn:scriptTask> + <bpmn:callActivity id="Activity_0dlr4ra" name="Handle NSI Selection OOF request" calledElement="DoHandleOofRequest"> + <bpmn:extensionElements> + <camunda:in source="nsiSelectionUrl" target="apiPath" /> + <camunda:in source="nsiSelection_correlator" target="correlator" /> + <camunda:in source="nsiSelection_messageType" target="messageType" /> + <camunda:in source="nsiSelection_timeout" target="timeout" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:out source="asyncCallbackResponse" target="nsiSelection_oofResponse" /> + <camunda:in source="nsiSelection_oofRequest" target="oofRequest" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_15c2jcx</bpmn:incoming> + <bpmn:outgoing>Flow_1mcx2ja</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="Activity_049mjag" name="Process OOF response " scriptFormat="groovy"> + <bpmn:incoming>Flow_1mcx2ja</bpmn:incoming> + <bpmn:outgoing>Flow_07ustqm</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processOOFResponse(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1mcx2ja" sourceRef="Activity_0dlr4ra" targetRef="Activity_049mjag" /> + <bpmn:sequenceFlow id="Flow_15c2jcx" sourceRef="Task_09nzhwk" targetRef="Activity_0dlr4ra" /> + <bpmn:sequenceFlow id="Flow_07ustqm" sourceRef="Activity_049mjag" targetRef="ScriptTask_1umbyel" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> - <dc:Bounds x="175" y="107" width="36" height="36" /> + <bpmndi:BPMNEdge id="SequenceFlow_0d774n5_di" bpmnElement="SequenceFlow_0d774n5"> + <di:waypoint x="1220" y="125" /> + <di:waypoint x="1275" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_086yszq_di" bpmnElement="SequenceFlow_086yszq"> + <di:waypoint x="1060" y="125" /> + <di:waypoint x="1120" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0piifl1_di" bpmnElement="SequenceFlow_0piifl1"> + <di:waypoint x="920" y="125" /> + <di:waypoint x="960" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> + <di:waypoint x="1325" y="125" /> + <di:waypoint x="1993" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> + <di:waypoint x="1300" y="150" /> + <di:waypoint x="1300" y="351" /> + <di:waypoint x="1430" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> + <di:waypoint x="2061" y="351" /> + <di:waypoint x="2148" y="351" /> + <di:waypoint x="2148" y="493" /> + <di:waypoint x="1960" y="493" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> + <di:waypoint x="1872" y="351" /> + <di:waypoint x="1961" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> + <di:waypoint x="1860" y="493" /> + <di:waypoint x="1666" y="493" /> + <di:waypoint x="1666" y="376" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> + <di:waypoint x="1691" y="351" /> + <di:waypoint x="1772" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> + <di:waypoint x="1530" y="351" /> + <di:waypoint x="1641" y="351" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> + <di:waypoint x="1666" y="326" /> + <di:waypoint x="1666" y="235" /> + <di:waypoint x="2011" y="235" /> + <di:waypoint x="2011" y="143" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="350" y="125" /> + <di:waypoint x="390" y="125" /> <bpmndi:BPMNLabel> - <dc:Bounds x="151" y="143" width="86" height="27" /> + <dc:Bounds x="436" y="108" width="0" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> - <di:waypoint x="211" y="125" /> - <di:waypoint x="251" y="125" /> - <di:waypoint x="251" y="125" /> - <di:waypoint x="293" y="125" /> + <di:waypoint x="218" y="125" /> + <di:waypoint x="250" y="125" /> <bpmndi:BPMNLabel> <dc:Bounds x="266" y="123" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> - <di:waypoint x="393" y="125" /> - <di:waypoint x="460" y="125" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="436" y="108" width="0" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="Flow_1mcx2ja_di" bpmnElement="Flow_1mcx2ja"> + <di:waypoint x="640" y="125" /> + <di:waypoint x="680" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_15c2jcx_di" bpmnElement="Flow_15c2jcx"> + <di:waypoint x="490" y="122" /> + <di:waypoint x="540" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_07ustqm_di" bpmnElement="Flow_07ustqm"> + <di:waypoint x="780" y="125" /> + <di:waypoint x="820" y="125" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> - <dc:Bounds x="460" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> - <dc:Bounds x="293" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> - <dc:Bounds x="1813" y="107" width="36" height="36" /> + <dc:Bounds x="1993" y="107" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="412" y="617" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0kecvrc_di" bpmnElement="ScriptTask_0kecvrc"> - <dc:Bounds x="1250" y="311" width="100" height="80" /> + <dc:Bounds x="1430" y="311" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1mlytov_di" bpmnElement="ScriptTask_1mlytov"> - <dc:Bounds x="1680" y="453" width="100" height="80" /> + <dc:Bounds x="1860" y="453" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1y1wzs9_di" bpmnElement="ExclusiveGateway_1y1wzs9" isMarkerVisible="true"> - <dc:Bounds x="1461" y="326" width="50" height="50" /> + <dc:Bounds x="1641" y="326" width="50" height="50" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> - <di:waypoint x="1486" y="326" /> - <di:waypoint x="1486" y="235" /> - <di:waypoint x="1831" y="235" /> - <di:waypoint x="1831" y="143" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> - <di:waypoint x="1350" y="351" /> - <di:waypoint x="1461" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> - <di:waypoint x="1511" y="351" /> - <di:waypoint x="1592" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> - <di:waypoint x="1680" y="493" /> - <di:waypoint x="1486" y="493" /> - <di:waypoint x="1486" y="376" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1e5ysya_di" bpmnElement="ScriptTask_1e5ysya"> - <dc:Bounds x="1592" y="311" width="100" height="80" /> + <dc:Bounds x="1772" y="311" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> - <di:waypoint x="1692" y="351" /> - <di:waypoint x="1781" y="351" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1rfnoe2_di" bpmnElement="CallActivity_1rfnoe2"> - <dc:Bounds x="1781" y="311" width="100" height="80" /> + <dc:Bounds x="1961" y="311" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> - <di:waypoint x="1881" y="351" /> - <di:waypoint x="1968" y="351" /> - <di:waypoint x="1968" y="493" /> - <di:waypoint x="1780" y="493" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1utpplq_di" bpmnElement="SequenceFlow_1utpplq"> - <di:waypoint x="560" y="125" /> - <di:waypoint x="620" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1skfk7w_di" bpmnElement="ExclusiveGateway_1skfk7w" isMarkerVisible="true"> - <dc:Bounds x="1095" y="100" width="50" height="50" /> + <dc:Bounds x="1275" y="100" width="50" height="50" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> - <di:waypoint x="1120" y="150" /> - <di:waypoint x="1120" y="351" /> - <di:waypoint x="1250" y="351" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> - <di:waypoint x="1145" y="125" /> - <di:waypoint x="1813" y="125" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1umbyel_di" bpmnElement="ScriptTask_1umbyel"> - <dc:Bounds x="620" y="85" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0piifl1_di" bpmnElement="SequenceFlow_0piifl1"> - <di:waypoint x="720" y="125" /> - <di:waypoint x="780" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0ly8xiw_di" bpmnElement="CallActivity_0ly8xiw"> - <dc:Bounds x="780" y="85" width="100" height="80" /> + <dc:Bounds x="960" y="85" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_086yszq_di" bpmnElement="SequenceFlow_086yszq"> - <di:waypoint x="880" y="125" /> - <di:waypoint x="940" y="125" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0d774n5_di" bpmnElement="SequenceFlow_0d774n5"> - <di:waypoint x="1040" y="125" /> - <di:waypoint x="1095" y="125" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1895p18_di" bpmnElement="Task_1k2ypj0"> - <dc:Bounds x="940" y="85" width="100" height="80" /> + <dc:Bounds x="1120" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> + <dc:Bounds x="182" y="107" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="158" y="143" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="250" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="390" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_049mjag_di" bpmnElement="Activity_049mjag"> + <dc:Bounds x="680" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0dlr4ra_di" bpmnElement="Activity_0dlr4ra"> + <dc:Bounds x="540" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1umbyel_di" bpmnElement="ScriptTask_1umbyel"> + <dc:Bounds x="820" y="85" width="100" height="80" /> </bpmndi:BPMNShape> </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/subprocess/DoHandleOofRequest.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn new file mode 100644 index 0000000000..7ca1a62312 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoHandleOofRequest.bpmn @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0nlt5gi" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> + <bpmn:process id="DoHandleOofRequest" name="DoHandleOofRequest" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>Flow_1jorico</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="Flow_1fbzzqg" sourceRef="Activity_0tki17o" targetRef="Activity_08ozlfa" /> + <bpmn:scriptTask id="Activity_08ozlfa" name="Call Oof Adapter" scriptFormat="groovy"> + <bpmn:incoming>Flow_1fbzzqg</bpmn:incoming> + <bpmn:outgoing>Flow_013jfci</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +def oofHandler = new DoHandleOofRequest() +oofHandler .callOofAdapter(execution) +</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_1jorico" sourceRef="StartEvent_1" targetRef="Activity_0tki17o" /> + <bpmn:scriptTask id="Activity_0tki17o" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>Flow_1jorico</bpmn:incoming> + <bpmn:outgoing>Flow_1fbzzqg</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +def oofHandler = new DoHandleOofRequest() +oofHandler .preProcessRequest(execution) +</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="Activity_02ru8n9" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> + <bpmn:startEvent id="Event_1r00tca"> + <bpmn:outgoing>Flow_072knve</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1sy4yh2" /> + </bpmn:startEvent> + <bpmn:endEvent id="Event_1rwmekw"> + <bpmn:incoming>Flow_0ykpxpc</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="Activity_11rvko0" name="Handle Unexpected Error" scriptFormat="groovy"> + <bpmn:incoming>Flow_072knve</bpmn:incoming> + <bpmn:outgoing>Flow_0ykpxpc</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0ykpxpc" sourceRef="Activity_11rvko0" targetRef="Event_1rwmekw" /> + <bpmn:sequenceFlow id="Flow_072knve" sourceRef="Event_1r00tca" targetRef="Activity_11rvko0" /> + </bpmn:subProcess> + <bpmn:callActivity id="Activity_1yq993l" name="Receive Async Callback" camunda:modelerTemplate="receiveWorkflowMessage" calledElement="ReceiveWorkflowMessage"> + <bpmn:extensionElements> + <camunda:in source="true" target="isDebugLogEnabled" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="messageType" target="RCVWFMSG_messageType" /> + <camunda:in source="correlator" target="RCVWFMSG_correlator" /> + <camunda:in source="timeout" target="RCVWFMSG_timeout" /> + <camunda:out source="WorkflowResponse" target="asyncCallbackResponse" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_013jfci</bpmn:incoming> + <bpmn:outgoing>Flow_1nmoiqi</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="Flow_013jfci" sourceRef="Activity_08ozlfa" targetRef="Activity_1yq993l" /> + <bpmn:endEvent id="Event_179tp7r" name="End event"> + <bpmn:incoming>Flow_1nmoiqi</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1nmoiqi" sourceRef="Activity_1yq993l" targetRef="Event_179tp7r" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoHandleOofRequest"> + <bpmndi:BPMNEdge id="Flow_1jorico_di" bpmnElement="Flow_1jorico"> + <di:waypoint x="218" y="130" /> + <di:waypoint x="270" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1fbzzqg_di" bpmnElement="Flow_1fbzzqg"> + <di:waypoint x="370" y="130" /> + <di:waypoint x="450" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_013jfci_di" bpmnElement="Flow_013jfci"> + <di:waypoint x="550" y="130" /> + <di:waypoint x="641" y="130" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1nmoiqi_di" bpmnElement="Flow_1nmoiqi"> + <di:waypoint x="741" y="127" /> + <di:waypoint x="832" y="127" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="182" y="112" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="154" y="142" width="87" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1nfzvjq_di" bpmnElement="Activity_0tki17o"> + <dc:Bounds x="270" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0wi75kt_di" bpmnElement="Activity_08ozlfa"> + <dc:Bounds x="450" y="90" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_1yq993l_di" bpmnElement="Activity_1yq993l"> + <dc:Bounds x="641" y="87" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_179tp7r_di" bpmnElement="Event_179tp7r"> + <dc:Bounds x="832" y="109" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="826" y="152" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_02ru8n9_di" bpmnElement="Activity_02ru8n9" isExpanded="true"> + <dc:Bounds x="160" y="420" width="781" height="196" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_0ykpxpc_di" bpmnElement="Flow_0ykpxpc"> + <di:waypoint x="554" y="524" /> + <di:waypoint x="828" y="524" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_072knve_di" bpmnElement="Flow_072knve"> + <di:waypoint x="226" y="524" /> + <di:waypoint x="454" y="524" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Event_1r00tca_di" bpmnElement="Event_1r00tca"> + <dc:Bounds x="190" y="506" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Event_1rwmekw_di" bpmnElement="Event_1rwmekw"> + <dc:Bounds x="828" y="506" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_11rvko0_di" bpmnElement="Activity_11rvko0"> + <dc:Bounds x="454" y="484" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java index a0ef90d7b8..b9c5fdf145 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java @@ -49,15 +49,15 @@ import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** - * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. + * Basic Integration test for GenericPnfSWUPDownloadTest.bpmn workflow. */ -public class PNFSWUPDownloadTest extends BaseBPMNTest { +public class GenericPnfSWUPDownloadTest extends BaseBPMNTest { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final long WORKFLOW_WAIT_TIME = 1000L; - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSWUPDownload"; private static final AAIVersion VERSION = AAIVersion.LATEST; private static final Map<String, Object> executionVariables = new HashMap(); private final String[] actionNames = new String[3]; @@ -76,8 +76,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { executionVariables.clear(); - requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); - responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); + requestObject = FileUtil.readResourceFile("request/GenericPnfSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest.json"); executionVariables.put("bpmnRequest", requestObject); @@ -136,7 +136,7 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSWUPDownload request exception", e); + fail("GenericPnfSWUPDownload request exception", e); } assertThat(count == actionNames.length); } @@ -152,7 +152,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgradeTest_catalogdb.json. */ Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); @@ -202,7 +203,8 @@ public class PNFSWUPDownloadTest extends BaseBPMNTest { */ private void mockCatalogDb() { - String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); + String catalogdbClientResponse = + FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest_catalogdb.json"); /** diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java index 0bf14d7443..de81f91e66 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java @@ -49,15 +49,15 @@ import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** - * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. + * Basic Integration test for GenericPnfSoftwareUpgrade.bpmn workflow. */ -public class PNFSoftwareUpgradeTest extends BaseBPMNTest { +public class GenericPnfSoftwareUpgradeTest extends BaseBPMNTest { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final long WORKFLOW_WAIT_TIME = 1000L; - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSoftwareUpgrade"; private static final AAIVersion VERSION = AAIVersion.LATEST; private static final Map<String, Object> executionVariables = new HashMap(); private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; @@ -140,7 +140,7 @@ public class PNFSoftwareUpgradeTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); + fail("GenericPnfSoftwareUpgrade request exception", e); } assertThat(count == actionNames.length); } @@ -156,7 +156,8 @@ public class PNFSoftwareUpgradeTest extends BaseBPMNTest { ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgrade_catalogdb.json. */ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java index 00dda299b6..bdad46f3ca 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java @@ -145,7 +145,7 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); + fail("GenericPnfSoftwareUpgrade request exception", e); } assertThat(count == actionNames.length); } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json index a101118623..a101118623 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json index 32539844ba..32539844ba 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json index faec947fec..faec947fec 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java new file mode 100644 index 0000000000..93d30512b6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.cnf.CnfAdapterClient; +import org.onap.so.client.adapter.cnf.entities.InstanceRequest; +import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +import org.onap.so.client.adapter.vnf.mapper.AttributeNameValue; +import org.onap.so.client.adapter.vnf.mapper.Attributes; +import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class CnfAdapterCreateTasks { + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterCreateTasks.class); + public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private CnfAdapterClient cnfAdapterClient; + @Autowired + private VnfAdapterVfModuleObjectMapper vfModuleMapper; + + private ObjectMapper mapper = new ObjectMapper(); + + /** + * This method is used for creating the request for an Instance in Multicloud K8s Plugin. + * + * @param execution + * @return + */ + public void createInstance(BuildingBlockExecution execution) { + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + ServiceInstance serviceInstance = + gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + RequestContext requestContext = gBBInput.getRequestContext(); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId()); + String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId()); + Map<String, Object> paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, + genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + Map<String, String> sdncDirectives = getSdncDirectives(paramsMap); + InstanceRequest createInstanceRequest = createInstanceRequest(vfModule, cloudRegion, sdncDirectives); + InstanceResponse response = cnfAdapterClient.createVfModule(createInstanceRequest); + execution.setVariable("heatStackId", response.getId()); + } catch (Exception ex) { + logger.error("Exception occurred", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + protected Map<String, String> getSdncDirectives(Map<String, Object> paramsMap) + throws JsonParseException, JsonMappingException, IOException { + Map<String, String> sdncDirectivesMap = new HashMap<>(); + String sdncDirectivesString = (String) paramsMap.get(MsoMulticloudUtils.SDNC_DIRECTIVES); + Attributes sdncDirectives = mapper.readValue(sdncDirectivesString, Attributes.class); + for (AttributeNameValue nameVal : sdncDirectives.getAttributes()) { + sdncDirectivesMap.put(nameVal.getAttributeName(), (String) nameVal.getAttributeValue()); + } + return sdncDirectivesMap; + } + + protected InstanceRequest createInstanceRequest(VfModule vfModule, CloudRegion cloudRegion, + Map<String, String> sdncDirectives) { + InstanceRequest request = new InstanceRequest(); + request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID()); + request.setCloudRegion(cloudRegion.getLcpCloudRegionId()); + request.setReleaseName(vfModule.getVfModuleId()); + request.setProfileName(sdncDirectives.get("k8s-rb-profile-name")); + request.setOverrideValues(sdncDirectives); + return request; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java index d94641846d..7b73fff20c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java @@ -45,7 +45,7 @@ public class ServiceLevelConstants { Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck"); public static final Map<String, String> DEFAULT_SOFTWARE_UP_WORKFLOWS = - Map.of(PNF, "PNFSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); + Map.of(PNF, "GenericPnfSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); // Maps operation name with workflows public static final Map<String, Map<String, String>> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 75d3ddf2e6..9b9433afdb 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -300,6 +300,9 @@ public class WorkflowAction { || ("recreateInstance".equalsIgnoreCase(requestAction)))) { traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds); + } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) { + customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), + workflowResourceIds.getVnfId(), aaiResourceIds); } else { buildAndThrowException(execution, "Current Macro Request is not supported"); } @@ -568,6 +571,10 @@ public class WorkflowAction { WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds()); org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + if (configuration == null) { + logger.warn(String.format("No configuration found for VNFC %s in AAI", vnfc.getVnfcName())); + continue; + } workflowIdsCopy.setConfigurationId(configuration.getConfigurationId()); for (OrchestrationFlow orchFlow : result) { dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); @@ -584,7 +591,6 @@ public class WorkflowAction { dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy, dataObj.getRequestDetails(), false, null, vnfcName, true, null); flowsToExecuteConfigs.add(ebb); - } } return flowsToExecuteConfigs; @@ -1108,6 +1114,51 @@ public class WorkflowAction { } } + private void customTraverseAAIVnf(DelegateExecution execution, List<Resource> resourceList, String serviceId, + String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) { + try { + ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = + bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); + resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); + if (serviceInstanceMSO.getVnfs() != null) { + for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { + if (vnf.getVnfId().equals(vnfId)) { + aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); + + String vnfCustomizationUUID = + bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); + resourceList.add(new Resource(WorkflowType.VNF, vnfCustomizationUUID, false)); + + if (vnf.getVfModules() != null) { + for (VfModule vfModule : vnf.getVfModules()) { + aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); + resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false)); + findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), + resourceList, aaiResourceIds); + } + } + if (vnf.getVolumeGroups() != null) { + for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf + .getVolumeGroups()) { + aaiResourceIds + .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); + resourceList.add( + new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); + } + } + break; + } + } + } + } catch (Exception ex) { + logger.error("Exception in customTraverseAAIVnf", ex); + buildAndThrowException(execution, + "Could not find existing Vnf or related Instances to execute the request on."); + } + + } + private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) { try { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java new file mode 100644 index 0000000000..f44c15ac54 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.adapter.cnf; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.EntityNotFoundException; +import javax.ws.rs.core.UriBuilder; +import org.apache.http.HttpStatus; +import org.onap.so.client.adapter.cnf.entities.InstanceRequest; +import org.onap.so.client.adapter.cnf.entities.InstanceResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; +import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.RestTemplate; + +@Component +public class CnfAdapterClient { + + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterClient.class); + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private Environment env; + + private static final String INSTANCE_CREATE_PATH = "/api/multicloud-k8s/v1/v1/instance"; + + @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) + public InstanceResponse createVfModule(InstanceRequest request) throws CnfAdapterClientException { + try { + // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well + // for configuration + String uri = "https://localhost:32780"; // TODO: What is the correct uri? + String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString(); + HttpEntity<?> entity = getHttpEntity(request); + ResponseEntity<InstanceResponse> result = + restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class); + return result.getBody(); + } catch (HttpClientErrorException e) { + logger.error("Error Calling CNF Adapter, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } + } + + protected HttpHeaders getHttpHeaders() { + HttpHeaders headers = new HttpHeaders(); + List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + /* + * try { String userCredentials = CryptoUtils.decrypt(env.getRequiredProperty("mso.cnf.adapter.auth"), + * env.getRequiredProperty("mso.msoKey")); if (userCredentials != null) { headers.add(HttpHeaders.AUTHORIZATION, + * "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } } catch + * (GeneralSecurityException e) { logger.error("Security exception", e); } + */ + return headers; + } + + protected HttpEntity<?> getHttpEntity(InstanceRequest request) { + HttpHeaders headers = getHttpHeaders(); + return new HttpEntity<>(request, headers); + } + +} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyTokenProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClientException.java index 7c31d9288f..d716070ffa 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyTokenProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClientException.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.base.client; +package org.onap.so.client.adapter.cnf; -public interface CloudifyTokenProvider { +public class CnfAdapterClientException extends Exception { - String getToken(); + /** + * + */ + private static final long serialVersionUID = -7154784472485852602L; - void expireToken(); + public CnfAdapterClientException(String message) { + super(message); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java new file mode 100644 index 0000000000..3ed6894fcf --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/GVK.java @@ -0,0 +1,49 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"Group", "Version", "Kind"}) +public class GVK { + + @JsonProperty("Group") + private String group; + @JsonProperty("Version") + private String version; + @JsonProperty("Kind") + private String kind; + + @JsonProperty("Group") + public String getGroup() { + return group; + } + + @JsonProperty("Group") + public void setGroup(String group) { + this.group = group; + } + + @JsonProperty("Version") + public String getVersion() { + return version; + } + + @JsonProperty("Version") + public void setVersion(String version) { + this.version = version; + } + + @JsonProperty("Kind") + public String getKind() { + return kind; + } + + @JsonProperty("Kind") + public void setKind(String kind) { + this.kind = kind; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java new file mode 100644 index 0000000000..e4058097ab --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java @@ -0,0 +1,95 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"rb-name", "rb-version", "profile-name", "release-name", "cloud-region", "labels", + "override-values"}) +public class InstanceRequest { + + @JsonProperty("rb-name") + private String rbName; + @JsonProperty("rb-version") + private String rbVersion; + @JsonProperty("profile-name") + private String profileName; + @JsonProperty("release-name") + private String releaseName; + @JsonProperty("cloud-region") + private String cloudRegion; + @JsonProperty("labels") + private Labels labels; + @JsonProperty(value = "override-values") + private Map<String, String> overrideValues; + + @JsonProperty("rb-name") + public String getRbName() { + return rbName; + } + + @JsonProperty("rb-name") + public void setRbName(String rbName) { + this.rbName = rbName; + } + + @JsonProperty("rb-version") + public String getRbVersion() { + return rbVersion; + } + + @JsonProperty("rb-version") + public void setRbVersion(String rbVersion) { + this.rbVersion = rbVersion; + } + + @JsonProperty("profile-name") + public String getProfileName() { + return profileName; + } + + @JsonProperty("profile-name") + public void setProfileName(String profileName) { + this.profileName = profileName; + } + + @JsonProperty("cloud-region") + public String getCloudRegion() { + return cloudRegion; + } + + @JsonProperty("cloud-region") + public void setCloudRegion(String cloudRegion) { + this.cloudRegion = cloudRegion; + } + + @JsonProperty("labels") + public Labels getLabels() { + return labels; + } + + @JsonProperty("labels") + public void setLabels(Labels labels) { + this.labels = labels; + } + + public String getReleaseName() { + return releaseName; + } + + public void setReleaseName(String releaseName) { + this.releaseName = releaseName; + } + + public Map<String, String> getOverrideValues() { + return overrideValues; + } + + public void setOverrideValues(Map<String, String> overrideValues) { + this.overrideValues = overrideValues; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java new file mode 100644 index 0000000000..e38bcc2664 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java @@ -0,0 +1,62 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "request", "namespace", "resources"}) +public class InstanceResponse { + + @JsonProperty("id") + private String id; + @JsonProperty("request") + private InstanceRequest request; + @JsonProperty("namespace") + private String namespace; + @JsonProperty("resources") + private List<Resource> resources = null; + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("request") + public InstanceRequest getRequest() { + return request; + } + + @JsonProperty("request") + public void setRequest(InstanceRequest request) { + this.request = request; + } + + @JsonProperty("namespace") + public String getNamespace() { + return namespace; + } + + @JsonProperty("namespace") + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @JsonProperty("resources") + public List<Resource> getResources() { + return resources; + } + + @JsonProperty("resources") + public void setResources(List<Resource> resources) { + this.resources = resources; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java new file mode 100644 index 0000000000..1df2e59459 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Labels.java @@ -0,0 +1,25 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"testCaseName"}) +public class Labels { + + @JsonProperty("testCaseName") + private String testCaseName; + + @JsonProperty("testCaseName") + public String getTestCaseName() { + return testCaseName; + } + + @JsonProperty("testCaseName") + public void setTestCaseName(String testCaseName) { + this.testCaseName = testCaseName; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java new file mode 100644 index 0000000000..bde495aaa2 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/Resource.java @@ -0,0 +1,37 @@ + +package org.onap.so.client.adapter.cnf.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"GVK", "Name"}) +public class Resource { + + @JsonProperty("GVK") + private GVK gVK; + @JsonProperty("Name") + private String name; + + @JsonProperty("GVK") + public GVK getGVK() { + return gVK; + } + + @JsonProperty("GVK") + public void setGVK(GVK gVK) { + this.gVK = gVK; + } + + @JsonProperty("Name") + public String getName() { + return name; + } + + @JsonProperty("Name") + public void setName(String name) { + this.name = name; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java new file mode 100644 index 0000000000..6d79c20616 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/Attributes.java @@ -0,0 +1,23 @@ +package org.onap.so.client.adapter.vnf.mapper; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Attributes implements Serializable { + + private static final long serialVersionUID = -5782985934617532582L; + + @JsonProperty("attributes") + private List<AttributeNameValue> attributes = new ArrayList<>(); + + public List<AttributeNameValue> getAttributes() { + return attributes; + } + + public void setAttributes(List<AttributeNameValue> attributes) { + this.attributes = attributes; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index bc618e17de..59da22f8e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -178,7 +178,7 @@ public class VnfAdapterVfModuleObjectMapper { return msoRequest; } - private Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, + public Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws IOException, MissingValueTagException { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 407a844c4e..c1970ec32c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -1601,6 +1601,79 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void getConfigBuildingBlocksNullConfigurationTest() throws Exception { + String gAction = "deleteInstance"; + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); + + WorkflowType resourceType = WorkflowType.VFMODULE; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("vnfId", "1234"); + execution.setVariable("vfModuleId", "vfModuleId1234"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = "deleteInstance"; + String requestId = "9c944122-d161-4280-8594-48c06a9d96d5"; + boolean aLaCarte = true; + String apiVersion = "7"; + String vnfType = "vnfType"; + String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0"; + String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e"; + Resource resourceKey = new Resource(resourceType, key, aLaCarte); + WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution); + + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "UnassignVfModuleBB", "DeleteFabricConfigurationBB"); + + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("vnf0"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setModelCustomizationId("modelCustomizationId"); + + /* this is a test case where configuration for vnfc is null */ + org.onap.aai.domain.yang.Configuration config1 = null; + org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration(); + config2.setConfigurationId("config2"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc(); + vnfc1.setVnfcName("zauk53avetd02svm001"); + org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc(); + vnfc2.setVnfcName("zauk53avetd02tvm001"); + vnfcs.add(vnfc1); + vnfcs.add(vnfc2); + + when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); + doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), + eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), + eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + + List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); + + assertFalse(results.isEmpty()); + assertEquals(1, results.size()); + assertEquals("config2", results.get(0).getWorkflowResourceIds().getConfigurationId()); + assertEquals("zauk53avetd02tvm001", results.get(0).getConfigurationResourceKeys().getVnfcName()); + } + + @Test public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; diff --git a/cloudify-client/.gitignore b/cloudify-client/.gitignore deleted file mode 100644 index ae3c172604..0000000000 --- a/cloudify-client/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/cloudify-client/pom.xml b/cloudify-client/pom.xml deleted file mode 100644 index ccf2c4270e..0000000000 --- a/cloudify-client/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so</groupId> - <artifactId>so</artifactId> - <version>1.7.1-SNAPSHOT</version> - </parent> - - <groupId>org.onap.so</groupId> - <artifactId>cloudify-client</artifactId> - <packaging>jar</packaging> - <name>Cloudify Rest Client</name> - <description>Java client for Cloudify REST interface</description> - - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <!--<version>2.6</version>--> - <version>3.0.2</version> - <configuration> - <classesDirectory>target/classes</classesDirectory> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.onap.so</groupId> - <artifactId>common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.6</version> - </dependency> - </dependencies> -</project> diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyBaseException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyBaseException.java deleted file mode 100644 index b8006cb45f..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyBaseException.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -/** - * A common abstract parent of all Openstack Exception types, allowing calling classes the choice to catch all error - * exceptions together. - */ -public abstract class CloudifyBaseException extends RuntimeException { - private static final long serialVersionUID = 1L; - - /* - * Implement only the basic constructors - */ - public CloudifyBaseException() {} - - public CloudifyBaseException(String message) { - super(message); - } - - public CloudifyBaseException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java deleted file mode 100644 index d15fbf9322..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClient.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -import java.util.Properties; -import org.onap.so.cloudify.connector.http.HttpClientConnector; - -public class CloudifyClient { - - protected String managerEndpoint; - protected String tenant = "default_tenant"; // Note - only default_tenant supported in community edition - - protected CloudifyTokenProvider tokenProvider; - - protected static int AUTHENTICATION_RETRIES = 1; - - protected CloudifyClientConnector connector; - - protected Properties properties = new Properties(); - - public CloudifyClient(String managerEndpoint) { - this.managerEndpoint = managerEndpoint; - this.connector = new HttpClientConnector(); - } - - public CloudifyClient(String managerEndpoint, String tenant) { - this.managerEndpoint = managerEndpoint; - this.tenant = tenant; - this.connector = new HttpClientConnector(); - } - - public CloudifyClient(String managerEndpoint, CloudifyClientConnector connector) { - this.managerEndpoint = managerEndpoint; - this.connector = connector; - } - - /** - * Execute a Cloudify request by making the REST API call. Return the complete CloudifyResponse structure, which - * includes the complete HTTP response. - * - * @param request a CloudifyRequest object - * @return a CloudifyResponse object - */ - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - CloudifyResponseException authException = null; - - for (int i = 0; i <= AUTHENTICATION_RETRIES; i++) { - request.endpoint(managerEndpoint); - request.header("Tenant", tenant); - if (tokenProvider != null) - request.header("Authentication-Token", tokenProvider.getToken()); - - try { - return connector.request(request); - } catch (CloudifyResponseException e) { - if (e.getStatus() != CloudifyResponseStatus.NOT_AUTHORIZED || tokenProvider == null) { - throw e; - } - authException = e; - tokenProvider.expireToken(); - } - } - - if (authException != null) { - throw authException; - } - - return null; - } - - /** - * Execute a CloudifyRequest by sending the REST API call to the Cloudify Manager endpoint. The return type is a - * JSON POJO object containing the response body entity. - * - * @param request - * @return a JSON POJO object specific to the request type - */ - public <T> T execute(CloudifyRequest<T> request) { - CloudifyResponse response = request(request); - - if (null == response) { - return null; - } - - return (request.returnType() != null && request.returnType() != Void.class) - ? response.getEntity(request.returnType()) - : null; - } - - public void property(String property, String value) { - properties.put(property, value); - } - - /** - * Set a Token Provider. This class should be able to produce an authentication token on-demand. - * - * @param tokenProvider - */ - public void setTokenProvider(CloudifyTokenProvider tokenProvider) { - this.tokenProvider = tokenProvider; - } - - /** - * Manually set the authentication token to use for this client. - * - * @param token - */ - public void setToken(String token) { - setTokenProvider(new CloudifySimpleTokenProvider(token)); - } - - /** - * Perform a simple GET request with no request message body - * - * @param path - * @param returnType - * @return An object of Class <R> - */ - public <R> CloudifyRequest<R> get(String path, Class<R> returnType) { - return new CloudifyRequest<>(this, HttpMethod.GET, path, null, returnType); - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java deleted file mode 100644 index c4dcc89d0b..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProvider.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -import java.util.Date; -import org.apache.commons.lang.time.DateUtils; -import org.onap.so.cloudify.v3.client.Cloudify; -import org.onap.so.cloudify.v3.client.TokensResource.GetToken; -import org.onap.so.cloudify.v3.model.Token; - -/** - * Cloudify Token Provider that uses the Cloudify client API itself to obtain a token - * - * @author JC1348 - * - */ -public class CloudifyClientTokenProvider implements CloudifyTokenProvider { - - String user; - String password; - String token; - Date expiration; - Cloudify cloudify = null; - - public CloudifyClientTokenProvider(String cloudifyEndpoint, String user, String password) { - this.user = user; - this.password = password; - - cloudify = new Cloudify(cloudifyEndpoint); - } - - @Override - public String getToken() { - Date now = new Date(); - if (token != null && expiration != null && expiration.after(now)) { - return token; - } - - // Create a "Get Token" request. Force basic authentication to acquire the token itself. - GetToken tokenRequest = cloudify.tokens().token(); - tokenRequest.setBasicAuthentication(user, password); - Token newToken = tokenRequest.execute(); - - if (newToken != null) { - token = newToken.getValue(); - } - - if (expiration == null) { - expiration = new Date(); - } - // TODO: Make this property driven (or see if it comes back somehow in response) - expiration = DateUtils.addMinutes(expiration, 10); - - return token; - } - - @Override - /** - * This doesn't actually expire the token in Cloudify. It just prevents this token provider from using it. - */ - public void expireToken() { - expiration = null; - token = null; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyConnectException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyConnectException.java deleted file mode 100644 index 5bcc27bafc..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyConnectException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -/** - * Custom RuntimeException to report connection errors to Openstack endpoints. Must be a RuntimeException to conform - * with OpenstackClient interface, which does not declare specific Exceptions. - */ -public class CloudifyConnectException extends CloudifyBaseException { - - private static final long serialVersionUID = 7294957362769575271L; - - public CloudifyConnectException(String message) { - super(message); - } - - public CloudifyConnectException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java deleted file mode 100644 index 006768f2f1..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyRequest.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; - -public class CloudifyRequest<R> { - - private CloudifyClient client; - - private String endpoint; - - private HttpMethod method; - - private StringBuilder path = new StringBuilder(); - - private Map<String, List<Object>> headers = new HashMap<>(); - - private Entity<?> entity; - - private Class<R> returnType; - - private boolean basicAuth = false; - private String user = null; - private String password = null; - - public CloudifyRequest() { - - } - - public CloudifyRequest(CloudifyClient client, HttpMethod method, CharSequence path, Entity<?> entity, - Class<R> returnType) { - this.client = client; - this.method = method; - this.path = new StringBuilder(path); - this.entity = entity; - this.returnType = returnType; - header("Accept", "application/json"); - } - - public CloudifyRequest<R> endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - public String endpoint() { - return endpoint; - } - - public CloudifyRequest<R> method(HttpMethod method) { - this.method = method; - return this; - } - - public HttpMethod method() { - return method; - } - - public CloudifyRequest<R> path(String path) { - this.path.append(path); - return this; - } - - public String path() { - return path.toString(); - } - - public CloudifyRequest<R> header(String name, Object value) { - if (value != null) { - headers.put(name, Arrays.asList(value)); - } - return this; - } - - public Map<String, List<Object>> headers() { - return headers; - } - - public <T> Entity<T> entity(T entity, String contentType) { - return new Entity<>(entity, contentType); - } - - public Entity<?> entity() { - return entity; - } - - public <T> Entity<T> json(T entity) { - return entity(entity, "application/json"); - } - - public void returnType(Class<R> returnType) { - this.returnType = returnType; - } - - public Class<R> returnType() { - return returnType; - } - - /* - * Use Basic Authentication for this request. If not set, the client will use Token authentication if a token - * provider is defined. Otherwise, no authentication will be applied. - */ - public void setBasicAuthentication(String user, String password) { - this.basicAuth = true; - this.user = user; - this.password = password; - } - - public boolean isBasicAuth() { - return this.basicAuth; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public R execute() { - return client.execute(this); - } - - public CloudifyResponse request() { - return client.request(this); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CloudifyRequest [endpoint=" + endpoint + ", method=" + method + ", path=" + path + ", headers=" - + headers + ", entity=" + entity + ", returnType=" + returnType + "]"; - } - - private Map<String, List<Object>> queryParams = new LinkedHashMap<>(); - - public Map<String, List<Object>> queryParams() { - return queryParams; - } - - public CloudifyRequest<R> queryParam(String key, Object value) { - if (queryParams.containsKey(key)) { - List<Object> values = queryParams.get(key); - values.add(value); - } else { - List<Object> values = new ArrayList<>(); - values.add(value); - queryParams.put(key, values); - } - - return this; - } - - protected static String buildPath(String... elements) { - StringBuilder stringBuilder = new StringBuilder(); - for (String element : elements) { - stringBuilder.append(element); - } - - return stringBuilder.toString(); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponse.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponse.java deleted file mode 100644 index 6b70e5fa95..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.Map; - -public interface CloudifyResponse extends Serializable { - - public <T> T getEntity(Class<T> returnType); - - public <T> T getErrorEntity(Class<T> returnType); - - public InputStream getInputStream(); - - public String getHeader(String name); - - public Map<String, String> headers(); - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java deleted file mode 100644 index 0ca3212238..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -import org.onap.so.cloudify.v3.model.CloudifyError; - -public class CloudifyResponseException extends CloudifyBaseException { - - private static final long serialVersionUID = 7294957362769575271L; - - private final String message; - private final int status; - - // Make the response available for exception handling (includes body) - private final CloudifyResponse response; - - public CloudifyResponseException(String message, int status) { - this.message = message; - this.status = status; - this.response = null; - } - - // Include the response message itself. The body is a CloudifyError JSON structure. - public CloudifyResponseException(String message, int status, CloudifyResponse response) { - CloudifyError error = response.getErrorEntity(CloudifyError.class); - this.message = message + ": " + error.getErrorCode(); - this.status = status; - this.response = response; - } - - public String getMessage() { - return message; - } - - public int getStatus() { - return status; - } - - public CloudifyResponse getResponse() { - return response; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java deleted file mode 100644 index 095582fa51..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/Entity.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -public class Entity<T> { - - private T entity; - - private String contentType; - - public static <T> Entity<T> json(T entity) { - return new Entity<T>(entity, "application/json"); - } - - public static <T> Entity<T> stream(T entity) { - return new Entity<T>(entity, "application/octet-stream"); - } - - public Entity(T entity, String contentType) { - super(); - this.entity = entity; - this.contentType = contentType; - } - - /** - * @return the entity - */ - public T getEntity() { - return entity; - } - - /** - * @param entity the entity to set - */ - public void setEntity(T entity) { - this.entity = entity; - } - - /** - * @return the contentType - */ - public String getContentType() { - return contentType; - } - - /** - * @param contentType the contentType to set - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/HttpMethod.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/HttpMethod.java deleted file mode 100644 index 2c5097f1ad..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/HttpMethod.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -public enum HttpMethod { - HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java deleted file mode 100644 index 54519bac72..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.connector.http; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.UnknownHostException; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.HttpResponseException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.onap.so.cloudify.base.client.CloudifyClientConnector; -import org.onap.so.cloudify.base.client.CloudifyConnectException; -import org.onap.so.cloudify.base.client.CloudifyRequest; -import org.onap.so.cloudify.base.client.CloudifyResponse; -import org.onap.so.cloudify.base.client.CloudifyResponseException; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonRootName; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HttpClientConnector implements CloudifyClientConnector { - - private static ObjectMapper DEFAULT_MAPPER; - private static ObjectMapper WRAPPED_MAPPER; - - private static Logger logger = LoggerFactory.getLogger(HttpClientConnector.class); - - static { - DEFAULT_MAPPER = new ObjectMapper(); - - DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL); - DEFAULT_MAPPER.disable(SerializationFeature.INDENT_OUTPUT); - DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - - WRAPPED_MAPPER = new ObjectMapper(); - - WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL); - WRAPPED_MAPPER.disable(SerializationFeature.INDENT_OUTPUT); - WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - } - - protected static <T> ObjectMapper getObjectMapper(Class<T> type) { - return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER; - } - - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - - CloseableHttpClient httpClient = null; - - if (request.isBasicAuth()) { - // Use Basic Auth for this request. - CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - credentialsProvider.setCredentials(AuthScope.ANY, - new UsernamePasswordCredentials(request.getUser(), request.getPassword())); - - httpClient = HttpClients.custom().setRedirectStrategy(new HttpClientRedirectStrategy()) - .setDefaultCredentialsProvider(credentialsProvider).build(); - } else { - // Don't use basic authentication. The Client will attempt Token-based authentication - httpClient = HttpClients.custom().setRedirectStrategy(new HttpClientRedirectStrategy()).build(); - } - - URI uri = null; - - // Build the URI with query params - try { - URIBuilder uriBuilder = new URIBuilder(request.endpoint() + request.path()); - - for (Map.Entry<String, List<Object>> entry : request.queryParams().entrySet()) { - for (Object o : entry.getValue()) { - uriBuilder.setParameter(entry.getKey(), String.valueOf(o)); - } - } - - uri = uriBuilder.build(); - } catch (URISyntaxException e) { - throw new HttpClientException(e); - } - - HttpEntity entity = null; - if (request.entity() != null) { - // Special handling for streaming input - if (request.entity().getEntity() instanceof InputStream) { - // Entity is an InputStream - entity = new InputStreamEntity((InputStream) request.entity().getEntity()); - } else { - // Assume to be JSON. Flatten the entity to a Json string - try { - // Get appropriate mapper, based on existence of a root element in Entity class - ObjectMapper mapper = getObjectMapper(request.entity().getEntity().getClass()); - - String entityJson = mapper.writeValueAsString(request.entity().getEntity()); - entity = new StringEntity(entityJson, ContentType.create(request.entity().getContentType())); - - logger.debug("Request JSON Body: {}", - entityJson.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"***\"")); - - } catch (JsonProcessingException e) { - throw new HttpClientException("Json processing error on request entity", e); - } catch (IOException e) { - throw new HttpClientException("Json IO error on request entity", e); - } - } - } - - // Determine the HttpRequest class based on the method - HttpUriRequest httpRequest; - - switch (request.method()) { - case POST: - HttpPost post = new HttpPost(uri); - post.setEntity(entity); - httpRequest = post; - break; - - case GET: - httpRequest = new HttpGet(uri); - break; - - case PUT: - HttpPut put = new HttpPut(uri); - put.setEntity(entity); - httpRequest = put; - break; - - case DELETE: - httpRequest = new HttpDelete(uri); - break; - - default: - throw new HttpClientException("Unrecognized HTTP Method: " + request.method()); - } - - for (Entry<String, List<Object>> h : request.headers().entrySet()) { - StringBuilder sb = new StringBuilder(); - for (Object v : h.getValue()) { - sb.append(String.valueOf(v)); - } - httpRequest.addHeader(h.getKey(), sb.toString()); - } - - // Get the Response. But don't get the body entity yet, as this response - // will be wrapped in an HttpClientResponse. The HttpClientResponse - // buffers the body in constructor, so can close the response here. - HttpClientResponse httpClientResponse = null; - CloseableHttpResponse httpResponse = null; - - // Catch known HttpClient exceptions, and wrap them in OpenStack Client Exceptions - // so calling functions can distinguish. Only RuntimeExceptions are allowed. - try { - httpResponse = httpClient.execute(httpRequest); - - logger.debug("Response status: {}", httpResponse.getStatusLine().getStatusCode()); - - httpClientResponse = new HttpClientResponse(httpResponse); - - int status = httpResponse.getStatusLine().getStatusCode(); - if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT - || status == HttpStatus.SC_ACCEPTED) { - return httpClientResponse; - } - } catch (HttpResponseException e) { - // What exactly does this mean? It does not appear to get thrown for - // non-2XX responses as documented. - logger.error("Client HttpResponseException", e); - throw new CloudifyResponseException(e.getMessage(), e.getStatusCode()); - } catch (UnknownHostException e) { - logger.error("Client UnknownHostException", e); - throw new CloudifyConnectException("Unknown Host: " + e.getMessage()); - } catch (IOException e) { - // Catch all other IOExceptions and throw as OpenStackConnectException - logger.error("Client IOException", e); - throw new CloudifyConnectException(e.getMessage()); - } catch (Exception e) { - // Catchall for anything else, must throw as a RuntimeException - logger.error("Client exception", e); - throw new RuntimeException("Unexpected client exception", e); - } finally { - // Have the body. Close the stream - if (httpResponse != null) - try { - httpResponse.close(); - } catch (IOException e) { - logger.debug("Unable to close HTTP Response: ", e); - } - } - - // Get here on an error response (4XX-5XX) - if (httpResponse != null) { - throw new CloudifyResponseException(httpResponse.getStatusLine().getReasonPhrase(), - httpResponse.getStatusLine().getStatusCode(), httpClientResponse); - } else { - throw new CloudifyResponseException("Null httpResponse", 0, httpClientResponse); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java deleted file mode 100644 index b8b4a5b018..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategy.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.connector.http; - -import java.net.URI; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.methods.RequestBuilder; -import org.apache.http.impl.client.DefaultRedirectStrategy; -import org.apache.http.protocol.HttpContext; - -/** - * Custom {@link org.apache.http.client.RedirectStrategy} implementation that automatically redirects all HEAD, GET and - * DELETE requests. The {@link org.apache.http.client.DefaultRedirectStrategy} only redirects GET and HEAD - * automatically, per the HTTP specification (POST and PUT typically have bodies and thus cannot be redirected). - * - * A custom strategy is needed for the Openstack API, which can also send 302 on a DELETE (by name) request, expecting - * the client to follow the redirect to perform the actual deletion. - */ -@Immutable -public class HttpClientRedirectStrategy extends DefaultRedirectStrategy { - - /** - * Redirectable methods. - */ - private static final String[] REDIRECT_METHODS = - new String[] {HttpGet.METHOD_NAME, HttpDelete.METHOD_NAME, HttpHead.METHOD_NAME}; - - /** - * Determine if the request should be redirected. This may not actually be needed, since the REDIRECT_METHODS array - * has been updated with the DELETE. - */ - @Override - protected boolean isRedirectable(final String method) { - for (final String m : REDIRECT_METHODS) { - if (m.equalsIgnoreCase(method)) { - return true; - } - } - return false; - } - - /** - * Override the default redirect handling method. As implemented in HttpClient, it does not preserve the method on - * 301 or 302 responses, always redirecting to a GET. - */ - @Override - public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context) - throws ProtocolException { - - final URI uri = getLocationURI(request, response, context); - final String method = request.getRequestLine().getMethod(); - if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { - return new HttpHead(uri); - } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) { - return new HttpGet(uri); - } else { - - final int status = response.getStatusLine().getStatusCode(); - - HttpUriRequest newRequest = null; - if (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == HttpStatus.SC_MOVED_TEMPORARILY) { - newRequest = RequestBuilder.copy(request).setUri(uri).build(); - } else { - newRequest = new HttpGet(uri); - } - return newRequest; - } - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java deleted file mode 100644 index f1aa06cb39..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.connector.http; - -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.so.cloudify.base.client.CloudifyResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -public class HttpClientResponse implements CloudifyResponse { - - private static Logger logger = LoggerFactory.getLogger(HttpClientResponse.class); - - private transient HttpResponse response = null; - private String entityBody = null; - - public HttpClientResponse(HttpResponse response) { - this.response = response; - - // Read the body so InputStream can be closed - if (response.getEntity() == null) { - // No body - logger.debug("No Response Body"); - return; - } - - ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); - try { - response.getEntity().writeTo(responseBody); - } catch (IOException e) { - throw new HttpClientException("Error Reading Response Body", e); - } - entityBody = responseBody.toString(); - logger.debug(entityBody); - } - - - @Override - public <T> T getEntity(Class<T> returnType) { - // Get appropriate mapper, based on existence of a root element - ObjectMapper mapper = HttpClientConnector.getObjectMapper(returnType); - - T resp = null; - try { - resp = mapper.readValue(entityBody, returnType); - } catch (Exception e) { - throw new HttpClientException("Caught exception in getEntity", e); - } - return resp; - } - - @Override - public <T> T getErrorEntity(Class<T> returnType) { - return getEntity(returnType); - } - - @Override - public InputStream getInputStream() { - return new ByteArrayInputStream(entityBody.getBytes()); - } - - @Override - public String getHeader(String name) { - return response.getFirstHeader(name).getValue(); - } - - @Override - public Map<String, String> headers() { - Map<String, String> headers = new HashMap<>(); - - Header responseHeaders[] = response.getAllHeaders(); - for (Header h : responseHeaders) { - headers.put(h.getName(), h.getValue()); - } - - return headers; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java deleted file mode 100644 index 9877eb9f43..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/BlueprintsResource.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import java.io.InputStream; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.Blueprints; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class BlueprintsResource { - - private final CloudifyClient client; - private static final String BLUEPRINTS_PATH = "/api/v3/blueprints/"; - - public BlueprintsResource(CloudifyClient client) { - this.client = client; - } - - /* - * Upload a blueprint package directly. The blueprint must be a ZIP archive. However, this method will not validate - * this. - */ - public UploadBlueprint uploadFromStream(String blueprintId, String mainFileName, InputStream blueprint) { - return new UploadBlueprint(blueprintId, mainFileName, blueprint, null); - } - - public UploadBlueprint uploadFromUrl(String blueprintId, String mainFileName, String blueprintUrl) { - return new UploadBlueprint(blueprintId, mainFileName, null, blueprintUrl); - } - - public ListBlueprints list() { - return new ListBlueprints(); - } - - public GetBlueprint getById(String id) { - return new GetBlueprint(id, ""); - } - - // Return all of the metadata, but not the plan - public GetBlueprint getMetadataById(String id) { - return new GetBlueprint(id, "?_include=id,main_file_name,description,tenant_name,created_at,updated_at"); - } - - public DeleteBlueprint deleteById(String id) { - return new DeleteBlueprint(id); - } - - public class UploadBlueprint extends CloudifyRequest<Blueprint> { - public UploadBlueprint(String blueprintId, String mainFileName, InputStream blueprint, String blueprintUrl) { - // Initialize the request elements dynamically. - // Either a blueprint input stream or a URL will be provided. - // If a URL is provided, add it to the query string - // If a Stream is provided, set it as the Entity body - super(client, HttpMethod.PUT, - BLUEPRINTS_PATH + blueprintId + "?application_file_name=" + mainFileName - + ((blueprintUrl != null) ? "&blueprint_archive=" + blueprintUrl : ""), - ((blueprint != null) ? Entity.stream(blueprint) : null), Blueprint.class); - } - } - - public class DeleteBlueprint extends CloudifyRequest<Blueprint> { - public DeleteBlueprint(String blueprintId) { - super(client, HttpMethod.DELETE, BLUEPRINTS_PATH + blueprintId, null, Blueprint.class); - } - } - - public class GetBlueprint extends CloudifyRequest<Blueprint> { - public GetBlueprint(String id, String queryArgs) { - super(client, HttpMethod.GET, BLUEPRINTS_PATH + id + queryArgs, null, Blueprint.class); - } - } - - public class ListBlueprints extends CloudifyRequest<Blueprints> { - public ListBlueprints() { - super(client, HttpMethod.GET, "/api/v3/blueprints", null, Blueprints.class); - } - } - - // TODO: DownloadBlueprint is not supported, as it needs to return an input stream - // containing the full blueprint ZIP. - // For a full client library, this will require returning an open stream as the entity... -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java deleted file mode 100644 index 2fdd61ce48..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/Cloudify.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyClientConnector; - -/** - * Reference: http://docs.getcloudify.org/api/v3/ - */ -public class Cloudify extends CloudifyClient { - - private final DeploymentsResource deployments; - private final BlueprintsResource blueprints; - private final TokensResource tokens; - private final NodeInstancesResource nodeInstances; - private final ExecutionsResource executions; - - /* - * Not supporting dynamic connectors public Cloudify(String endpoint, CloudifyClientConnector connector) { - * super(endpoint, connector); deployments = new DeploymentsResource(this); blueprints = new - * BlueprintsResource(this); nodeInstances = new NodeInstancesResource(this); tokens = new TokensResource(this); } - */ - public Cloudify(String endpoint, String tenant) { - super(endpoint, tenant); - deployments = new DeploymentsResource(this); - blueprints = new BlueprintsResource(this); - nodeInstances = new NodeInstancesResource(this); - executions = new ExecutionsResource(this); - tokens = new TokensResource(this); - } - - public Cloudify(String endpoint) { - super(endpoint); - deployments = new DeploymentsResource(this); - blueprints = new BlueprintsResource(this); - nodeInstances = new NodeInstancesResource(this); - executions = new ExecutionsResource(this); - tokens = new TokensResource(this); - } - - public DeploymentsResource deployments() { - return this.deployments; - } - - public BlueprintsResource blueprints() { - return this.blueprints; - } - - public NodeInstancesResource nodeInstances() { - return this.nodeInstances; - } - - public ExecutionsResource executions() { - return this.executions; - } - - public TokensResource tokens() { - return this.tokens; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java deleted file mode 100644 index 335f6b1697..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/DeploymentsResource.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import org.onap.so.cloudify.v3.model.Deployments; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class DeploymentsResource { - - private final CloudifyClient client; - private static final String DEPLOYMENT_PATH = "/api/v3/deployments/"; - - public DeploymentsResource(CloudifyClient client) { - this.client = client; - } - - public CreateDeployment create(String deploymentId, CreateDeploymentParams body) { - return new CreateDeployment(deploymentId, body); - } - - public ListDeployments list() { - return new ListDeployments(); - } - - public GetDeployment byId(String id) { - return new GetDeployment(id); - } - - public GetDeploymentOutputs outputsById(String id) { - return new GetDeploymentOutputs(id); - } - - public DeleteDeployment deleteByName(String name) { - return new DeleteDeployment(name); - } - - public class CreateDeployment extends CloudifyRequest<Deployment> { - public CreateDeployment(String deploymentId, CreateDeploymentParams body) { - super(client, HttpMethod.PUT, DEPLOYMENT_PATH + deploymentId, Entity.json(body), Deployment.class); - } - } - - public class DeleteDeployment extends CloudifyRequest<Deployment> { - public DeleteDeployment(String deploymentId) { - super(client, HttpMethod.DELETE, DEPLOYMENT_PATH + deploymentId, null, Deployment.class); - } - } - - public class GetDeployment extends CloudifyRequest<Deployment> { - public GetDeployment(String id) { - super(client, HttpMethod.GET, DEPLOYMENT_PATH + id, null, Deployment.class); - } - } - - public class GetDeploymentOutputs extends CloudifyRequest<DeploymentOutputs> { - public GetDeploymentOutputs(String id) { - super(client, HttpMethod.GET, DEPLOYMENT_PATH + id + "/outputs", null, DeploymentOutputs.class); - } - } - - public class ListDeployments extends CloudifyRequest<Deployments> { - public ListDeployments() { - super(client, HttpMethod.GET, "/api/v3/deployments", null, Deployments.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java deleted file mode 100644 index 34251bfe52..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/ExecutionsResource.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.cloudify.v3.model.Executions; -import org.onap.so.cloudify.v3.model.StartExecutionParams; -import org.onap.so.cloudify.v3.model.UpdateExecutionParams; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class ExecutionsResource { - - private final CloudifyClient client; - private static final String EXECUTIONS_PATH = "/api/v3/executions/"; - - public ExecutionsResource(CloudifyClient client) { - this.client = client; - } - - public ListExecutions list() { - return new ListExecutions(null); - } - - public ListExecutions listSorted(String sortBy) { - return new ListExecutions("?_sort=" + sortBy); - } - - // Return a filtered list. - // The filter parameter should be a query string of filter criteria (without leading "?") - public ListExecutions listFiltered(String filter, String sortBy) { - String listParams = "?" + filter; - if (sortBy != null) - listParams += "&_sort=" + sortBy; - return new ListExecutions(listParams); - } - - public GetExecution byId(String id) { - return new GetExecution(id); - } - - public StartExecution start(StartExecutionParams params) { - return new StartExecution(params); - } - - public UpdateExecution updateStatus(String id, String status) { - UpdateExecutionParams params = new UpdateExecutionParams(); - params.setStatus(status); - return new UpdateExecution(id, params); - } - - public CancelExecution cancel(String executionId, CancelExecutionParams params) { - return new CancelExecution(executionId, params); - } - - - public class GetExecution extends CloudifyRequest<Execution> { - public GetExecution(String id) { - super(client, HttpMethod.GET, EXECUTIONS_PATH + id, null, Execution.class); - } - } - - public class ListExecutions extends CloudifyRequest<Executions> { - public ListExecutions(String listParams) { - super(client, HttpMethod.GET, "/api/v3/executions" + ((listParams != null) ? listParams : ""), null, - Executions.class); - } - } - - public class StartExecution extends CloudifyRequest<Execution> { - public StartExecution(StartExecutionParams body) { - super(client, HttpMethod.POST, "/api/v3/executions", Entity.json(body), Execution.class); - } - } - - public class UpdateExecution extends CloudifyRequest<Execution> { - public UpdateExecution(String executionId, UpdateExecutionParams body) { - super(client, HttpMethod.PATCH, EXECUTIONS_PATH + executionId, Entity.json(body), Execution.class); - } - } - - public class CancelExecution extends CloudifyRequest<Execution> { - public CancelExecution(String executionId, CancelExecutionParams body) { - super(client, HttpMethod.POST, EXECUTIONS_PATH + executionId, Entity.json(body), Execution.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java deleted file mode 100644 index bc82c77026..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/NodeInstancesResource.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.UpdateNodeInstanceParams; -import org.onap.so.cloudify.v3.model.NodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstances; -import org.onap.so.cloudify.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class NodeInstancesResource { - - private final CloudifyClient client; - - public NodeInstancesResource(CloudifyClient client) { - this.client = client; - } - - public ListNodeInstances list() { - return new ListNodeInstances(); - } - - public GetNodeInstance byId(String id) { - return new GetNodeInstance(id); - } - - public UpdateNodeInstance update(String id, UpdateNodeInstanceParams params) { - return new UpdateNodeInstance(id, params); - } - - - public class GetNodeInstance extends CloudifyRequest<NodeInstance> { - public GetNodeInstance(String id) { - super(client, HttpMethod.GET, "/api/v3/node-instances/" + id, null, NodeInstance.class); - } - } - - public class ListNodeInstances extends CloudifyRequest<NodeInstances> { - public ListNodeInstances() { - super(client, HttpMethod.GET, "/api/v3/node-instances", null, NodeInstances.class); - } - } - - public class UpdateNodeInstance extends CloudifyRequest<NodeInstance> { - public UpdateNodeInstance(String nodeInstanceId, UpdateNodeInstanceParams body) { - super(client, HttpMethod.PATCH, "/api/v3/node-instances/" + nodeInstanceId, Entity.json(body), - NodeInstance.class); - } - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java deleted file mode 100644 index 417d7c6eda..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/client/TokensResource.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -import org.onap.so.cloudify.v3.model.Token; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.base.client.CloudifyClient; -import org.onap.so.cloudify.base.client.CloudifyRequest; - -public class TokensResource { - - private final CloudifyClient client; - - public TokensResource(CloudifyClient client) { - this.client = client; - } - - /* - * Get a new token for a user TODO: User ID/Password logic need to be in the Client. Results of a token query should - * also be able to add to the Client - */ - public GetToken token() { - return new GetToken(); - } - - public class GetToken extends CloudifyRequest<Token> { - public GetToken() { - super(client, HttpMethod.GET, "/api/v3/tokens", null, Token.class); - } - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java deleted file mode 100644 index 8fd6b7c9c0..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/AzureConfig.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AzureConfig implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("subscription_id") - String subscriptionId; - - @JsonProperty("tenant_id") - String tenantId; - - @JsonProperty("client_id") - String clientId; - - @JsonProperty("client_secret") - String clientSecret; - - public String getSubscriptionId() { - return subscriptionId; - } - - public void setSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java deleted file mode 100644 index 873816d121..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprint.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Date; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("blueprint") -public class Blueprint implements Serializable { - - - /** - * - */ - private static final long serialVersionUID = 938604986548763151L; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("description") - private String description; - - @JsonProperty("id") - private String id; - - @JsonProperty("main_file_name") - private String mainFileName; - - @JsonProperty("plan") - private Map<String, Object> plan = null; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("updated_at") - private Date updatedAt; - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getMainFileName() { - return mainFileName; - } - - public void setMainFileName(String mainFileName) { - this.mainFileName = mainFileName; - } - - public Map<String, Object> getPlan() { - return this.plan; - } - - public void setPlan(Map<String, Object> plan) { - this.plan = plan; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + ", description='" + description + '\'' + ", createdAt=" + createdAt - + ", updatedAt=" + updatedAt + ", mainFileName='" + mainFileName + '\'' + ", tenantName='" + tenantName - + '\'' + '}'; - } - - /* - * Add a definition of the Cloudify "plan" attribute once we know what it is. - * - * @JsonIgnoreProperties(ignoreUnknown=true) public static final class Plan { } - * - */ - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprints.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprints.java deleted file mode 100644 index aebf1e5daa..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Blueprints.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Blueprints implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Blueprint> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Blueprint> getItems() { - return items; - } - - public void setItems(List<Blueprint> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java deleted file mode 100644 index 1638199ce9..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CloudifyError.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * This class represents a generic Cloudify error response body. These responses have a common format: { "message": - * "<error message>", "error_code": "<cloudify error id string>". "server_traceback": "<Python traceback>" } - * - * @author jc1348 - */ -public class CloudifyError implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("message") - private String message; - - @JsonProperty("error_code") - private String errorCode; - - @JsonProperty("server_traceback") - private String serverTraceback; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getServerTraceback() { - return serverTraceback; - } - - public void setServerTraceback(String serverTraceback) { - this.serverTraceback = serverTraceback; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java deleted file mode 100644 index 66e9b61d27..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/CreateDeploymentParams.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.Map; - -public class CreateDeploymentParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("inputs") - private Map<String, Object> inputs; - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Map<String, Object> getInputs() { - return inputs; - } - - public void setInputs(Map<String, Object> inputs) { - this.inputs = inputs; - } - - @Override - public String toString() { - return "CreateDeploymentBody{" + "blueprintId='" + blueprintId + '\'' + ", inputs=" + inputs + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java deleted file mode 100644 index 86a2b5f1bb..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployment.java +++ /dev/null @@ -1,358 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("deployment") -public class Deployment implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("description") - private String description; - - @JsonProperty("groups") - private Map<String, Group> groups = null; - - @JsonProperty("id") - private String id; - - @JsonProperty("inputs") - private Map<String, Object> inputs = null; - - // TODO: Expand the definition of a PolicyTrigger - @JsonProperty("policy_triggers") - private List<Object> policyTriggers; - - // TODO: Expand the definition of a PolicyType - @JsonProperty("policy_types") - private List<Object> policyTypes; - - @JsonProperty("scaling_groups") - private Map<String, ScalingGroup> scalingGroups = null; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("updated_at") - private Date updatedAt; - - @JsonProperty("workflows") - private List<Workflow> workflows; - - public List<Object> getPolicyTriggers() { - return policyTriggers; - } - - public void setPolicyTriggers(List<Object> policyTriggers) { - this.policyTriggers = policyTriggers; - } - - public List<Object> getPolicyTypes() { - return policyTypes; - } - - public void setPolicyTypes(List<Object> policyTypes) { - this.policyTypes = policyTypes; - } - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Group> getGroups() { - return this.groups; - } - - public void setGroups(Map<String, Group> groups) { - this.groups = groups; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Map<String, Object> getInputs() { - return this.inputs; - } - - public void setInputs(Map<String, Object> inputs) { - this.inputs = inputs; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public Map<String, ScalingGroup> getScalingGroups() { - return scalingGroups; - } - - public void setScalingGroups(Map<String, ScalingGroup> scalingGroups) { - this.scalingGroups = scalingGroups; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - public List<Workflow> getWorkflows() { - return workflows; - } - - public void setWorkflows(List<Workflow> workflows) { - this.workflows = workflows; - } - - /* - * Nested subclasses for Group definitions - */ - public static final class Group { - @JsonProperty("policies") - Object policies; - - @JsonProperty("members") - List<String> members; - - public Object getPolicies() { - return policies; - } - - public void setPolicies(Object policies) { - this.policies = policies; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } - } - - /* - * Nested subclasses for Scaling Group definitions - */ - public static final class ScalingGroup { - @JsonProperty("properties") - ScalingGroupProperties properties; - - @JsonProperty("members") - List<String> members; - - public ScalingGroupProperties getProperties() { - return properties; - } - - public void setProperties(ScalingGroupProperties properties) { - this.properties = properties; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } - } - - public static final class ScalingGroupProperties { - @JsonProperty("current_instances") - int currentInstances; - - @JsonProperty("default_instances") - int defaultInstances; - - @JsonProperty("max_instances") - int maxInstances; - - @JsonProperty("min_instances") - int minInstances; - - @JsonProperty("planned_instances") - int plannedInstances; - - public int getCurrentInstances() { - return currentInstances; - } - - public void setCurrentInstances(int currentInstances) { - this.currentInstances = currentInstances; - } - - public int getDefaultInstances() { - return defaultInstances; - } - - public void setDefaultInstances(int defaultInstances) { - this.defaultInstances = defaultInstances; - } - - public int getMaxInstances() { - return maxInstances; - } - - public void setMaxInstances(int maxInstances) { - this.maxInstances = maxInstances; - } - - public int getMinInstances() { - return minInstances; - } - - public void setMinInstances(int minInstances) { - this.minInstances = minInstances; - } - - public int getPlannedInstances() { - return plannedInstances; - } - - public void setPlannedInstances(int plannedInstances) { - this.plannedInstances = plannedInstances; - } - } - - /* - * Nested subclass for Deployment Workflow entities. Note that Blueprint class also contains a slightly different - * Workflow structure. - */ - public static final class Workflow { - @JsonProperty("name") - private String name; - @JsonProperty("created_at") - private Date createdAt; - @JsonProperty("parameters") - private Map<String, ParameterDefinition> parameters; - - public Workflow() {} - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public Map<String, ParameterDefinition> getParameters() { - return parameters; - } - - public void setParameters(Map<String, ParameterDefinition> parameters) { - this.parameters = parameters; - } - } - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + ", description='" + description + '\'' + ", blueprintId='" - + blueprintId + '\'' + ", createdBy='" + createdBy + '\'' + ", tenantName='" + tenantName + '\'' - + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + ", inputs='" + inputs + '\'' - + ", workflows=" + workflows + ", groups=" + groups + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java deleted file mode 100644 index 1f34534a15..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/DeploymentOutputs.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("outputs") -public class DeploymentOutputs implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("outputs") - private Map<String, Object> outputs = null; - - public Map<String, Object> getOutputs() { - return this.outputs; - } - - public void setOutputs(Map<String, Object> outputs) { - this.outputs = outputs; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - /* - * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs. - */ - public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) { - - ObjectMapper mapper = new ObjectMapper(); - - if (map.containsKey(key)) { - try { - String s = mapper.writeValueAsString(map.get(key)); - return (mapper.readValue(s, type)); - } catch (IOException e) { - return null; - } - } - return null; - } - - @Override - public String toString() { - return "DeploymentOutputs{" + "deploymentId='" + deploymentId + '\'' + ", outputs='" + outputs + '\'' + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java deleted file mode 100644 index b97164f528..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Deployments.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class Deployments implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Deployment> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Deployment> getItems() { - return items; - } - - public void setItems(List<Deployment> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java deleted file mode 100644 index 258d8e525a..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Execution.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("execution") -public class Execution implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("blueprint_id") - private String blueprintId; - - @JsonProperty("created_at") - private Date createdAt; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("error") - private String error; - - @JsonProperty("id") - private String id; - - @JsonProperty("is_system_workflow") - private boolean isSystemWorkflow; - - @JsonProperty("parameters") - private Map<String, Object> parameters; - - @JsonProperty("status") - private String status; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("workflow_id") - private String workflowId; - - public String getBlueprintId() { - return blueprintId; - } - - public void setBlueprintId(String blueprintId) { - this.blueprintId = blueprintId; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public boolean isSystemWorkflow() { - return isSystemWorkflow; - } - - public void setSystemWorkflow(boolean isSystemWorkflow) { - this.isSystemWorkflow = isSystemWorkflow; - } - - public Map<String, Object> getParameters() { - return parameters; - } - - public void setParameters(Map<String, Object> parameters) { - this.parameters = parameters; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getWorkflowId() { - return workflowId; - } - - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - @Override - public String toString() { - return "Execution{" + "id='" + id + '\'' + ", blueprintId='" + blueprintId + '\'' + ", createdBy='" + createdBy - + '\'' + ", createdAt=" + createdAt + ", deploymentId='" + deploymentId + '\'' + ", error=" + error - + ", isSystemWorkflow=" + isSystemWorkflow + ", status=" + status + ", tenantName='" + tenantName + '\'' - + ", parameters=" + parameters + '}'; - } - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java deleted file mode 100644 index e238bc7fee..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Executions.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class Executions implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<Execution> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<Execution> getItems() { - return items; - } - - public void setItems(List<Execution> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java deleted file mode 100644 index 269ed9db8a..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Metadata.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; - -/** - * This class represents a generic Cloudify response to a GET command. These responses have a common format: { "items": - * [ List of objects of the requested type ], "metadata": { } } - * - * @author jc1348 - * - */ -public class Metadata implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("pagination") - private Pagination pagination; - - - public Pagination getPagination() { - return pagination; - } - - public void setPagination(Pagination pagination) { - this.pagination = pagination; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java deleted file mode 100644 index 4d7f8fb749..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstance.java +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonRootName("node_instance") -public class NodeInstance implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("created_by") - private String createdBy; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("host_id") - private String hostId; - - @JsonProperty("id") - private String id; - - @JsonProperty("node_id") - private String nodeId; - - @JsonProperty("relationships") - private List<Object> relationships = null; - - @JsonProperty("runtime_properties") - private Map<String, Object> runtimeProperties = null; - - @JsonProperty("scaling_groups") - private List<ScalingGroupIdentifier> scalingGroups; - - @JsonProperty("state") - private String state; - - @JsonProperty("tenant_name") - private String tenantName; - - @JsonProperty("version") - private String version; - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getHostId() { - return hostId; - } - - public void setHostId(String hostId) { - this.hostId = hostId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public List<Object> getRelationships() { - return relationships; - } - - public void setRelationships(List<Object> relationships) { - this.relationships = relationships; - } - - public Map<String, Object> getRuntimeProperties() { - return runtimeProperties; - } - - public void setRuntimeProperties(Map<String, Object> runtimeProperties) { - this.runtimeProperties = runtimeProperties; - } - - public List<ScalingGroupIdentifier> getScalingGroups() { - return scalingGroups; - } - - public void setScalingGroups(List<ScalingGroupIdentifier> scalingGroups) { - this.scalingGroups = scalingGroups; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - /* - * Nested structure representing scaling groups in which this node is a member - */ - public static final class ScalingGroupIdentifier { - @JsonProperty("name") - private String name; - - @JsonProperty("id") - private String id; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String toString() { - return "Scaling Group{ name=" + name + ", id=" + id + "}"; - } - } - - @Override - public String toString() { - return "Deployment{" + "id='" + id + '\'' + "nodeId='" + nodeId + '\'' + ", createdBy='" + createdBy + '\'' - + ", tenantName='" + tenantName + '\'' + ", state=" + state + ", deploymentId=" + deploymentId - + ", hostId='" + hostId + '\'' + ", version='" + version + '\'' + ", relationships=" + relationships - + ", runtimeProperties=" + runtimeProperties + ", scalingGroups=" + scalingGroups + '}'; - } - - // TODO: Need an object structure for Relationships -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java deleted file mode 100644 index 8dd30d9696..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/NodeInstances.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; - -public class NodeInstances implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("items") - private List<NodeInstance> items; - - @JsonProperty("metadata") - private Metadata metadata; - - public List<NodeInstance> getItems() { - return items; - } - - public void setItems(List<NodeInstance> items) { - this.items = items; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java deleted file mode 100644 index 8914a83a55..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/OpenstackConfig.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class OpenstackConfig implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("username") - String username; - - @JsonProperty("password") - String password; - - @JsonProperty("tenant_name") - String tenantName; - - @JsonProperty("auth_url") - String authUrl; - - @JsonProperty("region") - String region; - - // NOTE: Not supporting "custom_configuration" - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getTenantName() { - return tenantName; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public String getAuthUrl() { - return authUrl; - } - - public void setAuthUrl(String authUrl) { - this.authUrl = authUrl; - } - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java deleted file mode 100644 index a292b13881..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Pagination.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Pagination { - @JsonProperty("total") - private int total; - @JsonProperty("offset") - private int offset; - @JsonProperty("size") - private int size; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getOffset() { - return offset; - } - - public void setOffset(int offset) { - this.offset = offset; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java deleted file mode 100644 index 1ff70b68d6..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/ParameterDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ParameterDefinition implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("type") - private String type; - @JsonProperty("description") - private String description; - @JsonProperty("default") - private Object defaultValue; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Object getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java deleted file mode 100644 index e12b7d094c..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/StartExecutionParams.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StartExecutionParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("workflow_id") - private String workflowId; - - @JsonProperty("deployment_id") - private String deploymentId; - - @JsonProperty("allow_custom_parameters") - private boolean allowCustomParameters; - - @JsonProperty("force") - private boolean force; - - @JsonProperty("parameters") - private Map<String, Object> parameters; - - public String getWorkflowId() { - return workflowId; - } - - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public boolean isAllowCustomParameters() { - return allowCustomParameters; - } - - public void setAllowCustomParameters(boolean allowCustomParameters) { - this.allowCustomParameters = allowCustomParameters; - } - - public boolean isForce() { - return force; - } - - public void setForce(boolean force) { - this.force = force; - } - - public Map<String, Object> getParameters() { - return parameters; - } - - public void setParameters(Map<String, Object> parameters) { - this.parameters = parameters; - } - - @Override - public String toString() { - return "UpdateExecutionParams{" + "workflowId='" + workflowId + '\'' + "deploymentId='" + deploymentId + '\'' - + "allowCustomParameters='" + allowCustomParameters + '\'' + "force='" + force + '\'' + "parameters='" - + parameters + '\'' + '}'; - } - -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java deleted file mode 100644 index c5809d4a32..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/Token.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -// @JsonRootName("token") -// The Token object is returned without a root element -public class Token implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("role") - private String role; - - @JsonProperty("value") - private String value; - - // Any expiration? Maybe something in the Headers? - - public String getRole() { - return role; - } - - public void setRole(String role) { - this.role = role; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - - @Override - public String toString() { - return "Token{" + "role='" + role + '\'' + ", value='" + value + '\'' + '}'; - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateNodeInstanceParams.java b/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateNodeInstanceParams.java deleted file mode 100644 index fabb70a49a..0000000000 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/v3/model/UpdateNodeInstanceParams.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.Map; - -public class UpdateNodeInstanceParams implements Serializable { - - private static final long serialVersionUID = 1L; - - @JsonProperty("state") - private String state; - - @JsonProperty("version") - private String version; - - @JsonProperty("runtime_properties") - private Map<String, Object> runtimeProperties; - - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Map<String, Object> getRuntimeProperties() { - return runtimeProperties; - } - - public void setRuntimeProperties(Map<String, Object> runtimeProperties) { - this.runtimeProperties = runtimeProperties; - } - - - @Override - public String toString() { - return "UpdateNodeInstanceParams{" + "state='" + state + '\'' + "version='" + version + '\'' - + ", runtimeProperties=" + runtimeProperties + '}'; - } - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java deleted file mode 100644 index 4028b71109..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify; - -import org.junit.Before; -import org.junit.Test; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class BeanMultiTest { - - Validator validator; - PojoClassFilter enumFilter; - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Before - public void setup() { - enumFilter = new FilterEnum(); - validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) - .with(new SetterTester(), new GetterTester()).build(); - } - - @Test - public void validateBeansMsoApihandlerBeans() { - - validator.validate("org.onap.so.cloudify.v3.model", enumFilter); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/src/test/java"); - } - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java deleted file mode 100644 index 88974acb11..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -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.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.model.Execution; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class CloudifyClientTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void clientCreate() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClient cc = new CloudifyClient("http://localhost:" + port); - cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void clientCreateWithBadConnector() { - thrown.expect(CloudifyResponseException.class); - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClientConnector ccc = new CloudifyClientConnector() { - @Override - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - throw new CloudifyResponseException("test case", 401); - } - }; - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc); - // cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - } - - @Test - public void clientCreateWithBadConnectorAndToken() { - thrown.expect(CloudifyResponseException.class); - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClientConnector ccc = new CloudifyClientConnector() { - @Override - public <T> CloudifyResponse request(CloudifyRequest<T> request) { - throw new CloudifyResponseException("test case", 401); - } - }; - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc); - cc.setToken("token"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - } - - @Test - public void clientCreateWithTenant() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - CloudifyClient cc = new CloudifyClient("http://localhost:" + port, "other_tenant"); - cc.setToken("token"); - cc.property("property", "value"); - CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class); - Execution x = crx.execute(); - assertEquals("123", x.getId()); - } - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java deleted file mode 100644 index 77152a2dd0..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.base.client; - -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.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class CloudifyClientTokenProviderTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void createTokenProvider() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl/api/v3/tokens")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"role\": \"user\", \"value\": \"tokenVal\"}").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - - CloudifyClientTokenProvider cctp = - new CloudifyClientTokenProvider("http://localhost:" + port + "/testUrl", "user", "pswd"); - String token = cctp.getToken(); - assertEquals("tokenVal", token); - token = cctp.getToken(); - assertEquals("tokenVal", token); - cctp.expireToken(); - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java deleted file mode 100644 index c85b88f7f3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.connector.http; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import com.github.tomakehurst.wiremock.http.Fault; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertEquals; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -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.base.client.Entity; -import org.onap.so.cloudify.base.client.HttpMethod; -import org.onap.so.cloudify.v3.model.Deployment; - -public class HttpClientConnectorTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void sunnyDay_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - Deployment deployment = new Deployment(); - deployment.setId("id"); - request.entity(deployment, "application/json"); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - request.method(HttpMethod.POST); - conector.request(request); - verify(postRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void sunnyDay_GET() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); - verify(getRequestedFor(urlEqualTo("/testUrl"))); - } - - @Test - public void sunnyDay_PUT() { - wireMockRule.stubFor(put(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.PUT); - conector.request(request); - verify(putRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void sunnyDay_DELETE() { - wireMockRule.stubFor(delete(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.DELETE); - conector.request(request); - verify(deleteRequestedFor(urlEqualTo("/testUrl"))); - } - - - @Test - public void rainyDay_PATCH() { - thrown.expect(HttpClientException.class); - thrown.expectMessage("Unrecognized HTTP Method: PATCH"); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:123123/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.PATCH); - conector.request(request); - - } - - @Test - public void rainyDayRunTimeException() { - wireMockRule.stubFor(post(urlEqualTo("/503")) - .willReturn(aResponse().withStatus(503).withHeader("Content-Type", "text/plain").withBody("failure"))); - thrown.expect(RuntimeException.class); - thrown.expectMessage("Unexpected client exception"); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:123123/503"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.POST); - conector.request(request); - - } - - @Test - public void rainyDayBadUri() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - thrown.expect(HttpClientException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - Deployment deployment = new Deployment(); - deployment.setId("id"); - request.entity(deployment, "application/json"); - request.endpoint("(@#$@(#*$&asfasdf"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - request.method(HttpMethod.POST); - conector.request(request); - } - - @Test - public void sunnyDayWithJsonEntity_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - - Deployment deployment = new Deployment(); - deployment.setId("id"); - - CloudifyRequest<Deployment> request = - new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/", Entity.json(deployment), null); - - request.endpoint("http://localhost:" + port); - request.path("testUrl"); - request.header("Content-Type", "application/json"); - request.header("Content-Type", null); - - request.returnType(Deployment.class); - assertEquals(Deployment.class, request.returnType()); - - Entity<Deployment> t = request.json(deployment); - assertEquals(t.getEntity().getId(), "id"); - - request.queryParam("test", "one").queryParam("test", "two"); - - conector.request(request); - - verify(postRequestedFor(urlEqualTo("/testUrl?test=two"))); - } - - @Test - public void sunnyDayWithStreamEntity_POST() { - wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK))); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - - InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)); - - CloudifyRequest<Deployment> request = - new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/testUrl", Entity.stream(is), null); - - request.endpoint("http://localhost:" + port); - request.setBasicAuthentication("USER", "PASSWORD"); - request.header("Content-Type", "application/json"); - - conector.request(request); - verify(postRequestedFor(urlEqualTo("/testUrl"))); - } - - @Test - public void rainyDayGarbageData() { - wireMockRule.stubFor( - get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE))); - thrown.expect(CloudifyConnectException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); - } - - @Test - public void rainyDayEmptyResponse() { - wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_NOT_FOUND))); - - thrown.expect(HttpClientException.class); - int port = wireMockRule.port(); - HttpClientConnector conector = new HttpClientConnector(); - CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>(); - request.endpoint("http://localhost:" + port + "/testUrl"); - request.setBasicAuthentication("USER", "PASSWORD"); - request.method(HttpMethod.GET); - conector.request(request); // gets down to "Get here on an error response (4XX-5XX)", then tries to throw a - // CloudifyResponseException, which calls getEntity, which tries to parse an HTML - // error page as a JSON, which causes the HttpClientException. - } - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java deleted file mode 100644 index 6010726669..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ============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.connector.http; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import java.net.URI; -import java.net.URISyntaxException; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolException; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpTrace; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.protocol.HttpContext; -import org.junit.Test; - -public class HttpClientRedirectStrategyTest { - - private HttpClientRedirectStrategy httpClientRedirectStrategy = new HttpClientRedirectStrategy(); - - @Test - public void isRedirectable_shouldReturnFalse_forNonRedirectableHttpMethods() { - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPost.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPatch.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpPut.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpOptions.METHOD_NAME)).isFalse(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpTrace.METHOD_NAME)).isFalse(); - } - - @Test - public void isRedirectable_shouldReturnTrue_forRedirectableHttpMethods() { - assertThat(httpClientRedirectStrategy.isRedirectable(HttpGet.METHOD_NAME)).isTrue(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpDelete.METHOD_NAME)).isTrue(); - assertThat(httpClientRedirectStrategy.isRedirectable(HttpHead.METHOD_NAME)).isTrue(); - } - - @Test - public void getRedirect_shouldReturnHttpHeadUriRequest() throws URISyntaxException, ProtocolException { - assertHttpUriRequestFor(HttpHead.METHOD_NAME, HttpHead.class); - } - - @Test - public void getRedirect_shouldReturnHttpGetUriRequest() throws URISyntaxException, ProtocolException { - assertHttpUriRequestFor(HttpGet.METHOD_NAME, HttpGet.class); - } - - private void assertHttpUriRequestFor(String methodName, Class<? extends HttpUriRequest> expectedHttpMethodClass) - throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(methodName); - HttpResponse response = null; - HttpContext context = null; - URI expectedUri = new URI("http://localhost/host"); - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(expectedHttpMethodClass); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - @Test - public void getRedirect_shouldReturnHttpGetUri_byDefault() throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(HttpPost.METHOD_NAME); - HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); - given(response.getStatusLine().getStatusCode()).willReturn(HttpStatus.SC_ACCEPTED); - URI expectedUri = new URI("http://localhost/host"); - HttpContext context = null; - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(HttpGet.class); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - @Test - public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forMovedTemporarilyStatus() - throws URISyntaxException, ProtocolException { - assertHttpRequestIsCopied(HttpStatus.SC_MOVED_TEMPORARILY); - } - - @Test - public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forTemporaryRedirectStatus() - throws URISyntaxException, ProtocolException { - assertHttpRequestIsCopied(HttpStatus.SC_TEMPORARY_REDIRECT); - } - - private void assertHttpRequestIsCopied(int expectedHttpStatus) throws URISyntaxException, ProtocolException { - // GIVEN - HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS); - given(request.getRequestLine().getMethod()).willReturn(HttpGet.METHOD_NAME); - given(request.getRequestLine().getUri()).willReturn("http://hostname"); - HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); - given(response.getStatusLine().getStatusCode()).willReturn(expectedHttpStatus); - URI expectedUri = new URI("http://localhost/host"); - HttpContext context = null; - // WHEN - HttpUriRequest httpUriRequest = - new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context); - // THEN - assertThat(httpUriRequest).isInstanceOf(HttpGet.class); - assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri); - } - - private static class TestableHttpClientRedirectStrategy extends HttpClientRedirectStrategy { - - private final URI expectedUri; - - public TestableHttpClientRedirectStrategy(URI expectedUri) { - this.expectedUri = expectedUri; - } - - @Override - public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) { - return expectedUri; - } - } -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java deleted file mode 100644 index cba3bf8fdc..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -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.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.client.BlueprintsResource.DeleteBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.GetBlueprint; -import org.onap.so.cloudify.v3.client.BlueprintsResource.ListBlueprints; -import org.onap.so.cloudify.v3.client.BlueprintsResource.UploadBlueprint; -import org.onap.so.cloudify.v3.model.Blueprint; -import org.onap.so.cloudify.v3.model.Blueprints; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class BlueprintsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyClientBlueprintFromStream() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)); - UploadBlueprint ub = br.uploadFromStream("123", "blueprint.json", is); - Blueprint b = ub.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintFromUrl() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - UploadBlueprint ub = br.uploadFromUrl("123", "blueprint.json", "http://localhost:" + port + "/blueprint"); - Blueprint b = ub.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintDelete() { - wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - DeleteBlueprint db = br.deleteById("123"); - Blueprint b = db.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{\"items\": [{\"id\": \"123\"}]}").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - ListBlueprints lb = br.list(); - Blueprints b = lb.execute(); - assertEquals("123", b.getItems().get(0).getId()); - } - - @Test - public void cloudifyClientBlueprintGetById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - GetBlueprint gb = br.getById("123"); - Blueprint b = gb.execute(); - assertEquals("123", b.getId()); - } - - @Test - public void cloudifyClientBlueprintGetMetadataById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - BlueprintsResource br = c.blueprints(); - GetBlueprint gb = br.getMetadataById("123"); - Blueprint b = gb.execute(); - assertEquals("123", b.getId()); - } - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java deleted file mode 100644 index 2acd4ba5a3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -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.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import java.util.HashMap; -import java.util.Map; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.v3.client.DeploymentsResource.CreateDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.DeleteDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeployment; -import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeploymentOutputs; -import org.onap.so.cloudify.v3.client.DeploymentsResource.ListDeployments; -import org.onap.so.cloudify.v3.model.CreateDeploymentParams; -import org.onap.so.cloudify.v3.model.Deployment; -import org.onap.so.cloudify.v3.model.Deployments; -import org.onap.so.cloudify.v3.model.DeploymentOutputs; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class DeploymentsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyDeploymentsCreate() { - wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/deployments/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - - CreateDeploymentParams cdp = new CreateDeploymentParams(); - cdp.setBlueprintId("123"); - Map<String, Object> inputs = new HashMap<String, Object>(); - cdp.setInputs(inputs); - CreateDeployment cd = br.create("123", cdp); - Deployment d = cd.execute(); - assertEquals("123", d.getId()); - } - - @Test - public void cloudifyDeploymentsList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"items\": {\"id\": \"123\" } } ").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - ListDeployments ld = br.list(); - Deployments d = ld.execute(); - assertEquals("123", d.getItems().get(0).getId()); - } - - @Test - public void cloudifyDeploymentsGet() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - GetDeployment gd = br.byId("123"); - Deployment d = gd.execute(); - assertEquals("123", d.getId()); - } - - @Test - public void cloudifyDeploymentsGetOutputs() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123/outputs")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"deployment_id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - GetDeploymentOutputs gdo = br.outputsById("123"); - DeploymentOutputs d = gdo.execute(); - assertEquals("123", d.getDeploymentId()); - - Map<String, Object> map = new HashMap<String, Object>(); - map.put("test", "answer"); - assertEquals("answer", d.getMapValue(map, "test", String.class)); - - Integer i = d.getMapValue(map, "nil", Integer.class); - assertNull(i); - - i = d.getMapValue(map, "test", Integer.class); - assertNull(i); - } - - @Test - public void cloudifyDeploymentsDelete() { - wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/deployments/name")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - DeploymentsResource br = c.deployments(); - DeleteDeployment cd = br.deleteByName("name"); - Deployment d = cd.execute(); - assertEquals("123", d.getId()); - } - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java deleted file mode 100644 index 7b63c6eecb..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -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.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.connector.http.HttpClientException; -import org.onap.so.cloudify.v3.client.ExecutionsResource.CancelExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.GetExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.ListExecutions; -import org.onap.so.cloudify.v3.client.ExecutionsResource.StartExecution; -import org.onap.so.cloudify.v3.client.ExecutionsResource.UpdateExecution; -import org.onap.so.cloudify.v3.model.CancelExecutionParams; -import org.onap.so.cloudify.v3.model.Execution; -import org.onap.so.cloudify.v3.model.Executions; -import org.onap.so.cloudify.v3.model.StartExecutionParams; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class ExecutionsResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void cloudifyClientExecutions() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"345\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.list(); - Executions x = lx.execute(); - assertEquals("123", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionsSorted() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"123\" }, { \"id\": \"345\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.listSorted("id"); - Executions x = lx.execute(); - assertEquals("345", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionsFilter() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - "{\"items\": [{ \"id\": \"121\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - ListExecutions lx = xr.listFiltered("a=b", "id"); - Executions x = lx.execute(); - assertEquals("123", x.getItems().get(1).getId()); - } - - @Test - public void cloudifyClientExecutionById() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - GetExecution gx = xr.byId("123"); - Execution x = gx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientStartExecution() { - wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - StartExecutionParams params = new StartExecutionParams(); - StartExecution sx = xr.start(params); - Execution x = sx.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientUpdateExecution() { - thrown.expect(HttpClientException.class); - thrown.expectMessage("Unrecognized HTTP Method: PATCH"); - - wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/executions")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - UpdateExecution ux = xr.updateStatus("123", "good"); - Execution x = ux.execute(); - assertEquals("123", x.getId()); - } - - @Test - public void cloudifyClientCancelExecution() { - wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }") - .withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - ExecutionsResource xr = c.executions(); - - CancelExecutionParams params = new CancelExecutionParams(); - CancelExecution cx = xr.cancel("123", params); - Execution x = cx.execute(); - assertEquals("123", x.getId()); - } - - - -} diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java deleted file mode 100644 index d38d0401c3..0000000000 --- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloudify.v3.client; - -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.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.cloudify.connector.http.HttpClientException; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.GetNodeInstance; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.ListNodeInstances; -import org.onap.so.cloudify.v3.client.NodeInstancesResource.UpdateNodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstance; -import org.onap.so.cloudify.v3.model.NodeInstances; -import org.onap.so.cloudify.v3.model.UpdateNodeInstanceParams; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class NodeInstancesResourceTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void nodeInstanceGet() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances/123")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - GetNodeInstance gni = nir.byId("123"); - NodeInstance ni = gni.execute(); - assertEquals("123", ni.getId()); - } - - @Test - public void nodeInstanceList() { - wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - // .withBody(" { \"items\": [ { \"node_instance\": { \"id\": \"123\" } } ] } ") - .withBody(" { \"items\": [ { \"id\": \"123\" } ] } ").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - ListNodeInstances lni = nir.list(); - NodeInstances ni = lni.execute(); - assertEquals("123", ni.getItems().get(0).getId()); - } - - @Test - public void nodeInstanceUpdate() { - wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/node-instances/")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK))); - - int port = wireMockRule.port(); - - Cloudify c = new Cloudify("http://localhost:" + port, "tenant"); - NodeInstancesResource nir = c.nodeInstances(); - UpdateNodeInstanceParams params = new UpdateNodeInstanceParams(); - - UpdateNodeInstance uni = nir.update("123", params); - thrown.expect(HttpClientException.class); /// ??????? - NodeInstance ni = uni.execute(); - } -} diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientException.java b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java index 6f170baef5..418f8a5065 100644 --- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientException.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,25 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.cloudify.connector.http; +package org.onap.so.beans.nsmf; -/* - * Declare a RuntimeException since the Interface does not declare any throwables. Any caught exception will be wrapped - * in HttpClientException - */ -public class HttpClientException extends RuntimeException { +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AnPerfReq { + + private PerfReqEmbb perfReqEmbb; - private static final long serialVersionUID = 1L; + private PerfReqUrllc perfReqUrllc; + + public PerfReqEmbb getPerfReqEmbb() { + return perfReqEmbb; + } - public HttpClientException(String s) { - super(s); + public void setPerfReqEmbb(PerfReqEmbb perfReqEmbb) { + this.perfReqEmbb = perfReqEmbb; } - public HttpClientException(Exception e) { - super("Caught nested exception in HttpClient", e); + public PerfReqUrllc getPerfReqUrllc() { + return perfReqUrllc; } - public HttpClientException(String s, Exception e) { - super(s, e); + public void setPerfReqUrllc(PerfReqUrllc perfReqUrllc) { + this.perfReqUrllc = perfReqUrllc; } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index 653f9ac495..26c3c0012a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -21,7 +21,6 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import java.util.List; @@ -33,17 +32,17 @@ public class AnSliceProfile { private String sliceProfileId; - private List<String> coverageAreaTAList; + private List<Integer> coverageAreaTAList; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int latency; private List<String> pLMNIdList; - private PerfReq perfReq; + private AnPerfReq perfReq; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int maxNumberofUEs; + private long maxNumberofUEs; private UeMobilityLevel uEMobilityLevel; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java index 7061ec2ff3..a44dbd636f 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java @@ -24,15 +24,14 @@ import lombok.Data; import java.io.Serializable; +@JsonInclude(JsonInclude.Include.NON_NULL) @Data public class NssmfAdapterNBIRequest implements Serializable { private static final long serialVersionUID = -454145891489457960L; - @JsonInclude(JsonInclude.Include.NON_NULL) private EsrInfo esrInfo; - @JsonInclude(JsonInclude.Include.NON_NULL) private ServiceInfo serviceInfo; private AllocateCnNssi allocateCnNssi; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java index 4aabc3f26f..c67f193a02 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java @@ -26,23 +26,23 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) public class PerfReq { - private List<PerfReqEmbbList> perfReqEmbbList; + private List<PerfReqEmbb> perfReqEmbbList; - private List<PerfReqUrllcList> perfReqUrllcList; + private List<PerfReqUrllc> perfReqUrllcList; - public List<PerfReqEmbbList> getPerfReqEmbbList() { + public List<PerfReqEmbb> getPerfReqEmbbList() { return perfReqEmbbList; } - public void setPerfReqEmbbList(List<PerfReqEmbbList> perfReqEmbbList) { + public void setPerfReqEmbbList(List<PerfReqEmbb> perfReqEmbbList) { this.perfReqEmbbList = perfReqEmbbList; } - public List<PerfReqUrllcList> getPerfReqUrllcList() { + public List<PerfReqUrllc> getPerfReqUrllcList() { return perfReqUrllcList; } - public void setPerfReqUrllcList(List<PerfReqUrllcList> perfReqUrllcList) { + public void setPerfReqUrllcList(List<PerfReqUrllc> perfReqUrllcList) { this.perfReqUrllcList = perfReqUrllcList; } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java index 9e9fcaa19e..bce0d56f9a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java @@ -23,7 +23,7 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqEmbbList { +public class PerfReqEmbb { @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int expDataRateDL; @@ -38,6 +38,9 @@ public class PerfReqEmbbList { private int areaTrafficCapUL; @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int overallUserDensity; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int activityFactor; public int getExpDataRateDL() { @@ -72,6 +75,14 @@ public class PerfReqEmbbList { this.areaTrafficCapUL = areaTrafficCapUL; } + public int getOverallUserDensity() { + return overallUserDensity; + } + + public void setOverallUserDensity(int overallUserDensity) { + this.overallUserDensity = overallUserDensity; + } + public int getActivityFactor() { return activityFactor; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java index 00f0a917aa..0b05d39bab 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java @@ -23,7 +23,7 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) -public class PerfReqUrllcList { +public class PerfReqUrllc { @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int e2eLatency; diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index fff82ea5bc..33958a7850 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -1,8 +1,10 @@ package org.onap.so.utils; import java.security.GeneralSecurityException; +import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; import org.camunda.bpm.client.ExternalTaskClient; import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; @@ -75,7 +77,20 @@ public class ExternalTaskServiceUtils { @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { - getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start); + try { + logger.debug("Executing scheduled task to check and restart external task clients"); // TODO remove + // eventually + List<ExternalTaskClient> inactiveClients = + getClients().stream().filter(client -> !client.isActive()).collect(Collectors.toList()); + + inactiveClients.forEach(c -> { + logger.debug("External Task Client found to be inactive. Restarting Client."); + c.start(); + }); + } catch (Exception e) { + logger.error("Exception occured in checkAllClientsActive", e); + } + } protected Set<ExternalTaskClient> getClients() { diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java index 5b68d0c69a..78f8350eff 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java @@ -74,6 +74,8 @@ public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlur new AAIObjectPlurals(AAIObjectType.INSTANCE_GROUP, AAINamespaceConstants.NETWORK, "/instance-groups"); public static final AAIObjectPlurals PNF = new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs"); + public static final AAIObjectPlurals PROJECT = + new AAIObjectPlurals(AAIObjectType.PROJECT, AAINamespaceConstants.BUSINESS, "/projects"); private final String uriTemplate; private final String partialUri; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 665fa547cc..c7692cb2cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -396,7 +396,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -408,7 +409,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -484,7 +485,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -496,7 +498,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -715,7 +717,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON); + "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -727,7 +730,7 @@ public class E2EServiceInstances { MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -948,7 +951,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 4ac8b73698..bf76cd3174 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -451,7 +451,7 @@ public class MsoRequest { } public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action, - String requestScope, String requestJSON) { + String requestScope, String requestJSON, String serviceInstanceId) { try { InfraActiveRequests request = new InfraActiveRequests(requestId); Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); @@ -463,6 +463,9 @@ public class MsoRequest { request.setRequestAction(action.toString()); request.setRequestScope(requestScope); request.setRequestBody(requestJSON); + if (serviceInstanceId != null) { + request.setServiceInstanceId(serviceInstanceId); + } Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index a68309f199..87e5a2f23e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { String requestScope = requestScopeFromUri(requestUri); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - requestScope, requestJSON); + requestScope, requestJSON, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 418ba05abf..107aa57974 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -823,9 +823,16 @@ public class ServiceInstances extends AbstractRestHandler { sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); action = handleReplaceInstance(action, sir); - requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + try { + requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); + } catch (ApiException e) { + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, + requestJSON, sir.getServiceInstanceId()); + throw e; + } + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); if (sir.getRequestDetails().getRequestParameters() != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index 7711608288..1f944da7ba 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -335,7 +335,6 @@ public class OrchestrationRequestsTest extends BaseTest { Map<String, List<String>> orchestrationMap = new HashMap<>(); orchestrationMap.put("modelType", values); - List<GetOrchestrationResponse> testResponses = new ArrayList<>(); List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); HttpHeaders headers = new HttpHeaders(); @@ -427,7 +426,6 @@ public class OrchestrationRequestsTest extends BaseTest { public void testUnlockOrchestrationRequest_Valid_Status() throws JsonParseException, JsonMappingException, IOException, ValidationException { setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING"); - ObjectMapper mapper = new ObjectMapper(); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); HttpHeaders headers = new HttpHeaders(); @@ -481,7 +479,6 @@ public class OrchestrationRequestsTest extends BaseTest { assertThat(actualProcessingData, sameBeanAs(expectedDataList)); } - public void setupTestGetOrchestrationRequest() throws Exception { // For testGetOrchestrationRequest wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018")) diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index a4a1e378d5..20b61e638a 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -271,6 +271,30 @@ </build> </image> <image> + <name>${docker.image.prefix}/so-oof-adapter</name> + <build> + <cleanup>try</cleanup> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:mso-oof-adapter</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> + <image> <name>${docker.image.prefix}/so-appc-orchestrator</name> <build> <cleanup>try</cleanup> @@ -469,7 +493,7 @@ <goal>push</goal> </goals> <configuration> - <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator,${docker.image.prefix}/mso-nssmf-adapter,${docker.image.prefix}/mso-cnf-adapter,${docker.image.prefix}/so-etsi-nfvo-ns-lcm</image> + <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator,${docker.image.prefix}/mso-nssmf-adapter,${docker.image.prefix}/so-oof-adapter,${docker.image.prefix}/mso-cnf-adapter,${docker.image.prefix}/so-etsi-nfvo-ns-lcm</image> </configuration> </execution> </executions> @@ -529,6 +553,11 @@ </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-oof-adapter</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> <artifactId>so-appc-orchestrator</artifactId> <version>${project.version}</version> </dependency> @@ -32,7 +32,6 @@ <module>so-optimization-clients</module> <module>so-sdn-clients</module> <module>bpmn</module> - <module>cloudify-client</module> <module>cxf-logging</module> <module>so-monitoring</module> <module>so-simulator</module> diff --git a/releases/1.7.1.cnf.yaml b/releases/1.7.1.cnf.yaml new file mode 100644 index 0000000000..b986786e5d --- /dev/null +++ b/releases/1.7.1.cnf.yaml @@ -0,0 +1,9 @@ +--- +distribution_type: 'container' +container_release_tag: '1.7.1' +project: 'so' +log_dir: 'so-maven-docker-stage-master/437/' +ref: '96f7bcf737cc10a3258b5c8cf11b5cc5fd1ee65c' +containers: + - name: 'so/mso-cnf-adapter' + version: '1.7.1-20200827T0421'
\ No newline at end of file diff --git a/so-monitoring/so-monitoring-service/pom.xml b/so-monitoring/so-monitoring-service/pom.xml index 6671ac56d4..4a0f6cbe1d 100644 --- a/so-monitoring/so-monitoring-service/pom.xml +++ b/so-monitoring/so-monitoring-service/pom.xml @@ -104,6 +104,24 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> </build> </project> diff --git a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml index dbccb76979..ef0b6aa786 100644 --- a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml +++ b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml @@ -1,8 +1,12 @@ server: + ssl: + keyStore: classpath:org.onap.so.p12 + keyStorePassword: 6IxlmmPs:HqNhzVP#VFuSs,% + trustStore: classpath:org.onap.so.trust.jks + trustStorePassword: 72z0TFN&xfSR;;&NrIP^QB,^ port: 9091 tomcat: max-threads: 50 -ssl-enable: false camunda: rest: api: @@ -19,3 +23,9 @@ mso: spring: main: allow-bean-definition-overriding: true + security: + usercredentials: + - + username: gui + password: '$2a$10$ndkDhATUid4a3g0JJVRv2esX4rtB.vzCn7iBhKyR1qZ/wDdvNzjTS' + role: GUI-Client diff --git a/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 Binary files differnew file mode 100644 index 0000000000..8fa921a884 --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.p12 diff --git a/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..39c310e27e --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/resources/org.onap.so.trust.jks diff --git a/so-monitoring/so-monitoring-ui/pom.xml b/so-monitoring/so-monitoring-ui/pom.xml index 71480416d3..574d78287a 100644 --- a/so-monitoring/so-monitoring-ui/pom.xml +++ b/so-monitoring/so-monitoring-ui/pom.xml @@ -49,7 +49,7 @@ </goals> <phase>generate-resources</phase> <configuration> - <nodeVersion>v10.15.3</nodeVersion> + <nodeVersion>v10.19.0</nodeVersion> <yarnVersion>v1.7.0</yarnVersion> </configuration> </execution> diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json b/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json index b58ee265d0..45feb6007c 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/angular.json @@ -55,7 +55,9 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "ONAP-SO-Monitor:build" + "browserTarget": "ONAP-SO-Monitor:build", + "sslKey": "src/app/ssl/localhost.key", + "sslCert": "src/app/ssl/localhost.crt" }, "configurations": { "production": { diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/package.json b/so-monitoring/so-monitoring-ui/src/main/frontend/package.json index c793264e99..fcbeabed69 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/package.json +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "ng serve --ssl", "build": "ng build", "test": "ng test", "lint": "ng lint", diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt new file mode 100644 index 0000000000..7995c0e2c3 --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIUPVNQnCGr+uu048oN/oILqbk+DKwwDQYJKoZIhvcNAQEL +BQAwgZ8xCzAJBgNVBAYTAkdCMQ8wDQYDVQQIDAZMb25kb24xDzANBgNVBAcMBkxv +bmRvbjEYMBYGA1UECgwPTXkgT3JnYW5pc2F0aW9uMR8wHQYDVQQLDBZNeSBPcmdh +bmlzYXRpb25hbCBVbml0MR8wHQYJKoZIhvcNAQkBFhBlbWFpbEBkb21haW4uY29t +MRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjAwODA3MTIyMjM2WhcNMzAwNTA3MTIy +MjM2WjCBnzELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwG +TG9uZG9uMRgwFgYDVQQKDA9NeSBPcmdhbmlzYXRpb24xHzAdBgNVBAsMFk15IE9y +Z2FuaXNhdGlvbmFsIFVuaXQxHzAdBgkqhkiG9w0BCQEWEGVtYWlsQGRvbWFpbi5j +b20xEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKCtMRhrl1o1obijVfREsIatq/fEiFETCtSx3mJVKjZjYNHFn2/OjvXo +ncABnhKiFND8XiLYEgzDw9rtX3l2RVe9gQm2zNUvKPcmO+D4Dsn6QJu8HS7uDU8m +gaXRiEUHsjD+jvEF/sUKjD565XRGd9qCyDpdtjra2W7CGZdzTrdepMRJhxMmA0fB +t3JsV/52WMCqU6drSxT8hH7PvXh4nwr9DQ2fvUZarRptiW2Dg9zSqO+6M3XWCvUI +jdm4Q0jxXY2jCLsh1oTo3dIYdHedB4LORXAPIRsLdJ1/ofl9NdyL20kG4ONIdJXv +5mTuPGBATGOWEJvD8TTxrZtEMx9GNTsCAwEAAaMYMBYwFAYDVR0RBA0wC4IJbG9j +YWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQAIDUoitU/11f9ApfPXwtuDaPeX20sc +gSfq/MLQ9LttSi/SpAjebSlp12JNkZvxuV+2cPmc92NWv8WXqfyP+0BDhlGTm1qp +Hc/wRB9ASG/7Z1imAh+zpNXFe0fV0HpUqJx33ywiXLoMTTaSvwPSF4VEki8g9h2R +8zVXjsaE0ybi4eUIKG+ZJ2EBaVgLMEm+osVMnkTEWIeR3XN66Ko2SegvOrAjfOyz +CIqkDvPhowYkKVV4LSsFIgz+YKOVMxaEcHbrxciYKymmWQ/9I/ek8TUs8C4z6cKs +n+9nvYisfFpZ6tpMU+cgYkGezOCV5+nAri+SHoAfAOMXVPLACT39sOF9 +-----END CERTIFICATE----- diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key new file mode 100644 index 0000000000..85e6b7e09d --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/ssl/localhost.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgrTEYa5daNaG4 +o1X0RLCGrav3xIhREwrUsd5iVSo2Y2DRxZ9vzo716J3AAZ4SohTQ/F4i2BIMw8Pa +7V95dkVXvYEJtszVLyj3Jjvg+A7J+kCbvB0u7g1PJoGl0YhFB7Iw/o7xBf7FCow+ +euV0Rnfagsg6XbY62tluwhmXc063XqTESYcTJgNHwbdybFf+dljAqlOna0sU/IR+ +z714eJ8K/Q0Nn71GWq0abYltg4Pc0qjvujN11gr1CI3ZuENI8V2Nowi7IdaE6N3S +GHR3nQeCzkVwDyEbC3Sdf6H5fTXci9tJBuDjSHSV7+Zk7jxgQExjlhCbw/E08a2b +RDMfRjU7AgMBAAECggEAByszAY/rVM8HxCEleJyH87pT7d4K5vMejJbTATgjhgGx +FCrpDif9IOOcBjEMSHCK1TgtSwiw5XjmiCIHHHg2Z8/ArhpF0U0lWsGN8l+e6UwN +DeW6t5lPZrSlHCzZE5tgS+dPoVlPIKNz1mXNTv7F4i3rmQ8NTlrtUI/AbI1seanh +Ofb2yhHkkiHYIUridCDTuhk9hMmypHB9THA7SFRB7C9/zO8T95I2D1QQ5ZO5xKGg +rDAMacSeQMnuKNcyuF4RYoh0T4PmM1NFGH1F1+QKTAt5CU0rkZtMHZ9YuYPYCC1S +f1YrPQSJ5mFstaF9kWDp1rnR2J8Od/KU5ZSOgmvMoQKBgQDUithsDxnGEOQCKXfX +e6/kgaL7mB5Q/Pgeyiy5lyBjTLZcbFeaDzkRBR3zL5v8xbNZ4IsJqkaxJavrIwr4 +R2+WvuznEaeLhFds0ze57kDyV/uunsQwBSJSXYohCRiq1gc7nqpamSSpFFI9Ls81 +JmXSPdyosRWESjCTCrQffZFKhQKBgQDBh4VZ9lSAGfASKjkqGLncAEHcnCbavQoy +2DlHEhA+gZDvR2CSsunIxlQerZC78KcTA+oex54Ovi+NG8Rx6qyyywxiGjm0e1yG +B2z060CTO9PlMhs81kXJkUDxR4tHyMNtLaFKICJ9J6wZXBnYZcMU+Do7OhlRVoaL +qrNwhonsvwKBgCCTq3pckim+mwQN0RWRGrOefxmrBjKJo4osmNBVbpxpvKXL4V12 +qduG+kE08ea7crL67LStiapLSN+AfoTxhhQH7Y25MgH7Zd8DPM5dy0yZ2bS5Fv75 +Onp/ZdWMbGB6757eweOjB3B28ef4zb+qw/6GhtTAV7jwGiPfhx4wg911AoGBAIAP +1H82UK4/+6uZgyBHIl3hUbPRJKjkJOaGTEiqPFOQWz7rJY2NlMQF8U4nnjmvQm+D +zJ23i/DHiyG9+R1EpCjf0f7sybiTVSNfsIrVTXLgSRRGNt3oEGAUnTvMEu9ae284 +nZ02bHwTD3/sgTHADPpIVAgzJuO69Odg+sKAVK5zAoGAVn6bUm+QVuELmn8CNT+y +XsSks5gu0MDwuSbUwjuNjSGMEab2lwyIgY8CduopyJWLPgkVtALiuXxp6OzPNCE4 +pC/5HNaqawCQ7Kgbk6MjRwY551HQRgMG7wf9iFBP8sfdWG30vYFmiYWN4oUEDi5j +ytwU+extcKSRxj/O1op3KDI= +-----END PRIVATE KEY----- diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts index f0c63fe582..bf2f31d5c9 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts @@ -24,5 +24,5 @@ SPDX-License-Identifier: Apache-2.0 export const environment = { production: false, - soMonitoringBackendURL: 'http://so-monitoring:30224/so/monitoring/' + soMonitoringBackendURL: 'https://so-monitoring:30224/so/monitoring/' }; diff --git a/version.properties b/version.properties index 4bdcfa1b54..f56901fc20 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=7 -patch=1 +patch=2 base_version=${major}.${minor}.${patch} |