diff options
Diffstat (limited to 'adapters/mso-vnf-adapter')
7 files changed, 618 insertions, 31 deletions
diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index 9116e57a11..9a290f4f00 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -2,11 +2,11 @@ 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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version> + <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter</artifactId>
<packaging>war</packaging>
<name>mso-vnf-adapter</name>
@@ -56,7 +56,7 @@ </executions>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
@@ -107,17 +107,17 @@ </build>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter-async-client</artifactId>
<version>${project.version}</version>
</dependency>
@@ -140,7 +140,7 @@ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
@@ -157,7 +157,7 @@ <scope>test</scope>
</dependency>
<!-- <dependency> -->
- <!-- <groupId>org.openecomp.so</groupId> -->
+ <!-- <groupId>org.onap.so</groupId> -->
<!-- <artifactId>mso-catalog-db</artifactId> -->
<!-- <version>${project.version}</version> -->
<!-- </dependency> -->
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 7fe09be2b6..95e62a0e2d 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -465,7 +465,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private boolean callHeatbridge(String heatStackId) { String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge"; String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; - long waitTimeMs = 10000l; + long waitTimeMs = 10000L; try { String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; String[] envp = null; @@ -508,7 +508,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("Exception :",e); outputString = "Unable to call toString() on the value for " + str; } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); + sb.append("\t\nitem ").append(i++).append(": '").append(str).append("'='").append(outputString) + .append("'"); } } LOGGER.debug(sb.toString()); @@ -524,7 +525,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sb.append("\tEMPTY"); } else { for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + sb.append("\titem ").append(i++).append(": ").append(str).append("=").append(inputs.get(str)); } } LOGGER.debug(sb.toString()); @@ -1170,7 +1171,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // Check that required parameters have been supplied - String missingParams = null; + StringBuilder missingParams = null; List <String> paramList = new ArrayList <> (); // New for 1510 - consult the PARAM_ALIAS field to see if we've been @@ -1224,7 +1225,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { int cntr = 0; try { for (HeatTemplateParam htp : heatTemplate.getParameters()) { - sb.append("param[" + cntr++ + "]=" + htp.getParamName()); + sb.append("param[").append(cntr++).append("]=").append(htp.getParamName()); parameterNames.add(htp.getParamName()); if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { aliasToParam.put(htp.getParamAlias(), htp.getParamName()); @@ -1264,9 +1265,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); if (missingParams == null) { - missingParams = parm.getParamName (); + missingParams = new StringBuilder(parm.getParamName()); } else { - missingParams += "," + parm.getParamName (); + missingParams.append("," + parm.getParamName()); } } } @@ -1276,7 +1277,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (checkRequiredParameters) { // Problem - missing one or more required parameters String error = "Create VFModule: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { @@ -1443,16 +1444,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { StringBuilder sbInit = new StringBuilder(); sbInit.append("updateVfModule: \n"); - sbInit.append("cloudSiteId=" + cloudSiteId + "\n"); - sbInit.append("tenantId=" + tenantId + "\n"); - sbInit.append("vnfType=" + vnfType + "\n"); - sbInit.append("vnfVersion=" + vnfVersion + "\n"); - sbInit.append("vnfName=" + vnfName + "\n"); - sbInit.append("requestType=" + requestType + "\n"); - sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n"); - sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); - sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); - sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); + sbInit.append("cloudSiteId=").append(cloudSiteId).append("\n"); + sbInit.append("tenantId=").append(tenantId).append("\n"); + sbInit.append("vnfType=").append(vnfType).append("\n"); + sbInit.append("vnfVersion=").append(vnfVersion).append("\n"); + sbInit.append("vnfName=").append(vnfName).append("\n"); + sbInit.append("requestType=").append(requestType).append("\n"); + sbInit.append("volumeGroupHeatStackId=").append(volumeGroupHeatStackId).append("\n"); + sbInit.append("baseVfHeatStackId=").append(baseVfHeatStackId).append("\n"); + sbInit.append("vfModuleStackId=").append(vfModuleStackId).append("\n"); + sbInit.append("modelCustomizationUuid=").append(modelCustomizationUuid).append("\n"); LOGGER.debug(sbInit.toString()); String mcu = modelCustomizationUuid; @@ -1871,7 +1872,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // Check that required parameters have been supplied - String missingParams = null; + StringBuilder missingParams = null; List <String> paramList = new ArrayList <> (); // New for 1510 - consult the PARAM_ALIAS field to see if we've been @@ -2009,9 +2010,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { else { LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); if (missingParams == null) { - missingParams = parm.getParamName (); + missingParams = new StringBuilder(parm.getParamName()); } else { - missingParams += "," + parm.getParamName (); + missingParams.append("," + parm.getParamName()); } } } @@ -2021,7 +2022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Problem - missing one or more required parameters if (checkRequiredParameters) { String error = "Update VNF: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java new file mode 100755 index 0000000000..6e06eed702 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.vdu.utils; + +import java.util.Map; + +/* + * This Java bean class describes the template model of a VDU as distributed + * by SDC to SO. It is composed of one or more templates, one of which must be + * the main template, + * + * The structure of this class corresponds to the format in which the templates + * and associated artifacts are represented in the SO Catalog. + * + * The map keys will be the "path" that is used to reference these artifacts within + * the other templates. This may be relevant to how different VDU plugins package + * the files for delivery to the sub-orchestrator. + * + * In the future, it is possible that pre-packaged blueprints (e.g. complete TOSCA CSARs) + * could be stored in the catalog (and added to this structure). + * + * This bean is passed as an input to instantiateVdu and updateVdu. + */ + +public class VduBlueprint { + String vduModelId; + String mainTemplateName; + Map<String,byte[]> templateFiles; + Map<String,byte[]> attachedFiles; + + public String getVduModelId() { + return vduModelId; + } + + public void setVduModelId(String vduModelId) { + this.vduModelId = vduModelId; + } + + public String getMainTemplateName() { + return mainTemplateName; + } + + public void setMainTemplateName(String mainTemplateName) { + this.mainTemplateName = mainTemplateName; + } + + public Map<String, byte[]> getTemplateFiles() { + return templateFiles; + } + + public void setTemplateFiles(Map<String, byte[]> templateFiles) { + this.templateFiles = templateFiles; + } + + public Map<String, byte[]> getAttachedFiles() { + return attachedFiles; + } + + public void setAttachedFiles(Map<String, byte[]> attachedFiles) { + this.attachedFiles = attachedFiles; + } + + @Override + public String toString() { + return "VduInfo {" + + "id='" + vduModelId + '\'' + + "mainTemplateName='" + mainTemplateName + '\'' + + '}'; + } + +} + diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java new file mode 100755 index 0000000000..53300c9453 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.vdu.utils; + +import java.util.Map; +import java.util.HashMap; + +/* + * This Java bean class relays VDU status information in a cloud-agnostic format. + * + * This bean is returned by all implementors of the MsoVduUtils interface operations + * (instantiate, query, delete). + */ + +public class VduInfo { + // Set defaults for everything + private String vduInstanceId = ""; + private String vduInstanceName = ""; + private VduStatus status = VduStatus.NOTFOUND; + private Map<String,Object> outputs = new HashMap<String,Object>(); + private Map<String,Object> inputs = new HashMap<String,Object>(); + private String lastAction; + private String actionStatus; + private String errorMessage; + + public VduInfo () { + } + + // Add more constructors as appropriate + // + + public VduInfo (String id, Map<String,Object> outputs) { + this.vduInstanceId = id; + if (outputs != null) this.outputs = outputs; + } + + public VduInfo (String id) { + this.vduInstanceId = id; + } + + public VduInfo (String id, VduStatus status) { + this.vduInstanceId = id; + this.status = status; + } + + public String getVnfInstanceId() { + return vduInstanceId; + } + + public void setVnfInstanceId (String id) { + this.vduInstanceId = id; + } + + public String getVnfInstanceName() { + return vduInstanceName; + } + + public void setVnfInstanceName (String name) { + this.vduInstanceName = name; + } + + public VduStatus getStatus() { + return status; + } + + public void setStatus (VduStatus status) { + this.status = status; + } + + public Map<String,Object> getOutputs () { + return outputs; + } + + public void setOutputs (Map<String,Object> outputs) { + this.outputs = outputs; + } + + public Map<String,Object> getInputs () { + return inputs; + } + + public void setInputs (Map<String,Object> inputs) { + this.inputs = inputs; + } + + public String getLastAction() { + return lastAction; + } + + public String getActionStatus() { + return actionStatus; + } + + public String getErrorMessage() { + return errorMessage; + } + + @Override + public String toString() { + return "VduInfo {" + + "id='" + vduInstanceId + '\'' + + "name='" + vduInstanceName + '\'' + + ", inputs='" + inputs + '\'' + + ", outputs='" + outputs + '\'' + + ", lastAction='" + lastAction + '\'' + + ", status='" + status + '\'' + + ", errorMessage='" + errorMessage + '\'' + + '}'; + } + +} + diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java new file mode 100755 index 0000000000..3452a10db9 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java @@ -0,0 +1,248 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.vdu.utils; + +/** + * This interface defines a common API for template-based cloud deployments. + * The methods here should be adaptable for Openstack (Heat), Cloudify (TOSCA), + * Aria (TOSCA), Multi-VIM (TBD), and others (e.g. Azure Resource Manager). + * + * The deployed instances are referred to here as Virtual Deployment Units (VDUs). + * The package of templates that define a give VDU is referred to as its blueprint. + * + * Template-based orchestrators all follow a similar template/blueprint model. + * - One main template that is the top level definition + * - Optional nested templates referenced/included by the main template + * - Optional files attached to the template package, typically containing + * configuration files, install scripts, orchestration scripts, etc. + * + * The main template also defines the required inputs for creating a new instance, + * and output values exposed by successfully deployed instances. Inputs and outputs + * may include simple or complex (JSON) data types. + * + * Each implementation of this interface is expected to understand the MSO CloudConfig + * to obtain the credentials for its sub-orchestrator and the targeted cloud. + * The sub-orchestrator may have different credentials from the cloud (e.g. an Aria + * instance in front of an Openstack cloud) or they may be the same (e.g. Heat) + */ +import java.util.Map; + +import org.openecomp.mso.openstack.exceptions.MsoException; + +public interface VduPlugin { + + /** + * The instantiateVdu interface deploys a new VDU instance from a blueprint package. + * The templates and files in the blueprint may be pre-installed where supported + * (e.g. in Cloudify or Aria), or may be passed in directly (e.g. for Heat). These + * files are expressed as byte arrays, though only text files are expected from ASDC. + * + * For some VIMs, this may be a single command (e.g. Heat -> create stack) or may + * require a series of API calls (e.g. Cloudify -> upload blueprint, create deployment, + * execute install workflow). These details are hidden within the implementation. + * The instantiation should be fully completed before returning. On failures, this + * method is expected to back out the attempt, leaving the cloud in its previous state. + * + * It is expected that parameters have been validated and contain at minimum the + * required parameters for the given template with no extra parameters. + * + * The VDU name supplied by the caller will be globally unique, and identify the artifact + * in A&AI. Inventory is managed by the higher levels invoking this function. + * + * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry. + * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by + * cloud provider, but every cloud supports some sort of tenant partitioning. + * @param vduInstanceName A unique name for the VDU instance to create + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects. + * @param environmentFile A file containing default parameter name/value pairs. This is + * primarily for Heat, though ASDC may create a similar file for other orchestrators. + * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled + * @param suppressBackout Flag to preserve the deployment on install Failure. Should normally + * be False except in troubleshooting/debug cases + * + * @return A VduInfo object + * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo instantiateVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceName, + VduBlueprint vduBlueprint, + Map <String, ? extends Object> inputs, + String environmentFile, + int timeoutMinutes, + boolean suppressBackout) + throws MsoException; + + + /** + * Query a deployed VDU instance. This call will return a VduInfo object, or null + * if the deployment does not exist. + * + * Some VIM orchestrators identify deployment instances by string UUIDs, and others + * by integers. In the latter case, the ID will be passed in as a numeric string. + * + * The returned VduInfo object contains the input and output parameter maps, + * as well as other properties of the deployment (name, status, last action, etc.). + * + * @param cloudSiteId The target cloud to query for the VDU. + * @param tenantId The cloud tenant in which to query + * @param vduInstanceId The ID of the deployment to query + * + * @return A VduInfo object + * @throws MsoException Thrown if the VIM/sub-orchestrator API calls fail. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo queryVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId) + throws MsoException; + + + /** + * Delete a VDU instance by ID. If the VIM sub-orchestrator supports pre-installation + * of blueprints, the blueprint itself may remain installed. This is recommended, since + * other VDU instances may be using it. + * + * Some VIM orchestrators identify deployment instances by string UUIDs, and others + * by integers. In the latter case, the ID will be passed in as a numeric string. + * + * For some VIMs, deletion may be a single command (e.g. Heat -> delete stack) or a + * series of API calls (e.g. Cloudify -> execute uninstall workflow, delete deployment). + * These details are hidden within the implementation. The deletion should be fully + * completed before returning. + * + * The successful return is a VduInfo object which contains the state of the object just prior + * to deletion, with a status of DELETED. If the deployment was not found, the VduInfo object + * should be empty (with a status of NOTFOUND). There is no rollback from a successful deletion. + * + * A deletion failure will result in an undefined deployment state - the components may + * or may not have been all or partially uninstalled, so the resulting deployment must + * be considered invalid. + * + * @param cloudSiteId The target cloud from which to delete the VDU. + * @param tenantId The cloud tenant in which to delete the VDU. + * @param vduInstanceId The unique id of the deployment to delete. + * @param timeoutMinutes Timeout after which the delete action will be cancelled + * @param deleteBlueprint Flag to also delete the blueprint + * + * @return A VduInfo object, representing the state of the instance just prior to deletion. + * + * @throws MsoException Thrown if the API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo deleteVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId, + int timeoutMinutes, + boolean keepBlueprintLoaded) + throws MsoException; + + + /** + * The updateVdu interface attempts to update a VDU in-place, using either new inputs or + * a new model definition (i.e. updated templates/blueprints). This depends on the + * capabilities of the targeted sub-orchestrator, as not all implementations are expected + * to support this ability. It is primary included initially only for Heat. + * + * It is expected that parameters have been validated and contain at minimum the required + * parameters for the given template with no extra parameters. The VDU instance name cannot + * be updated. + * + * The update should be fully completed before returning. The successful return is a + * VduInfo object containing the updated VDU state. + * + * An update failure will result in an undefined deployment state - the components may + * or may not have been all or partially modified, deleted, recreated, etc. So the resulting + * VDU must be considered invalid. + * + * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry. + * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by + * cloud provider, but every cloud supports some sort of tenant partitioning. + * @param vduInstanceId The unique ID for the VDU instance to update. + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects. + * @param environmentFile A file containing default parameter name/value pairs. This is + * primarily for Heat, though ASDC may create a similar file for other orchestrators. + * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled + * + * @return A VduInfo object + * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs. + * Various subclasses of MsoException may be thrown. + */ + public VduInfo updateVdu ( + String cloudSiteId, + String tenantId, + String vduInstanceId, + VduBlueprint vduBlueprint, + Map <String, ? extends Object> inputs, + String environmentFile, + int timeoutMinutes) + throws MsoException; + + + /** + * Check if a blueprint package has been installed in the sub-orchestrator and available + * for use at a targeted cloud site. If the specific sub-orchestrator does not support + * pre-installation, then those implementations should always return False. + * + * @param cloudSiteId The cloud site where the blueprint is needed + * @param vduModelId Unique ID of the VDU model to query + * + * @throws MsoException Thrown if the API call fails. + */ + public boolean isBlueprintLoaded (String cloudSiteId, String vduModelId) + throws MsoException; + + + /** + * Install a blueprint package to the target sub-orchestrator for a cloud site. + * The blueprints 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. + * + * @param cloudSiteId The cloud site where the blueprint is needed + * @param vduBlueprint Object containing the collection of templates and files that comprise + * the blueprint for this VDU. + * @param failIfExists Flag to return an error if blueprint already exists + * + * @throws MsoException Thrown if the API call fails. + */ + public void uploadBlueprint (String cloudSiteId, + VduBlueprint vduBlueprint, + boolean failIfExists) + throws MsoException; + + /** + * Indicator that this VIM sub-orchestrator implementation supports independent upload + * of blueprint packages. Each implementation should return a constant value. + * + * @returns True if the sub-orchestrator supports blueprint pre-installation (upload). + */ + public boolean blueprintUploadSupported (); + +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java new file mode 100755 index 0000000000..0f4611a2de --- /dev/null +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.vdu.utils; + + +/* + * Enum status values to capture the state of a generic (cloud-agnostic) VDU. + */ +public enum VduStatus { + NOTFOUND, + INSTANTIATING, + INSTANTIATED, + DELETING, + DELETED, // Note - only returned in success response to deleteVdu call. + UPDATING, + FAILED, + UNKNOWN +} + diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java new file mode 100644 index 0000000000..21a71ccf61 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java @@ -0,0 +1,81 @@ +/*- + * ============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.openecomp.mso.vdu.utils; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.vdu.utils.VduBlueprint; + +import org.junit.Assert; + +public class VduBlueprintTest { + + private VduBlueprint vduBlueprint; + + private Map<String, byte[]> templateFiles; + private Map<String, byte[]> attachedFiles; + + @Before + public void setUp() { + vduBlueprint = new VduBlueprint(); + } + + @Test + public void testGetVduModelId() { + vduBlueprint.setVduModelId("vduModelId"); + Assert.assertNotNull(vduBlueprint.getVduModelId()); + Assert.assertEquals(vduBlueprint.getVduModelId(), "vduModelId"); + } + + @Test + public void testGetMainTemplateName() { + vduBlueprint.setMainTemplateName("MainTemplateName"); + Assert.assertNotNull(vduBlueprint.getMainTemplateName()); + Assert.assertEquals(vduBlueprint.getMainTemplateName(), "MainTemplateName"); + } + + @Test + public void testGetTemplateFiles() { + byte[] templateFileData = "some template file data".getBytes(); + templateFiles = new HashMap<String, byte[]>(); + templateFiles.put("templateKey1", templateFileData); + vduBlueprint.setTemplateFiles(templateFiles); + Assert.assertNotNull(vduBlueprint.getTemplateFiles()); + Assert.assertTrue(vduBlueprint.getTemplateFiles().containsKey("templateKey1")); + Assert.assertTrue(vduBlueprint.getTemplateFiles().containsValue(templateFileData)); + } + + @Test + public void testGetAttachedFiles() { + byte[] attachedFileData = "some file data".getBytes(); + attachedFiles = new HashMap<String, byte[]>(); + attachedFiles.put("attachedKey1", attachedFileData); + vduBlueprint.setAttachedFiles(attachedFiles); + Assert.assertNotNull(vduBlueprint.getAttachedFiles()); + Assert.assertTrue(vduBlueprint.getAttachedFiles().containsKey("attachedKey1")); + Assert.assertTrue(vduBlueprint.getAttachedFiles().containsValue(attachedFileData)); + } +} |