summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java38
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java6
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java13
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java18
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java6
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java37
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json5
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java18
-rw-r--r--asdc-controller/pom.xml529
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java1066
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java50
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java152
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java41
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java43
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java3
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java337
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java4314
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java442
-rw-r--r--asdc-controller/src/test/resources/ASDC/.gitignore2
-rw-r--r--asdc-controller/src/test/resources/application-test.yaml4
-rw-r--r--asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csarbin0 -> 35636 bytes
-rw-r--r--asdc-controller/src/test/resources/download/service-Testservice140-csar.csarbin0 -> 35457 bytes
-rw-r--r--asdc-controller/src/test/resources/schema.sql55
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy17
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy274
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy11
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy163
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy7
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java36
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn116
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy19
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy23
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy9
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java130
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java60
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java338
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java97
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json6
-rw-r--r--common/pom.xml4
-rw-r--r--common/src/main/java/org/onap/so/client/RestTemplateConfig.java2
-rw-r--r--common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java10
-rw-r--r--common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java2
-rw-r--r--common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java8
-rw-r--r--common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java2
-rw-r--r--common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java206
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java567
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java712
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java86
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java226
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java86
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java167
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java107
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java66
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java67
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java181
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java331
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java201
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java82
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java40
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json116
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java4
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java3
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java15
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java4
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java3
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql2
-rw-r--r--packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image2
132 files changed, 7887 insertions, 4409 deletions
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
index 2e12869c95..3b945ae484 100644
--- 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
@@ -44,7 +44,9 @@ public final class DeploymentInfoBuilder {
}
public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) {
- this.deploymentOutputs = deploymentOutputs;
+ if (deploymentOutputs != null) {
+ this.deploymentOutputs = deploymentOutputs;
+ }
return this;
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index 50bcb8e54a..6b16194471 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
@@ -104,7 +104,6 @@ import org.springframework.stereotype.Component;
@Component
public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
- private static final String CLOUDIFY_ERROR = "CloudifyError";
private static final String CLOUDIFY = "Cloudify";
private static final String CREATE_DEPLOYMENT = "CreateDeployment";
private static final String DELETE_DEPLOYMENT = "DeleteDeployment";
@@ -258,11 +257,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
if (installWorkflow.getStatus().equals(TERMINATED)) {
// Success!
// Create and return a DeploymentInfo structure. Include the Runtime outputs
- DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(installWorkflow)
.build();
}
@@ -352,16 +350,21 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
* Get the runtime Outputs of a deployment.
* Return the Map of tag/value outputs.
*/
- private DeploymentOutputs getDeploymentOutputs (Cloudify cloudify, String deploymentId)
+ private Optional<Map<String, Object>> getDeploymentOutputs (Cloudify cloudify, String deploymentId)
throws MsoException
{
// Build and send the Cloudify request
- DeploymentOutputs deploymentOutputs = null;
+ 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
@@ -372,7 +375,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
catch (CloudifyResponseException re) {
if (re.getStatus () == 404) {
// No Outputs
- return null;
+ return Optional.empty();
}
throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re);
}
@@ -380,8 +383,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Catch-all
throw new MsoAdapterException (e.getMessage(), e);
}
-
- return deploymentOutputs;
}
/*
@@ -545,7 +546,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
}
catch (Exception e) {
// Catch-all. Log the message and throw the original exception
- logger.debug("Cancel workflow {} failed for deployment : {} {}", workflowId, deploymentId, e);
+ logger.debug("Cancel workflow {} failed for deployment {} :", workflowId, deploymentId, e);
MsoCloudifyException exception = new MsoCloudifyException (-1, "", "", savedException);
exception.setPendingWorkflow(true);
throw exception;
@@ -579,16 +580,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Build and send the Cloudify request
Deployment deployment = new Deployment();
- DeploymentOutputs outputs = null;
try {
GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId);
logger.debug(queryDeployment.toString());
-
-// deployment = queryDeployment.execute();
deployment = executeAndRecordCloudifyRequest(queryDeployment);
- outputs = getDeploymentOutputs (cloudify, deploymentId);
-
// Next look for the latest execution
ListExecutions listExecutions = cloudify.executions().listFiltered ("deployment_id=" + deploymentId, "-created_at");
Executions executions = listExecutions.execute();
@@ -604,7 +600,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(executions.getItems().get(0))
.build();
}
@@ -623,7 +619,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.build();
} else {
// Deployment not found. Default status of a DeploymentInfo object is NOTFOUND
@@ -670,12 +666,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
logger.debug ("Ready to Uninstall/Delete Deployment ({})", deploymentId);
// Query first to save the trouble if deployment not found
- Deployment deployment = null;
- try {
+ try {
GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId);
logger.debug(queryDeploymentRequest.toString());
- deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest);
+ // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest);
}
catch (CloudifyResponseException e) {
// Since this came on the 'Create Deployment' command, nothing was changed
@@ -707,7 +702,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
/*
* Query the outputs before deleting so they can be returned as well
*/
- DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
+ //DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
/*
* Next execute the "uninstall" workflow.
@@ -745,6 +740,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// 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());
@@ -781,7 +777,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(uninstallWorkflow)
.build();
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index e8ef86a3b4..054234015f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -1295,7 +1295,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
Set<HeatTemplateParam> paramSet = template.getParameters();
logger.debug("paramSet has {} entries", paramSet.size());
} catch (Exception e) {
- logger.debug("Exception occurred in convertInputMap:" + e.getMessage(), e);
+ logger.debug("Exception occurred in convertInputMap {} :", e.getMessage(), e);
}
for (HeatTemplateParam htp : template.getParameters()) {
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
index 8f172b79ca..ce13d98dd1 100644
--- 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
@@ -149,6 +149,12 @@ public class DeploymentInfoBuilderTest {
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) {
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index d28784bb93..ea8cb5d616 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -23,13 +23,9 @@ package org.onap.so.db.catalog.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
import java.util.List;
import java.util.UUID;
-
-import javax.ws.rs.core.UriBuilder;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -54,20 +50,15 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
import org.onap.so.db.catalog.beans.VnfRecipe;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.security.core.parameters.P;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@@ -201,7 +192,6 @@ public class CatalogDbClientTest {
Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
-
}
@Test
@@ -659,7 +649,6 @@ public class CatalogDbClientTest {
pnfResource.getModelInvariantUUID());
assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
-
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
index 949027f7c1..b99e34eb9d 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
@@ -221,7 +221,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
} catch (Exception e) {
// might be ok - both are just blank
- logger.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e);
+ logger.debug("ERROR trying to parse the volumeGroupHeatStackId {}", volumeGroupHeatStackId,e);
}
this.createVfModule(cloudSiteId,
cloudOwner,
@@ -520,7 +520,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
}
- private void heatbridge(StackInfo heatStack, String cloudSiteId, String tenantId, String genericVnfName,
+ private void heatbridge(StackInfo heatStack, String cloudOwner, String cloudSiteId, String tenantId, String genericVnfName,
String vfModuleId) {
try {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(
@@ -528,7 +528,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
String heatStackId = heatStack.getCanonicalName().split("/")[1];
- String cloudOwner = "CloudOwner";//cloud owner needs to come from bpmn-adapter
List<String> oobMgtNetNames = new ArrayList<>();
HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
@@ -586,9 +585,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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.getMessage(),jpe);
+ logger.debug("Error converting json to string: {}", jpe.getMessage(),jpe);
} catch (Exception e) {
- logger.debug("Error converting json to string " + e.getMessage(),e);
+ logger.debug("Error converting json to string: {}", e.getMessage(),e);
}
return "[Error converting json to string]";
}
@@ -1345,7 +1344,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
logger.debug ("VF Module {} successfully created", vfModuleName);
//call heatbridge
- heatbridge(heatStack, cloudSiteId, tenantId, genericVnfName, vfModuleId);
+ heatbridge(heatStack, cloudOwner, cloudSiteId, tenantId, genericVnfName, vfModuleId);
return;
} catch (Exception e) {
logger.debug("unhandled exception in create VF",e);
@@ -1904,14 +1903,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
jsonNode = JSON_MAPPER.readTree(jsonString);
} catch (JsonParseException jpe) {
//TODO - what to do here?
- //for now - send the error to debug, but just leave it as a String
- String errorMessage = jpe.getMessage();
- logger.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
+ //for now - send the error to debug
+ logger.debug("Json Error Converting {} - {}", parm.getParamName(), jpe.getMessage(), jpe);
hasJson = false;
jsonNode = null;
} catch (Exception e) {
// or here?
- logger.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
+ logger.debug("Json Error Converting {} {}", parm.getParamName(), e.getMessage(), e);
hasJson = false;
jsonNode = null;
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index 2b49290727..62c373bea8 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -415,21 +415,21 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String str = "" + stackOutputs.get(key);
stringOutputs.put(key, str);
} catch (Exception e) {
- logger.debug("Unable to add " + key + " to outputs", e);
+ logger.debug("Unable to add {} to outputs", key, e);
}
} else if (stackOutputs.get(key) instanceof JsonNode) {
try {
String str = this.convertNode((JsonNode) stackOutputs.get(key));
stringOutputs.put(key, str);
} catch (Exception e) {
- logger.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e);
+ logger.debug("Unable to add {} to outputs - exception converting JsonNode", key, e);
}
} else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
try {
String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
stringOutputs.put(key, str);
} catch (Exception e) {
- logger.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e);
+ logger.debug("Unable to add {} to outputs - exception converting LinkedHashMap", key, e);
}
} else {
try {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
index 3910d9ec44..4e2d5e5da2 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
@@ -51,9 +51,10 @@ import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
-import org.onap.so.adapters.nwrest.NetworkTechnology;
import org.onap.so.adapters.nwrest.QueryNetworkError;
import org.onap.so.adapters.nwrest.QueryNetworkResponse;
+import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
+import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.adapters.vnf.BaseRestTestUtils;
@@ -193,6 +194,40 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
}
@Test
+ public void testRollbackNetwork() throws IOException {
+
+ RollbackNetworkRequest request = new RollbackNetworkRequest();
+
+ MsoRequest msoReq = new MsoRequest();
+
+ msoReq.setRequestId(MSO_REQUEST_ID);
+ msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
+
+ mockOpenStackResponseAccess(wireMockPort);
+
+ mockOpenStackPublicUrlStackByID_200(wireMockPort);
+
+ mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockPort);
+
+ mockOpenStackDeletePublicUrlStackByNameAndID_204();
+
+ headers.add("Accept", MediaType.APPLICATION_JSON);
+
+ HttpEntity<RollbackNetworkRequest> entity = new HttpEntity<>(request, headers);
+
+ ResponseEntity<RollbackNetworkResponse> response = restTemplate
+ .exchange(createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b/rollback"),
+ HttpMethod.DELETE, entity, RollbackNetworkResponse.class);
+
+ RollbackNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper()
+ .readValue(new File("src/test/resources/__files/RollbackNetworkResponse.json"), RollbackNetworkResponse.class);
+
+ assertThat(response.getBody(), sameBeanAs(expectedResponse));
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ }
+
+ @Test
public void testQueryNetwork_Exception() throws IOException{
MsoRequest msoReq = new MsoRequest();
msoReq.setRequestId(MSO_REQUEST_ID);
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json
new file mode 100644
index 0000000000..d319fedecd
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json
@@ -0,0 +1,5 @@
+{
+ "rollbackNetworkResponse" : {
+ "networkRolledBack" : true
+ }
+}
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
index bea4c1bb3b..80f111b570 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
@@ -85,7 +85,7 @@ public class SDNCRestClient{
@Async
public void executeRequest(SDNCAdapterRequest bpelRequest)
{
-
+
logger.debug("BPEL Request:" + bpelRequest.toString());
// Added delay to allow completion of create request to SDNC
@@ -93,7 +93,9 @@ public class SDNCRestClient{
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "SDNC",
+ ErrorCode.UnknownError.getValue(), "Exception processing request to SDNC", e);
+
Thread.currentThread().interrupt();
}
@@ -104,12 +106,10 @@ public class SDNCRestClient{
String sdncReqBody = null;
-
-
RequestTunables rt = new RequestTunables(bpelReqId,
bpelRequest.getRequestHeader().getMsoAction(),
bpelRequest.getRequestHeader().getSvcOperation(),
- bpelRequest.getRequestHeader().getSvcAction());
+ bpelRequest.getRequestHeader().getSvcAction());
rt = tunablesMapper.setTunables(rt);
rt.setSdncaNotificationUrl(env.getProperty(Constants.MY_URL_PROP));
@@ -176,8 +176,8 @@ public class SDNCRestClient{
sdncResp.setRespCode(con.getResponseCode());
sdncResp.setRespMsg(con.getResponseMessage());
- if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) {
- in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+ if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) {
+ in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
//Not parsing the response -it contains a responseHdr section and data section
while ((inputLine = in.readLine()) != null) {
@@ -185,7 +185,7 @@ public class SDNCRestClient{
}
in.close();
}
-
+
sdncResp.setSdncRespXml(response.toString());
logger.info("{} :\n {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.name(), sdncResp.toString(), "SDNC");
return(sdncResp);
@@ -314,7 +314,7 @@ public class SDNCRestClient{
SDNCCallbackAdapterPortType cbPort = cbSvc.getSDNCCallbackAdapterSoapHttpPort();
BindingProvider bp = (BindingProvider)cbPort;
-
+
if(null != wsdlUrl) {
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm());
}
diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml
index 50fbdd447b..7b774a2cce 100644
--- a/asdc-controller/pom.xml
+++ b/asdc-controller/pom.xml
@@ -1,265 +1,270 @@
-<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.4.0-SNAPSHOT</version>
- </parent>
+<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.4.0-SNAPSHOT</version>
+ </parent>
- <groupId>org.onap.so</groupId>
- <artifactId>asdc-controller</artifactId>
- <name>asdc-controller</name>
- <description>ASDC CLient and Controller</description>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <antlr.version>4.7.1</antlr.version>
- <java.version>1.8</java.version>
- </properties>
+ <groupId>org.onap.so</groupId>
+ <artifactId>asdc-controller</artifactId>
+ <name>asdc-controller</name>
+ <description>ASDC CLient and Controller</description>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <antlr.version>4.7.1</antlr.version>
+ <java.version>1.8</java.version>
+ <sdc.tosca.version>1.5.0</sdc.tosca.version>
+ <jtosca.version>1.5.0</jtosca.version>
+ </properties>
- <build>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.7.201606060606</version>
- <configuration>
- <excludes>
-+ <exclude>**/resource-examples/**</exclude>
- </excludes>
- </configuration>
- <executions>
- <execution>
- <id>default-prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report</id>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- <execution>
- <id>default-check</id>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <rules>
- <rule implementation="org.jacoco.maven.RuleConfiguration">
- <element>BUNDLE</element>
- <limits>
- <limit implementation="org.jacoco.report.check.Limit">
- <counter>INSTRUCTION</counter>
- <value>COVEREDRATIO</value>
- </limit>
- </limits>
- </rule>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- <version>${antlr.version}</version>
- <executions>
- <execution>
- <id>antlr</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>antlr4</goal>
- </goals>
- <configuration>
- <visitor>true</visitor>
- <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-testCompile</id>
- <phase>test-compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- <configuration>
- <generatedTestSourcesDirectory>${project.build.directory}/generated-sources</generatedTestSourcesDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <configuration>
- <mainClass>org.onap.so.asdc.Application</mainClass>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>extract-docker-file</id>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>fabric8-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>start</id>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>original</id>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jersey2-jaxrs</artifactId>
- <version>1.5.16</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jersey</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jdbc</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>mso-catalog-db</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.sdc-distribution-client</groupId>
- <artifactId>sdc-distribution-client</artifactId>
- <version>1.3.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <version>1.4.8</version>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.jtosca</groupId>
- <artifactId>jtosca</artifactId>
- <version>1.4.8</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>mso-api-handler-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>mso-requests-db</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>mso-requests-db-repositories</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4</artifactId>
- <version>${antlr.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.vorburger.mariaDB4j</groupId>
- <artifactId>mariaDB4j</artifactId>
- <version>2.2.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-contract-wiremock</artifactId>
- <version>1.2.4.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>io.micrometer</groupId>
- <artifactId>micrometer-core</artifactId>
- </dependency>
- <dependency>
- <groupId>io.micrometer</groupId>
- <artifactId>micrometer-registry-prometheus</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.interceptor</groupId>
- <artifactId>javax.interceptor-api</artifactId>
- </dependency>
- </dependencies>
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.7.201606060606</version>
+ <configuration>
+ <excludes>
+ +
+ <exclude>**/resource-examples/**</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <rule implementation="org.jacoco.maven.RuleConfiguration">
+ <element>BUNDLE</element>
+ <limits>
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>INSTRUCTION</counter>
+ <value>COVEREDRATIO</value>
+ </limit>
+ </limits>
+ </rule>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>${antlr.version}</version>
+ <executions>
+ <execution>
+ <id>antlr</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ <configuration>
+ <visitor>true</visitor>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ <configuration>
+ <generatedTestSourcesDirectory>${project.build.directory}/generated-sources
+ </generatedTestSourcesDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>org.onap.so.asdc.Application</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>extract-docker-file</id>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>fabric8-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start</id>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>original</id>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>1.5.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jersey</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jdbc</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-catalog-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>${sdc.tosca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.jtosca</groupId>
+ <artifactId>jtosca</artifactId>
+ <version>${jtosca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-api-handler-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db-repositories</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.vorburger.mariaDB4j</groupId>
+ <artifactId>mariaDB4j</artifactId>
+ <version>2.2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-contract-wiremock</artifactId>
+ <version>1.2.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.interceptor</groupId>
+ <artifactId>javax.interceptor-api</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index fd810e1e67..c9332e8f84 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -24,6 +24,11 @@ d * ============LICENSE_START===================================================
package org.onap.so.asdc.client;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -31,7 +36,6 @@ import java.io.UnsupportedEncodingException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;
-
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
@@ -48,6 +52,9 @@ import org.onap.so.asdc.client.exceptions.ASDCDownloadException;
import org.onap.so.asdc.client.exceptions.ASDCParametersException;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.IVfResourceInstaller;
+import org.onap.so.asdc.installer.PnfResourceStructure;
+import org.onap.so.asdc.installer.ResourceStructure;
+import org.onap.so.asdc.installer.ResourceType;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.asdc.installer.VfResourceStructure;
import org.onap.so.asdc.installer.bpmn.BpmnInstaller;
@@ -65,12 +72,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Component
public class ASDCController {
@@ -79,54 +80,49 @@ public class ASDCController {
protected boolean isAsdcClientAutoManaged = false;
protected String controllerName;
-
+
private ASDCControllerStatus controllerStatus = ASDCControllerStatus.STOPPED;
-
+
protected int nbOfNotificationsOngoing = 0;
@Autowired
private ToscaResourceInstaller toscaInstaller;
-
+
@Autowired
private BpmnInstaller bpmnInstaller;
-
+
@Autowired
private WatchdogDistributionStatusRepository wdsRepo;
-
+
@Autowired
private ASDCConfiguration asdcConfig;
-
+
@Autowired
private ASDCStatusCallBack asdcStatusCallBack;
-
+
@Autowired
private ASDCNotificationCallBack asdcNotificationCallBack;
-
+
private IDistributionClient distributionClient;
-
+
private static final String UUID_PARAM = "(UUID:";
-
+
@Autowired
private WatchdogDistribution wd;
-
- public int getNbOfNotificationsOngoing () {
+ public int getNbOfNotificationsOngoing() {
return nbOfNotificationsOngoing;
- }
+ }
public IDistributionClient getDistributionClient() {
- return distributionClient;
- }
-
-
-
- public void setDistributionClient(IDistributionClient distributionClient) {
- this.distributionClient = distributionClient;
- }
-
+ return distributionClient;
+ }
+ public void setDistributionClient(IDistributionClient distributionClient) {
+ this.distributionClient = distributionClient;
+ }
- protected void changeControllerStatus (ASDCControllerStatus newControllerStatus) {
+ protected void changeControllerStatus(ASDCControllerStatus newControllerStatus) {
switch (newControllerStatus) {
case BUSY:
@@ -150,97 +146,99 @@ public class ASDCController {
}
}
- public ASDCControllerStatus getControllerStatus () {
+ public ASDCControllerStatus getControllerStatus() {
return this.controllerStatus;
}
-
- public ASDCController () {
- isAsdcClientAutoManaged = true;
+
+ public ASDCController() {
+ this("");
}
- public ASDCController (String controllerConfigName) {
+ public ASDCController(String controllerConfigName) {
isAsdcClientAutoManaged = true;
this.controllerName = controllerConfigName;
}
- public ASDCController (String controllerConfigName, IDistributionClient asdcClient, IVfResourceInstaller resourceinstaller) {
- distributionClient = asdcClient;
+ public ASDCController(String controllerConfigName, IDistributionClient asdcClient,
+ IVfResourceInstaller resourceinstaller) {
+ distributionClient = asdcClient;
}
- public ASDCController (String controllerConfigName,IDistributionClient asdcClient) {
+ public ASDCController(String controllerConfigName, IDistributionClient asdcClient) {
distributionClient = asdcClient;
- this.controllerName = controllerConfigName;
+ this.controllerName = controllerConfigName;
}
+
public String getControllerName() {
- return controllerName;
- }
+ return controllerName;
+ }
- public void setControllerName(String controllerName) {
- this.controllerName = controllerName;
- }
+ public void setControllerName(String controllerName) {
+ this.controllerName = controllerName;
+ }
- /**
+ /**
* This method initializes the ASDC Controller and the ASDC Client.
*
* @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init
- * attempt is done when already initialized
+ * attempt is done when already initialized
* @throws ASDCParametersException If there is an issue with the parameters provided
* @throws IOException In case of issues when trying to load the key file
*/
- public void initASDC () throws ASDCControllerException {
+ public void initASDC() throws ASDCControllerException {
String event = "Initialize the ASDC Controller";
logger.debug(event);
- if (this.getControllerStatus () != ASDCControllerStatus.STOPPED) {
+ if (this.getControllerStatus() != ASDCControllerStatus.STOPPED) {
String endEvent = "The controller is already initialized, call the closeASDC method first";
- throw new ASDCControllerException (endEvent);
+ throw new ASDCControllerException(endEvent);
}
- if (asdcConfig != null) {
+ if (asdcConfig != null) {
asdcConfig.setAsdcControllerName(controllerName);
- }
+ }
if (this.distributionClient == null) {
- distributionClient = DistributionClientFactory.createDistributionClient ();
+ distributionClient = DistributionClientFactory.createDistributionClient();
}
-
- IDistributionClientResult result = this.distributionClient.init (asdcConfig,
- asdcNotificationCallBack, asdcStatusCallBack);
- if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) {
+
+ IDistributionClientResult result = this.distributionClient.init(asdcConfig,
+ asdcNotificationCallBack, asdcStatusCallBack);
+ if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client init failed with reason:"
- + result.getDistributionMessageResult ();
- logger.debug (endEvent);
- this.changeControllerStatus (ASDCControllerStatus.STOPPED);
- throw new ASDCControllerException ("Initialization of the ASDC Controller failed with reason: "
- + result.getDistributionMessageResult ());
+ + result.getDistributionMessageResult();
+ logger.debug(endEvent);
+ this.changeControllerStatus(ASDCControllerStatus.STOPPED);
+ throw new ASDCControllerException("Initialization of the ASDC Controller failed with reason: "
+ + result.getDistributionMessageResult());
}
- result = this.distributionClient.start ();
- if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) {
+ result = this.distributionClient.start();
+ if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client start failed with reason:"
- + result.getDistributionMessageResult ();
- logger.debug (endEvent);
- this.changeControllerStatus (ASDCControllerStatus.STOPPED);
- throw new ASDCControllerException ("Startup of the ASDC Controller failed with reason: "
- + result.getDistributionMessageResult ());
+ + result.getDistributionMessageResult();
+ logger.debug(endEvent);
+ this.changeControllerStatus(ASDCControllerStatus.STOPPED);
+ throw new ASDCControllerException("Startup of the ASDC Controller failed with reason: "
+ + result.getDistributionMessageResult());
}
- this.changeControllerStatus (ASDCControllerStatus.IDLE);
+ this.changeControllerStatus(ASDCControllerStatus.IDLE);
logger.info("{} {} {}", MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", "changeControllerStatus");
}
/**
* This method closes the ASDC Controller and the ASDC Client.
*
- * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because
- * it's currently BUSY in processing notifications.
+ * @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because it's currently
+ * BUSY in processing notifications.
*/
- public void closeASDC () throws ASDCControllerException {
+ public void closeASDC() throws ASDCControllerException {
- if (this.getControllerStatus () == ASDCControllerStatus.BUSY) {
- throw new ASDCControllerException ("Cannot close the ASDC controller as it's currently in BUSY state");
+ if (this.getControllerStatus() == ASDCControllerStatus.BUSY) {
+ throw new ASDCControllerException("Cannot close the ASDC controller as it's currently in BUSY state");
}
if (this.distributionClient != null) {
- this.distributionClient.stop ();
+ this.distributionClient.stop();
// If auto managed we can set it to Null, ASDCController controls it.
// In the other case the client of this class has specified it, so we can't reset it
if (isAsdcClientAutoManaged) {
@@ -249,59 +247,54 @@ public class ASDCController {
}
}
- this.changeControllerStatus (ASDCControllerStatus.STOPPED);
+ this.changeControllerStatus(ASDCControllerStatus.STOPPED);
}
- private boolean checkResourceAlreadyDeployed (VfResourceStructure resource) throws ArtifactInstallerException {
+ private boolean checkResourceAlreadyDeployed(VfResourceStructure resource) throws ArtifactInstallerException {
-
- if (toscaInstaller.isResourceAlreadyDeployed (resource)) {
- logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(),
- resource.getResourceInstance().getResourceInstanceName(),
- resource.getResourceInstance().getResourceUUID(),
- resource.getResourceInstance().getResourceName());
+ if (toscaInstaller.isResourceAlreadyDeployed(resource)) {
+ logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(),
+ resource.getResourceInstance().getResourceInstanceName(),
+ resource.getResourceInstance().getResourceUUID(),
+ resource.getResourceInstance().getResourceName());
- this.sendDeployNotificationsForResource(resource,DistributionStatusEnum.ALREADY_DOWNLOADED,null);
- this.sendDeployNotificationsForResource(resource,DistributionStatusEnum.ALREADY_DEPLOYED,null);
+ this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DOWNLOADED, null);
+ this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DEPLOYED, null);
- return true;
- } else {
- return false;
- }
+ return true;
+ } else {
+ return false;
+ }
}
-
- protected IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact,
- String distributionId) throws ASDCDownloadException {
+ protected IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact,
+ String distributionId) throws ASDCDownloadException {
- logger.debug("Trying to download the artifact : " + artifact.getArtifactURL ()
- + UUID_PARAM
- + artifact.getArtifactUUID ()
- + ")");
+ logger.info("Trying to download the artifact UUID: {} from URL: {}", artifact.getArtifactUUID(),
+ artifact.getArtifactURL());
IDistributionClientDownloadResult downloadResult;
-
try {
- downloadResult = distributionClient.download (artifact);
+ downloadResult = distributionClient.download(artifact);
if (null == downloadResult) {
- logger.info ("{} {}", MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID());
- return downloadResult;
+ logger.info("{} {}", MessageEnum.ASDC_ARTIFACT_NULL.toString(), artifact.getArtifactUUID());
+ return downloadResult;
}
} catch (RuntimeException e) {
- logger.debug ("Not able to download the artifact due to an exception: " + artifact.getArtifactURL ());
- this.sendASDCNotification (NotificationType.DOWNLOAD,
- artifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_ERROR,
- e.getMessage (),
- System.currentTimeMillis ());
-
- throw new ASDCDownloadException ("Exception caught when downloading the artifact", e);
+ logger.debug("Not able to download the artifact due to an exception: " + artifact.getArtifactURL());
+ this.sendASDCNotification(NotificationType.DOWNLOAD,
+ artifact.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ distributionId,
+ DistributionStatusEnum.DOWNLOAD_ERROR,
+ e.getMessage(),
+ System.currentTimeMillis());
+
+ throw new ASDCDownloadException("Exception caught when downloading the artifact", e);
}
- if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult ())) {
+ if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(), artifact.getArtifactURL(),
artifact.getArtifactUUID(), String.valueOf(downloadResult.getArtifactPayload().length));
@@ -311,143 +304,144 @@ public class ASDCController {
downloadResult.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
"ASDC artifact download fail");
- this.sendASDCNotification (NotificationType.DOWNLOAD,
- artifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_ERROR,
- downloadResult.getDistributionMessageResult (),
- System.currentTimeMillis ());
-
- throw new ASDCDownloadException ("Artifact " + artifact.getArtifactName ()
- + " could not be downloaded from ASDC URL "
- + artifact.getArtifactURL ()
- + UUID_PARAM
- + artifact.getArtifactUUID ()
- + ")"
- + System.lineSeparator ()
- + "Error message is "
- + downloadResult.getDistributionMessageResult ()
- + System.lineSeparator ());
+ this.sendASDCNotification(NotificationType.DOWNLOAD,
+ artifact.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ distributionId,
+ DistributionStatusEnum.DOWNLOAD_ERROR,
+ downloadResult.getDistributionMessageResult(),
+ System.currentTimeMillis());
+
+ throw new ASDCDownloadException("Artifact " + artifact.getArtifactName()
+ + " could not be downloaded from ASDC URL "
+ + artifact.getArtifactURL()
+ + UUID_PARAM
+ + artifact.getArtifactUUID()
+ + ")"
+ + System.lineSeparator()
+ + "Error message is "
+ + downloadResult.getDistributionMessageResult()
+ + System.lineSeparator());
}
- this.sendASDCNotification (NotificationType.DOWNLOAD,
- artifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_OK,
- null,
- System.currentTimeMillis ());
+ this.sendASDCNotification(NotificationType.DOWNLOAD,
+ artifact.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ distributionId,
+ DistributionStatusEnum.DOWNLOAD_OK,
+ null,
+ System.currentTimeMillis());
return downloadResult;
}
- private void writeArtifactToFile (IArtifactInfo artifact,
- IDistributionClientDownloadResult resultArtifact) {
+ private void writeArtifactToFile(IArtifactInfo artifact, IDistributionClientDownloadResult resultArtifact) {
- logger.debug(
- "Trying to write artifact to file : " + artifact.getArtifactURL() + UUID_PARAM + artifact.getArtifactUUID()
- + ")");
-
- String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString();
- // make parent directory
- File file = new File(filePath);
- File fileParent = file.getParentFile();
- if (!fileParent.exists()) {
- fileParent.mkdirs();
- }
-
- byte[] payloadBytes = resultArtifact.getArtifactPayload();
-
- try (FileOutputStream outFile = new FileOutputStream(filePath)) {
- logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***WRITE FILE ARTIFACT NAME",
- "ASDC", artifact.getArtifactName());
- outFile.write(payloadBytes, 0, payloadBytes.length);
- outFile.close();
- } catch (Exception e) {
- logger.debug("Exception :", e);
- logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
- artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
- resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
- "ASDC write to file failed");
+ String filePath = Paths
+ .get(getMsoConfigPath(), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize()
+ .toString();
+
+ logger.info("Trying to write artifact UUID: {}, URL: {} to file: {}", artifact.getArtifactUUID(),
+ artifact.getArtifactURL(), filePath);
+
+ // make parent directory
+ File file = new File(filePath);
+ File fileParent = file.getParentFile();
+ if (!fileParent.exists()) {
+ fileParent.mkdirs();
+ }
+
+ byte[] payloadBytes = resultArtifact.getArtifactPayload();
+
+ try (FileOutputStream outFile = new FileOutputStream(filePath)) {
+ logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***WRITE FILE ARTIFACT NAME",
+ "ASDC", artifact.getArtifactName());
+ outFile.write(payloadBytes, 0, payloadBytes.length);
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
+ artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
+ resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
+ "ASDC write to file failed");
}
}
- protected void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
-
- for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) {
-
- if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType().equalsIgnoreCase("OTHER") && !vfResourceStructure.isAlreadyDeployed())
- // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP
- && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null
- && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() == 0) {
- this.sendASDCNotification (NotificationType.DEPLOY,
- artifactInfo.getArtifactURL (),
- asdcConfig.getConsumerID (),
- vfResourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_ERROR,
- "The artifact has not been used by the modules defined in the resource",
- System.currentTimeMillis ());
- } else {
- this.sendASDCNotification (NotificationType.DEPLOY,
- artifactInfo.getArtifactURL (),
- asdcConfig.getConsumerID (),
- vfResourceStructure.getNotification().getDistributionID(),
- distribStatus,
- errorReason,
- System.currentTimeMillis ());
- }
- }
+ protected void sendDeployNotificationsForResource(ResourceStructure resourceStructure,
+ DistributionStatusEnum distribStatus, String errorReason) {
+
+ for (IArtifactInfo artifactInfo : resourceStructure.getResourceInstance().getArtifacts()) {
+
+ if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType()
+ .equalsIgnoreCase("OTHER") && !resourceStructure.isAlreadyDeployed())
+ // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP
+ && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null
+ && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb()
+ == 0) {
+ this.sendASDCNotification(NotificationType.DEPLOY,
+ artifactInfo.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_ERROR,
+ "The artifact has not been used by the modules defined in the resource",
+ System.currentTimeMillis());
+ } else {
+ this.sendASDCNotification(NotificationType.DEPLOY,
+ artifactInfo.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ resourceStructure.getNotification().getDistributionID(),
+ distribStatus,
+ errorReason,
+ System.currentTimeMillis());
+ }
+ }
}
-
- protected void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
-
- IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
-
- if(deploySuccessful){
-
- this.sendASDCNotification (NotificationType.DEPLOY,
- csarArtifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_OK,
- errorReason,
- System.currentTimeMillis ());
-
- } else {
-
- this.sendASDCNotification (NotificationType.DEPLOY,
- csarArtifact.getArtifactURL (),
- asdcConfig.getConsumerID (),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_ERROR,
- errorReason,
- System.currentTimeMillis ());
-
- }
+
+ protected void sendCsarDeployNotification(INotificationData iNotif, ResourceStructure resourceStructure,
+ ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
+
+ IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
+
+ if (deploySuccessful) {
+
+ this.sendASDCNotification(NotificationType.DEPLOY,
+ csarArtifact.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_OK,
+ errorReason,
+ System.currentTimeMillis());
+
+ } else {
+
+ this.sendASDCNotification(NotificationType.DEPLOY,
+ csarArtifact.getArtifactURL(),
+ asdcConfig.getConsumerID(),
+ resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_ERROR,
+ errorReason,
+ System.currentTimeMillis());
+
+ }
}
-
- protected void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
+
+ protected void deployResourceStructure(ResourceStructure resourceStructure,
+ ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
logger.info("{} {} {} {}", MessageEnum.ASDC_START_DEPLOY_ARTIFACT.toString(),
resourceStructure.getResourceInstance().getResourceInstanceName(),
resourceStructure.getResourceInstance().getResourceUUID(), "ASDC");
try {
- String resourceType = resourceStructure.getResourceInstance().getResourceType();
- String category = resourceStructure.getResourceInstance().getCategory();
- if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){
- resourceStructure.createVfModuleStructures();
- }
- toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure);
+ resourceStructure.prepareInstall();
+ toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure);
} catch (ArtifactInstallerException e) {
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
resourceStructure.getResourceInstance().getResourceName(),
resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf(resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure");
+ String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
throw e;
}
@@ -456,66 +450,66 @@ public class ASDCController {
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(),
resourceStructure.getResourceInstance().getResourceName(),
resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf(resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure");
+ String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_OK, null);
}
}
-
+
private enum NotificationType {
- DOWNLOAD, DEPLOY
+ DOWNLOAD, DEPLOY
}
- protected void sendASDCNotification (NotificationType notificationType,
- String artifactURL,
- String consumerID,
- String distributionID,
- DistributionStatusEnum status,
- String errorReason,
- long timestamp) {
-
- String event = "Sending " + notificationType.name ()
- + "("
- + status.name ()
- + ")"
- + " notification to ASDC for artifact:"
- + artifactURL;
+ protected void sendASDCNotification(NotificationType notificationType,
+ String artifactURL,
+ String consumerID,
+ String distributionID,
+ DistributionStatusEnum status,
+ String errorReason,
+ long timestamp) {
+
+ String event = "Sending " + notificationType.name()
+ + "("
+ + status.name()
+ + ")"
+ + " notification to ASDC for artifact:"
+ + artifactURL;
if (errorReason != null) {
- event=event+"("+errorReason+")";
+ event = event + "(" + errorReason + ")";
}
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC.toString(), notificationType.name(),
status.name(), artifactURL, "ASDC", "sendASDCNotification");
- logger.debug (event);
+ logger.debug(event);
String action = "";
try {
- IDistributionStatusMessage message = new DistributionStatusMessage (artifactURL,
- consumerID,
- distributionID,
- status,
- timestamp);
+ IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL,
+ consumerID,
+ distributionID,
+ status,
+ timestamp);
switch (notificationType) {
case DOWNLOAD:
if (errorReason != null) {
- this.distributionClient.sendDownloadStatus (message, errorReason);
+ this.distributionClient.sendDownloadStatus(message, errorReason);
} else {
- this.distributionClient.sendDownloadStatus (message);
+ this.distributionClient.sendDownloadStatus(message);
}
action = "sendDownloadStatus";
break;
case DEPLOY:
if (errorReason != null) {
- this.distributionClient.sendDeploymentStatus (message, errorReason);
+ this.distributionClient.sendDeploymentStatus(message, errorReason);
} else {
- this.distributionClient.sendDeploymentStatus (message);
+ this.distributionClient.sendDeploymentStatus(message);
}
action = "sendDeploymentdStatus";
break;
default:
- break;
+ break;
}
} catch (RuntimeException e) {
logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC",
@@ -523,148 +517,150 @@ public class ASDCController {
"RuntimeException - sendASDCNotification", e);
}
}
-
- protected void sendFinalDistributionStatus (
- String distributionID,
- DistributionStatusEnum status,
- String errorReason) {
+ protected void sendFinalDistributionStatus(
+ String distributionID,
+ DistributionStatusEnum status,
+ String errorReason) {
- logger.debug("Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status
+ logger.debug(
+ "Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status
.name() + " and ErrorReason " + errorReason);
- long subStarttime = System.currentTimeMillis ();
- try {
-
-
- IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID,status,subStarttime, asdcConfig.getConsumerID());
-
- if(errorReason == null){
- this.distributionClient.sendFinalDistrStatus(finalDistribution);
- }else{
- this.distributionClient.sendFinalDistrStatus(finalDistribution, errorReason);
- }
-
-
- } catch (RuntimeException e) {
- logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage());
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC", "sendASDCNotification",
- ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e);
- }
+ long subStarttime = System.currentTimeMillis();
+ try {
+
+ IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID, status,
+ subStarttime, asdcConfig.getConsumerID());
+
+ if (errorReason == null) {
+ this.distributionClient.sendFinalDistrStatus(finalDistribution);
+ } else {
+ this.distributionClient.sendFinalDistrStatus(finalDistribution, errorReason);
+ }
+
+
+ } catch (RuntimeException e) {
+ logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage());
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC",
+ "sendASDCNotification",
+ ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e);
+ }
}
- private Optional<String> getNotificationJson(INotificationData iNotif) {
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- mapper.setSerializationInclusion(Include.NON_EMPTY);
- mapper.setSerializationInclusion(Include.NON_ABSENT);
+ private Optional<String> getNotificationJson(INotificationData iNotif) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(Include.NON_EMPTY);
+ mapper.setSerializationInclusion(Include.NON_ABSENT);
mapper.enable(MapperFeature.USE_ANNOTATIONS);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- Optional<String> returnValue = Optional.empty();
- try {
- returnValue = Optional.of(mapper.writeValueAsString(iNotif));
- } catch (JsonProcessingException e) {
- logger.error("Error converting incoming ASDC notification to JSON" , e);
- }
- return returnValue;
- }
-
- public void treatNotification (INotificationData iNotif) {
-
- int noOfArtifacts = 0;
-
-
- for (IResourceInstance resource : iNotif.getResources ()) {
- noOfArtifacts += resource.getArtifacts ().size ();
- }
+ Optional<String> returnValue = Optional.empty();
+ try {
+ returnValue = Optional.of(mapper.writeValueAsString(iNotif));
+ } catch (JsonProcessingException e) {
+ logger.error("Error converting incoming ASDC notification to JSON", e);
+ }
+ return returnValue;
+ }
+
+ public void treatNotification(INotificationData iNotif) {
+
+ int noOfArtifacts = 0;
+
+ for (IResourceInstance resource : iNotif.getResources()) {
+ noOfArtifacts += resource.getArtifacts().size();
+ }
logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(), String.valueOf(noOfArtifacts),
iNotif.getServiceUUID(), "ASDC");
try {
- logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
- logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), "ASDC",
+ logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
+ logger
+ .info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), "ASDC",
"treatNotification");
this.changeControllerStatus(ASDCControllerStatus.BUSY);
- Optional<String> notificationMessage = getNotificationJson(iNotif);
- toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage,
- asdcConfig.getConsumerID());
-
- // Process only the Resource artifacts in MSO
- this.processResourceNotification(iNotif);
-
- //********************************************************************************************************
- //Start Watchdog loop and wait for all components to complete before reporting final status back.
- // **If timer expires first then we will report a Distribution Error back to ASDC
- //********************************************************************************************************
- long initialStartTime = System.currentTimeMillis();
- boolean componentsComplete = false;
- String distributionStatus = null;
- String watchdogError = null;
- String overallStatus = null;
- int watchDogTimeout = asdcConfig.getWatchDogTimeout() * 1000;
- boolean isDeploySuccess = false;
-
- while(!componentsComplete && (System.currentTimeMillis() - initialStartTime) < watchDogTimeout)
- {
-
- try{
- distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID());
- Thread.sleep(watchDogTimeout / 10);
- }catch(Exception e){
- logger.debug ("Exception in Watchdog Loop {}", e.getMessage());
- Thread.sleep(watchDogTimeout / 10);
- }
-
- if(distributionStatus != null && !distributionStatus.equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())){
-
- if(distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())){
- isDeploySuccess = true;
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name();
- }else{
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- }
- componentsComplete = true;
- }
- }
-
- if(!componentsComplete){
- logger.debug("Timeout of {} seconds was reached before all components reported status", watchDogTimeout);
- watchdogError = "Timeout occurred while waiting for all components to report status";
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- }
-
- if(distributionStatus == null){
- overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
- logger.debug("DistributionStatus is null for DistributionId: {}", iNotif.getDistributionID());
- }
-
- try {
- wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), overallStatus);
- logger.debug("A&AI Updated succefully with Distribution Status!");
- }
- catch(Exception e) {
- logger.debug("Exception in Watchdog executePatchAAI(): {}", e.getMessage());
- watchdogError = "Error calling A&AI " + e.getMessage();
- if(e.getCause() != null) {
- logger.debug("Exception caused by: {}", e.getCause().getMessage());
- }
- }
-
-
- if(isDeploySuccess && watchdogError == null){
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK, null);
- WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
- wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.toString());
- wdsRepo.save(wds);
- } else {
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError);
- WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
- wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
- wdsRepo.save(wds);
- }
-
-
- } catch(ObjectOptimisticLockingFailureException e) {
+ Optional<String> notificationMessage = getNotificationJson(iNotif);
+ toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage,
+ asdcConfig.getConsumerID());
+
+ // Process only the Resource artifacts in MSO
+ this.processResourceNotification(iNotif);
+
+ //********************************************************************************************************
+ //Start Watchdog loop and wait for all components to complete before reporting final status back.
+ // **If timer expires first then we will report a Distribution Error back to ASDC
+ //********************************************************************************************************
+ long initialStartTime = System.currentTimeMillis();
+ boolean componentsComplete = false;
+ String distributionStatus = null;
+ String watchdogError = null;
+ String overallStatus = null;
+ int watchDogTimeout = asdcConfig.getWatchDogTimeout() * 1000;
+ boolean isDeploySuccess = false;
+
+ while (!componentsComplete && (System.currentTimeMillis() - initialStartTime) < watchDogTimeout) {
+
+ try {
+ distributionStatus = wd.getOverallDistributionStatus(iNotif.getDistributionID());
+ Thread.sleep(watchDogTimeout / 10);
+ } catch (Exception e) {
+ logger.debug("Exception in Watchdog Loop {}", e.getMessage());
+ Thread.sleep(watchDogTimeout / 10);
+ }
+
+ if (distributionStatus != null && !distributionStatus
+ .equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())) {
+
+ if (distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())) {
+ isDeploySuccess = true;
+ overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.name();
+ } else {
+ overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
+ }
+ componentsComplete = true;
+ }
+ }
+
+ if (!componentsComplete) {
+ logger
+ .debug("Timeout of {} seconds was reached before all components reported status", watchDogTimeout);
+ watchdogError = "Timeout occurred while waiting for all components to report status";
+ overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
+ }
+
+ if (distributionStatus == null) {
+ overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
+ logger.debug("DistributionStatus is null for DistributionId: {}", iNotif.getDistributionID());
+ }
+
+ try {
+ wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(), overallStatus);
+ logger.debug("A&AI Updated succefully with Distribution Status!");
+ } catch (Exception e) {
+ logger.debug("Exception in Watchdog executePatchAAI(): {}", e.getMessage());
+ watchdogError = "Error calling A&AI " + e.getMessage();
+ if (e.getCause() != null) {
+ logger.debug("Exception caused by: {}", e.getCause().getMessage());
+ }
+ }
+
+ if (isDeploySuccess && watchdogError == null) {
+ sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK,
+ null);
+ WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
+ wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.toString());
+ wdsRepo.save(wds);
+ } else {
+ sendFinalDistributionStatus(iNotif.getDistributionID(),
+ DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError);
+ WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
+ wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
+ wdsRepo.save(wds);
+ }
+
+
+ } catch (ObjectOptimisticLockingFailureException e) {
logger.debug("OptimisticLockingFailure for DistributionId: {} Another process "
+ "has already altered this distribution, so not going to process it on this site.",
@@ -675,9 +671,10 @@ public class ASDCController {
} catch (Exception e) {
logger.error("", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Unexpected exception caught during the notification processing", "ASDC",
- "treatNotification", ErrorCode.SchemaError.getValue(), "RuntimeException in treatNotification",
- e);
+ "Unexpected exception caught during the notification processing", "ASDC",
+ "treatNotification", ErrorCode.SchemaError.getValue(),
+ "RuntimeException in treatNotification",
+ e);
try {
wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(),
@@ -690,167 +687,168 @@ public class ASDCController {
logger.debug("Exception caused by: {}", aaiException.getCause().getMessage());
}
}
-
- sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, e.getMessage());
-
- WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
- wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
- wdsRepo.save(wds);
-
+
+ sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR,
+ e.getMessage());
+
+ WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
+ wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
+ wdsRepo.save(wds);
+
} finally {
- this.changeControllerStatus (ASDCControllerStatus.IDLE);
+ this.changeControllerStatus(ASDCControllerStatus.IDLE);
}
}
- protected void processResourceNotification (INotificationData iNotif) {
- // For each artifact, create a structure describing the VFModule in a ordered flat level
- VfResourceStructure resourceStructure = null;
- ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
- boolean deploySuccessful = true;
- boolean hasVFResource = false;
- String errorMessage = null;
-
- try {
-
- this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
- IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
- String filePath = System.getProperty("mso.config.path") + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName();
- File csarFile = new File(filePath);
- String csarFilePath = csarFile.getAbsolutePath();
- if (bpmnInstaller.containsWorkflows(csarFilePath)) {
- bpmnInstaller.installBpmn(csarFilePath);
- }
-
- for (IResourceInstance resource : iNotif.getResources()){
-
- resourceStructure = new VfResourceStructure(iNotif,resource);
-
- String resourceType = resourceStructure.getResourceInstance().getResourceType();
- String category = resourceStructure.getResourceInstance().getCategory();
-
- logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure
- .getResourceInstance().getResourceUUID());
-
- if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){
-
- hasVFResource = true;
-
- for (IArtifactInfo artifact : resource.getArtifacts()) {
- IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,
- iNotif.getDistributionID());
- if (resultArtifact != null) {
-
- if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) {
- logger.debug("VF_MODULE_ARTIFACT: "+ new String(resultArtifact.getArtifactPayload(),"UTF-8"));
- logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact
- (resultArtifact.getArtifactPayload())));
- }
- resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact);
- }
- }
-
- //Deploy VF resource and artifacts
- logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
- try{
-
- this.deployResourceStructure(resourceStructure, toscaResourceStructure);
-
- } catch(ArtifactInstallerException e){
- deploySuccessful = false;
- errorMessage = e.getMessage();
- logger.error("Exception occurred", e);
- }
- }
-
- }
-
- // There are cases where the Service has no VF resources, those are handled here
- if (!hasVFResource) {
-
- logger.debug("No resources found for Service: {}", iNotif.getServiceUUID());
-
- try{
- resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance());
-
- this.deployResourceStructure(resourceStructure, toscaResourceStructure);
-
- } catch(ArtifactInstallerException e){
- deploySuccessful = false;
- errorMessage = e.getMessage();
- logger.error("Exception occurred", e);
- }
- }
- this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage);
-
- } catch (ASDCDownloadException | UnsupportedEncodingException e) {
- logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during Installation of artifact", "ASDC", "processResourceNotification",
- ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e);
- }
+ protected void processResourceNotification(INotificationData iNotif) {
+ // For each artifact, create a structure describing the VFModule in a ordered flat level
+ ResourceStructure resourceStructure = null;
+ String msoConfigPath = getMsoConfigPath();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
+ boolean deploySuccessful = true;
+ String errorMessage = null;
+
+ try {
+ this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
+ IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
+ String filePath =
+ msoConfigPath + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact
+ .getArtifactName();
+ File csarFile = new File(filePath);
+ String csarFilePath = csarFile.getAbsolutePath();
+ if (bpmnInstaller.containsWorkflows(csarFilePath)) {
+ bpmnInstaller.installBpmn(csarFilePath);
+ }
+
+ for (IResourceInstance resource : iNotif.getResources()) {
+
+ String resourceType = resource.getResourceType();
+ String category = resource.getCategory();
+
+ logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID());
+
+ if ("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)) {
+ resourceStructure = new VfResourceStructure(iNotif, resource);
+ } else if ("PNF".equals(resourceType)) {
+ resourceStructure = new PnfResourceStructure(iNotif, resource);
+ } else {
+ // There are cases where the Service has no VF resources, those are handled here
+ logger.info("No resources found for Service: {}", iNotif.getServiceUUID());
+ resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+ resourceStructure.setResourceType(ResourceType.OTHER);
+ }
+
+ for (IArtifactInfo artifact : resource.getArtifacts()) {
+ IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,
+ iNotif.getDistributionID());
+ if (resultArtifact != null) {
+ resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact);
+ }
+ }
+
+ //Deploy VF resource and artifacts
+ logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
+ try {
+ this.deployResourceStructure(resourceStructure, toscaResourceStructure);
+ } catch (ArtifactInstallerException e) {
+ deploySuccessful = false;
+ errorMessage = e.getMessage();
+ logger.error("Exception occurred", e);
+ }
+
+ this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful,
+ errorMessage);
+ }
+
+
+ } catch (ASDCDownloadException | UnsupportedEncodingException e) {
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during Installation of artifact", "ASDC", "processResourceNotification",
+ ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e);
+ }
}
- protected void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
-
- List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
-
- for(IArtifactInfo artifact : serviceArtifacts){
-
- if(artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)){
-
- try{
-
- toscaResourceStructure.setToscaArtifact(artifact);
-
- IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID());
-
- writeArtifactToFile(artifact, resultArtifact);
-
- toscaResourceStructure.updateResourceStructure(artifact);
-
- toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion());
-
- logger.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure));
-
-
- } catch(Exception e){
- logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
- ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts", e);
- }
- }
- else if(artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)){
-
- try{
-
- IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID());
-
- writeArtifactToFile(artifact, resultArtifact);
-
- toscaResourceStructure.setToscaArtifact(artifact);
-
- logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
-
-
- } catch(Exception e){
- logger.info("Whats the error {}", e.getMessage());
- logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
- ErrorCode.BusinessProcesssError.getValue(), "Exception in processCsarServiceArtifacts",
- e);
+
+ private String getMsoConfigPath() {
+ String msoConfigPath = System.getProperty("mso.config.path");
+ if (msoConfigPath == null) {
+ logger.info("Unable to find the system property mso.config.path, use the default configuration");
+ msoConfigPath = asdcConfig.getPropertyOrNull("mso.config.defaultpath");
+ }
+ if (msoConfigPath == null) {
+ logger.info("Unable to find the property: {} from configuration.", "mso.config.defaultpath");
+ msoConfigPath = "";
+ }
+ logger.info("MSO config path is: {}", msoConfigPath);
+ return msoConfigPath;
+ }
+
+ protected void processCsarServiceArtifacts(INotificationData iNotif,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
+
+ for (IArtifactInfo artifact : serviceArtifacts) {
+
+ if (artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)) {
+
+ try {
+
+ toscaResourceStructure.setToscaArtifact(artifact);
+
+ IDistributionClientDownloadResult resultArtifact = this
+ .downloadTheArtifact(artifact, iNotif.getDistributionID());
+
+ writeArtifactToFile(artifact, resultArtifact);
+
+ toscaResourceStructure.updateResourceStructure(artifact);
+
+ toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion());
+
+ logger.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure));
+
+
+ } catch (Exception e) {
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
+ ErrorCode.BusinessProcesssError.getValue(),
+ "Exception in processCsarServiceArtifacts", e);
+ }
+ } else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)) {
+
+ try {
+
+ IDistributionClientDownloadResult resultArtifact = this
+ .downloadTheArtifact(artifact, iNotif.getDistributionID());
+
+ writeArtifactToFile(artifact, resultArtifact);
+
+ toscaResourceStructure.setToscaArtifact(artifact);
+
+ logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
+
+
+ } catch (Exception e) {
+ logger.info("Whats the error {}", e.getMessage());
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
+ ErrorCode.BusinessProcesssError.getValue(),
+ "Exception in processCsarServiceArtifacts",
+ e);
+ }
}
- }
-
- }
+
+ }
}
-
- private static final String UNKNOWN="Unknown";
-
+
+ private static final String UNKNOWN = "Unknown";
+
/**
* @return the address of the ASDC we are connected to.
*/
- public String getAddress () {
+ public String getAddress() {
if (asdcConfig != null) {
- return asdcConfig.getAsdcAddress ();
+ return asdcConfig.getAsdcAddress();
}
return UNKNOWN;
}
@@ -858,9 +856,9 @@ public class ASDCController {
/**
* @return the environment name of the ASDC we are connected to.
*/
- public String getEnvironment () {
+ public String getEnvironment() {
if (asdcConfig != null) {
- return asdcConfig.getEnvironmentName ();
+ return asdcConfig.getEnvironmentName();
}
return UNKNOWN;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
index ed97f5bdea..759d88f196 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
@@ -41,7 +41,7 @@ public class ArtifactInfoImpl implements IArtifactInfo {
private ArtifactInfoImpl generatedArtifact;
private List<IArtifactInfo> relatedArtifactsInfo;
private List<ArtifactInfoImpl> relatedArtifactsImpl;
- ArtifactInfoImpl(){}
+ public ArtifactInfoImpl(){}
private ArtifactInfoImpl(IArtifactInfo iArtifactInfo){
artifactName = iArtifactInfo.getArtifactName();
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
index cbe16d864a..9462cc85d8 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
@@ -129,6 +129,10 @@ public class NotificationDataImpl implements INotificationData {
}
return ret;
}
+
+ public void setResources(List<ResourceInfoImpl> resources){
+ this.resources = resources;
+ }
public List<ResourceInfoImpl> getResourcesImpl(){
return resources;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
index dad7e64931..9103ae132e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
@@ -31,7 +31,7 @@ import org.onap.sdc.api.notification.IResourceInstance;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class ResourceInfoImpl implements IResourceInstance{
- ResourceInfoImpl (){}
+ public ResourceInfoImpl (){}
private String resourceInstanceName;
private String resourceCustomizationUUID;
private String resourceName;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java
new file mode 100644
index 0000000000..1c1351b272
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.installer;
+
+import java.io.UnsupportedEncodingException;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
+
+/**
+ * This class represents the PNF resource structure.
+ */
+public class PnfResourceStructure extends ResourceStructure {
+
+ public PnfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
+ super(notificationData, resourceInstance);
+ this.resourceType = ResourceType.PNF_RESOURCE;
+ }
+
+ @Override
+ public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
+
+ }
+
+ @Override
+ public void prepareInstall() throws ArtifactInstallerException {
+
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java
new file mode 100644
index 0000000000..53cc74f7e4
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java
@@ -0,0 +1,152 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.installer;
+
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract class to represent the resource structure.
+ *
+ * This structure exists to avoid having issues if the order of the resource artifact of tree structure is not good.
+ */
+public abstract class ResourceStructure {
+
+ /**
+ * Flag to indicate whether the resource is deployed successfully.
+ */
+ protected boolean isDeployedSuccessfully = false;
+
+ /**
+ * Flag to indicate whether the resource is already deployed.
+ */
+ protected boolean isAlreadyDeployed = false;
+
+ /**
+ * The resource type.
+ */
+ protected ResourceType resourceType;
+
+ /**
+ * The Raw notification data.
+ */
+ protected INotificationData notificationData;
+
+ /**
+ * The resource we will try to deploy.
+ */
+ protected IResourceInstance resourceInstance;
+
+ /**
+ * Number of resources provided by the resource structure.
+ */
+ protected int NumberOfResources;
+
+ /**
+ * The list of artifacts existing in this resource hashed by UUID.
+ */
+ protected final Map<String, VfModuleArtifact> artifactsMapByUUID;
+
+ public ResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
+ this.notificationData = notificationData;
+ this.resourceInstance = resourceInstance;
+ artifactsMapByUUID = new HashMap<>();
+ }
+
+ /**
+ * Add artifact to the resource structure.
+ *
+ * @param distributionClient
+ * @param artifactinfo
+ * @param clientResult
+ * @throws UnsupportedEncodingException
+ */
+ public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
+
+ /**
+ * Prepare the resource for installation.
+ *
+ * @throws ArtifactInstallerException
+ */
+ public abstract void prepareInstall() throws ArtifactInstallerException;
+
+ public boolean isDeployedSuccessfully() {
+ return isDeployedSuccessfully;
+ }
+
+ public void setDeployedSuccessfully(boolean deployedSuccessfully) {
+ isDeployedSuccessfully = deployedSuccessfully;
+ }
+
+ public boolean isAlreadyDeployed() {
+ return isAlreadyDeployed;
+ }
+
+ public void setAlreadyDeployed(boolean alreadyDeployed) {
+ isAlreadyDeployed = alreadyDeployed;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public INotificationData getNotification() {
+ return notificationData;
+ }
+
+ public void setNotification(INotificationData notificationData) {
+ this.notificationData = notificationData;
+ }
+
+ public IResourceInstance getResourceInstance() {
+ return resourceInstance;
+ }
+
+ public void setResourceInstance(IResourceInstance resourceInstance) {
+ this.resourceInstance = resourceInstance;
+ }
+
+ public int getNumberOfResources() {
+ return NumberOfResources;
+ }
+
+ public void setNumberOfResources(int numberOfResources) {
+ NumberOfResources = numberOfResources;
+ }
+
+ public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
+ return artifactsMapByUUID;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java
new file mode 100644
index 0000000000..8d55f57dfa
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.installer;
+
+/**
+ * This enum defines the resource type, it's used for tosca parsing, extraction and ingestion in SO.
+ */
+public enum ResourceType {
+
+ /**
+ * VF resource and the category is not allotted_resource.
+ */
+ VF_RESOURCE,
+
+ /**
+ * PNF resource.
+ */
+ PNF_RESOURCE,
+
+ /**
+ * Other resource type, including VF resource of allotted_resource category.
+ */
+ OTHER
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
index 6616bf4b54..3efc503fcb 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
@@ -43,6 +43,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
@@ -54,8 +55,16 @@ import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
public class ToscaResourceStructure {
+
+ protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class);
+
+ /**
+ * mso config path, used for the config files, like download csar files.
+ */
+ private String msoConfigPath;
Metadata serviceMetadata;
private Service catalogService;
@@ -100,6 +109,8 @@ public class ToscaResourceStructure {
private VfModuleCustomization vfModuleCustomization;
private VnfResourceCustomization vnfResourceCustomization;
+
+ private PnfResourceCustomization pnfResourceCustomization;
private AllottedResource allottedResource;
@@ -111,22 +122,21 @@ public class ToscaResourceStructure {
private ToscaCsar toscaCsar;
- protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class);
-
-
public ToscaResourceStructure(){
+ this(System.getProperty("mso.config.path"));
}
-
+
+ public ToscaResourceStructure(final String msoConfigPath){
+ this.msoConfigPath = msoConfigPath;
+ logger.info("MSO config path is: {}", msoConfigPath);
+ }
+
public void updateResourceStructure(IArtifactInfo artifact) throws ASDCDownloadException {
-
-
+
try {
-
SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable
-
- logger.debug("MSO config path is: " + System.getProperty("mso.config.path"));
-
- String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString();
+
+ String filePath = Paths.get(msoConfigPath, "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString();
File spoolFile = new File(filePath);
@@ -137,7 +147,7 @@ public class ToscaResourceStructure {
sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(),false);
}catch(Exception e){
- logger.info("System out {}", e.getMessage());
+ logger.debug(e.getMessage(), e);
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
"Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC",
"processResourceNotification", ErrorCode.BusinessProcesssError.getValue(),
@@ -259,6 +269,15 @@ public class ToscaResourceStructure {
this.vnfResourceCustomization = vnfResourceCustomization;
}
+ public PnfResourceCustomization getPnfResourceCustomization() {
+ return pnfResourceCustomization;
+ }
+
+ public void setPnfResourceCustomization(PnfResourceCustomization pnfResourceCustomization) {
+ this.pnfResourceCustomization = pnfResourceCustomization;
+ }
+
+
public VfModuleCustomization getCatalogVfModuleCustomization() {
return vfModuleCustomization;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
index 92fc598e7d..cb4761c557 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
@@ -42,8 +42,7 @@ public final class VfModuleArtifact {
private HeatEnvironment heatEnvironment;
public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- artifactInfo=artifactinfo;
- result = new String(clientResult.getArtifactPayload(), "UTF-8");
+ this(artifactinfo, clientResult, null);
}
public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException {
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
index 5b24dc56a1..402af160c1 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
@@ -10,9 +10,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
+import org.onap.so.asdc.util.ASDCNotificationLogging;
import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
@@ -49,186 +50,156 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure).
- *
+ * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree
+ * structure).
*/
-
-
-public class VfResourceStructure {
-
- protected static final Logger logger = LoggerFactory.getLogger(VfResourceStructure.class);
-
- private boolean isDeployedSuccessfully=false;
- /**
- * The Raw notification data.
- */
- private final INotificationData notification;
- /**
- * The Raw notification data.
- */
- private boolean isAlreadyDeployed=false;
-
- /**
- * The resource we will try to deploy.
- */
- private final IResourceInstance resourceInstance;
-
- /**
- * The list of VfModules defined for this resource.
- */
- private final List<VfModuleStructure> vfModulesStructureList;
-
- /**
- * The list of VfModulesMetadata defined for this resource.
- */
- private List<IVfModuleData> vfModulesMetadataList;
-
- private VnfResource catalogVnfResource;
-
- private NetworkResourceCustomization catalogNetworkResourceCustomization;
-
- private AllottedResourceCustomization catalogResourceCustomization;
-
- private Service catalogService;
-
- /**
- * The list of artifacts existing in this resource hashed by UUID.
- */
- private final Map<String, VfModuleArtifact> artifactsMapByUUID;
-
-
- public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) {
- notification=notificationdata;
- resourceInstance=resourceinstance;
- vfModulesStructureList = new LinkedList<>();
- artifactsMapByUUID = new HashMap<>();
- }
-
- public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult);
- addArtifactByType(artifactinfo,clientResult,vfModuleArtifact);
- }
-
- public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException {
- VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult,modifiedHeatTemplate);
- addArtifactByType(artifactinfo,clientResult,vfModuleArtifact);
- }
-
- protected void addArtifactByType(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
-
- switch(artifactinfo.getArtifactType()) {
- case ASDCConfiguration.HEAT:
- case ASDCConfiguration.HEAT_ENV:
- case ASDCConfiguration.HEAT_VOL:
- case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported
- case ASDCConfiguration.HEAT_ARTIFACT:
- case ASDCConfiguration.HEAT_NET:
- case ASDCConfiguration.OTHER:
- artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact);
- break;
- case ASDCConfiguration.VF_MODULES_METADATA:
- vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
- break;
- default:
- break;
- }
- }
-
- public void createVfModuleStructures() throws ArtifactInstallerException {
-
- //for vender tosca VNF there is no VFModule in VF
- if (vfModulesMetadataList == null) {
- logger.info("{} {} {} {}", MessageEnum.ASDC_GENERAL_INFO.toString(), "There is no VF mudules in the VF.", "ASDC",
- "createVfModuleStructures");
- return;
- }
- for (IVfModuleData vfModuleMeta:vfModulesMetadataList) {
- vfModulesStructureList.add(new VfModuleStructure(this,vfModuleMeta));
- }
- }
-
- public INotificationData getNotification() {
- return notification;
- }
-
- public IResourceInstance getResourceInstance() {
- return resourceInstance;
- }
-
- public List<VfModuleStructure> getVfModuleStructure() {
- return vfModulesStructureList;
- }
-
- public boolean isDeployedSuccessfully() {
- return isDeployedSuccessfully;
- }
-
- public void setSuccessfulDeployment() {
- isDeployedSuccessfully = true;
- }
-
- public boolean isAlreadyDeployed() {
- return isAlreadyDeployed;
- }
-
- public void setAlreadyDeployed(boolean isAlreadyDeployed) {
- this.isAlreadyDeployed = isAlreadyDeployed;
- }
-
- public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
- return artifactsMapByUUID;
- }
-
- public List<VfModuleStructure> getVfModulesStructureList() {
- return vfModulesStructureList;
- }
-
- public VnfResource getCatalogVnfResource() {
- return catalogVnfResource;
- }
-
- public void setCatalogVnfResource(VnfResource catalogVnfResource) {
- this.catalogVnfResource = catalogVnfResource;
- }
-
- // Network Only
- public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
- return catalogNetworkResourceCustomization;
- }
- // Network Only
- public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) {
- this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
- }
-
- public AllottedResourceCustomization getCatalogResourceCustomization() {
- return catalogResourceCustomization;
- }
-
- public void setCatalogResourceCustomization(
- AllottedResourceCustomization catalogResourceCustomization) {
- this.catalogResourceCustomization = catalogResourceCustomization;
- }
-
- public Service getCatalogService() {
- return catalogService;
- }
-
- public void setCatalogService(Service catalogService) {
- this.catalogService = catalogService;
- }
-
- public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
- try {
- List<IVfModuleData> listVFModuleMetaData = new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>(){});
- return listVFModuleMetaData;
-
- } catch (JsonParseException e) {
- logger.debug("JsonParseException : ",e);
- } catch (JsonMappingException e) {
- logger.debug("JsonMappingException : ",e);
- } catch (IOException e) {
- logger.debug("IOException : ",e);
- }
- return null;
- }
+public class VfResourceStructure extends ResourceStructure {
+
+ protected static final Logger logger = LoggerFactory.getLogger(VfResourceStructure.class);
+
+ /**
+ * The list of VfModules defined for this resource.
+ */
+ private final List<VfModuleStructure> vfModulesStructureList;
+
+ /**
+ * The list of VfModulesMetadata defined for this resource.
+ */
+ private List<IVfModuleData> vfModulesMetadataList;
+
+ private VnfResource catalogVnfResource;
+
+ private NetworkResourceCustomization catalogNetworkResourceCustomization;
+
+ private AllottedResourceCustomization catalogResourceCustomization;
+
+ private Service catalogService;
+
+
+ public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) {
+ super(notificationdata, resourceinstance);
+ this.resourceType = ResourceType.VF_RESOURCE;
+ vfModulesStructureList = new LinkedList<>();
+ }
+
+ public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
+ this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null);
+ }
+
+ public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate)
+ throws UnsupportedEncodingException {
+ VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate);
+ addArtifactByType(artifactinfo, clientResult, vfModuleArtifact);
+ if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) {
+ logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8"));
+ logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList));
+ }
+ }
+
+ protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
+ VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
+
+ switch (artifactinfo.getArtifactType()) {
+ case ASDCConfiguration.HEAT:
+ case ASDCConfiguration.HEAT_ENV:
+ case ASDCConfiguration.HEAT_VOL:
+ case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported
+ case ASDCConfiguration.HEAT_ARTIFACT:
+ case ASDCConfiguration.HEAT_NET:
+ case ASDCConfiguration.OTHER:
+ artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact);
+ break;
+ case ASDCConfiguration.VF_MODULES_METADATA:
+ vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void prepareInstall() throws ArtifactInstallerException{
+ createVfModuleStructures();
+ }
+
+ public void createVfModuleStructures() throws ArtifactInstallerException {
+
+ //for vender tosca VNF there is no VFModule in VF
+ if (vfModulesMetadataList == null) {
+ logger.info("{} {} {} {}", MessageEnum.ASDC_GENERAL_INFO.toString(), "There is no VF mudules in the VF.",
+ "ASDC",
+ "createVfModuleStructures");
+ return;
+ }
+ for (IVfModuleData vfModuleMeta : vfModulesMetadataList) {
+ vfModulesStructureList.add(new VfModuleStructure(this, vfModuleMeta));
+ }
+ setNumberOfResources(vfModulesMetadataList.size());
+ }
+
+ public List<VfModuleStructure> getVfModuleStructure() {
+ return vfModulesStructureList;
+ }
+
+ public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
+ return artifactsMapByUUID;
+ }
+
+ public List<VfModuleStructure> getVfModulesStructureList() {
+ return vfModulesStructureList;
+ }
+
+ public VnfResource getCatalogVnfResource() {
+ return catalogVnfResource;
+ }
+
+ public void setCatalogVnfResource(VnfResource catalogVnfResource) {
+ this.catalogVnfResource = catalogVnfResource;
+ }
+
+ // Network Only
+ public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
+ return catalogNetworkResourceCustomization;
+ }
+
+ // Network Only
+ public void setCatalogNetworkResourceCustomization(
+ NetworkResourceCustomization catalogNetworkResourceCustomization) {
+ this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
+ }
+
+ public AllottedResourceCustomization getCatalogResourceCustomization() {
+ return catalogResourceCustomization;
+ }
+
+ public void setCatalogResourceCustomization(
+ AllottedResourceCustomization catalogResourceCustomization) {
+ this.catalogResourceCustomization = catalogResourceCustomization;
+ }
+
+ public Service getCatalogService() {
+ return catalogService;
+ }
+
+ public void setCatalogService(Service catalogService) {
+ this.catalogService = catalogService;
+ }
+
+ public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
+ try {
+ List<IVfModuleData> listVFModuleMetaData = new ObjectMapper()
+ .readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {
+ });
+ return listVFModuleMetaData;
+
+ } catch (JsonParseException e) {
+ logger.debug("JsonParseException : ", e);
+ } catch (JsonMappingException e) {
+ logger.debug("JsonMappingException : ", e);
+ } catch (IOException e) {
+ logger.debug("IOException : ", e);
+ }
+ return null;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 5af427a81a..db639dad0a 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -10,9 +10,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,6 +24,8 @@
package org.onap.so.asdc.installer.heat;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
@@ -35,13 +37,15 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.api.notification.IStatusData;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -62,6 +66,8 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.ASDCElementInfo;
import org.onap.so.asdc.installer.BigDecimalVersion;
import org.onap.so.asdc.installer.IVfModuleData;
+import org.onap.so.asdc.installer.PnfResourceStructure;
+import org.onap.so.asdc.installer.ResourceStructure;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.asdc.installer.VfModuleArtifact;
import org.onap.so.asdc.installer.VfModuleStructure;
@@ -84,6 +90,8 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
import org.onap.so.db.catalog.beans.SubType;
@@ -109,6 +117,8 @@ import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
@@ -133,2007 +143,2323 @@ import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Component
public class ToscaResourceInstaller {
- protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
-
- protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
-
- protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
-
- protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
-
- protected static final String SCALABLE = "scalable";
-
- protected static final String BASIC = "BASIC";
-
- protected static final String PROVIDER = "PROVIDER";
-
- protected static final String HEAT = "HEAT";
-
- protected static final String MANUAL_RECORD = "MANUAL_RECORD";
-
- protected static final String MSO = "SO";
-
-
- @Autowired
- protected ServiceRepository serviceRepo;
-
- @Autowired
- protected InstanceGroupRepository instanceGroupRepo;
-
- @Autowired
- protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
-
- @Autowired
- protected CollectionResourceRepository collectionRepo;
-
- @Autowired
- protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceRepository configRepo;
-
- @Autowired
- protected VnfResourceRepository vnfRepo;
-
- @Autowired
- protected VnfCustomizationRepository vnfCustomizationRepo;
-
- @Autowired
- protected VFModuleRepository vfModuleRepo;
-
- @Autowired
- protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
-
- @Autowired
- protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
-
- @Autowired
- protected VnfcCustomizationRepository vnfcCustomizationRepo;
-
- @Autowired
- protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
-
- @Autowired
- protected AllottedResourceRepository allottedRepo;
-
- @Autowired
- protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
-
- @Autowired
- protected NetworkResourceRepository networkRepo;
-
- @Autowired
- protected HeatTemplateRepository heatRepo;
-
- @Autowired
- protected NetworkResourceCustomizationRepository networkCustomizationRepo;
-
- @Autowired
- protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
- @Autowired
- protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
- @Autowired
- protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
-
- @Autowired
- protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
-
- @Autowired
- protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
-
- protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
-
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
- boolean status = false;
- VfResourceStructure vfResourceStructure = vfResourceStruct;
- try {
- status = vfResourceStructure.isDeployedSuccessfully();
- } catch (RuntimeException e) {
- status = false;
- }
- try {
- Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
- if(existingService != null)
- status = true;
- if (status) {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.saveAndFlush(wdStatus);
- } else {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- }
- return status;
- } catch (Exception e) {
- logger
- .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
- "Exception - isResourceAlreadyDeployed");
- throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
- }
- }
-
- public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
- logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
- iStatus.getDistributionID(), iStatus.getComponentName());
-
- try {
- WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
- iStatus.getComponentName());
- cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
- watchdogCDStatusRepository.save(cdStatus);
-
- } catch (Exception e) {
- logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
- throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
- }
- }
-
- @Transactional(rollbackFor = { ArtifactInstallerException.class })
- public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
- throws ArtifactInstallerException {
- VfResourceStructure vfResourceStructure = vfResourceStruct;
- extractHeatInformation(toscaResourceStruct, vfResourceStructure);
-
- // PCLO: in case of deployment failure, use a string that will represent
- // the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- try {
- createToscaCsar(toscaResourceStruct);
- Service service = createService(toscaResourceStruct, vfResourceStruct);
-
- processResourceSequence(toscaResourceStruct, service);
- processVFResources(toscaResourceStruct, service, vfResourceStructure);
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
- processAllottedResources(toscaResourceStruct, service, allottedResourceList);
- processNetworks(toscaResourceStruct, service);
- // process Network Collections
- processNetworkCollections(toscaResourceStruct, service);
- // Process Service Proxy & Configuration
- processServiceProxyAndConfiguration(toscaResourceStruct, service);
-
- serviceRepo.save(service);
-
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.save(status);
-
- toscaResourceStruct.setSuccessfulDeployment();
-
- } catch (Exception e) {
- logger.debug("Exception :", e);
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
- watchdogCDStatusRepository.save(status);
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
- vfResourceStructure.getResourceInstance().getResourceName(),
- vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
- "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (!artifactListForLogging.isEmpty()
- ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
- : "No element listed");
- logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- ErrorCode.DataError.getValue(),
- "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
- + ". Transaction rollback", e);
- throw new ArtifactInstallerException("Exception caught during installation of "
- + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
- }
- }
-
-
- List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
- ISdcCsarHelper iSdcCsarHelper) {
-
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
- List<RequirementAssignment> reqAs = requirement.getAll();
- for (RequirementAssignment ra : reqAs) {
- String reqNode = ra.getNodeTemplateName();
- for (NodeTemplate rNode : resultList) {
- if (rNode.getName().equals(reqNode)) {
- if(!resultList.contains(nodeTemplate)) {
- resultList.add(nodeTemplate);
- }
- if(nodes.contains(nodeTemplate)) {
- nodes.remove(nodeTemplate);
- }
- break;
- }
- }
- }
- }
-
- if (!nodes.isEmpty()) {
- getRequirementList(resultList, nodes, iSdcCsarHelper);
- }
-
- return resultList;
- }
-
- // This method retrieve resource sequence from csar file
- void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
- List<String> resouceSequence = new ArrayList<String>();
- List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
-
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
- List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
-
- if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
- resultList.add(nodeTemplate);
- nodes.remove(nodeTemplate);
- }
- }
-
- resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
-
- for (NodeTemplate node : resultList) {
- String templateName = node.getMetaData().getValue("name");
- if (!resouceSequence.contains(templateName)) {
- resouceSequence.add(templateName);
- }
- }
-
- String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
- service.setResourceOrder(resourceSeqStr);
- logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
- }
-
- private static String CUSTOMIZATION_UUID = "customizationUUID";
-
- private static String getValue(Object value, List<Input> servInputs) {
- String output = null;
- if(value instanceof Map) {
- // currently this logic handles only one level of nesting.
- return ((LinkedHashMap) value).values().toArray()[0].toString();
- } else if(value instanceof GetInput) {
- String inputName = ((GetInput)value).getInputName();
-
- for(Input input : servInputs) {
- if(input.getName().equals(inputName)) {
- // keep both input name and default value
- // if service input does not supplies value the use default value
- String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
- output = inputName + "|" + defaultValue;// return default value
- }
- }
-
- } else {
- output = value != null ? value.toString() : "";
- }
- return output; // return property value
- }
-
- String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException {
- Map<String, String> resouceRequest = new HashMap<>();
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
-
- List<Input> serInput = iSdcCsarHelper.getServiceInputs();
- Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
- .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
- if(nodeTemplateOpt.isPresent()) {
- NodeTemplate nodeTemplate = nodeTemplateOpt.get();
- LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
-
- for(String key : resourceProperties.keySet()) {
- Property property = resourceProperties.get(key);
-
- String value = getValue(property.getValue(), serInput);
- resouceRequest.put(key, value);
- }
- }
-
- try {
- ObjectMapper objectMapper = new ObjectMapper();
- String jsonStr = objectMapper.writeValueAsString(resouceRequest);
-
- jsonStr = jsonStr.replace("\"", "\\\"");
- logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
- return jsonStr;
- } catch (JsonProcessingException e) {
- logger.error("resource input could not be deserialized for resource customization id ("
- + resourceCustomizationUuid + ")");
- throw new ArtifactInstallerException("resource input could not be parsed", e);
- }
- }
-
- protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
- Service service) throws ArtifactInstallerException {
- List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
-
- if (nodeTemplatesVLList != null) {
- for (NodeTemplate vlNode : nodeTemplatesVLList) {
- String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
+ protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
+
+ protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
+
+ protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
+
+ protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
+
+ protected static final String SCALABLE = "scalable";
+
+ protected static final String BASIC = "BASIC";
+
+ protected static final String PROVIDER = "PROVIDER";
+
+ protected static final String HEAT = "HEAT";
+
+ protected static final String MANUAL_RECORD = "MANUAL_RECORD";
+
+ protected static final String MSO = "SO";
+
+ protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
+
+ protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
+
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
+
+
+ @Autowired
+ protected ServiceRepository serviceRepo;
+
+ @Autowired
+ protected InstanceGroupRepository instanceGroupRepo;
+
+ @Autowired
+ protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
+
+ @Autowired
+ protected CollectionResourceRepository collectionRepo;
+
+ @Autowired
+ protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceRepository configRepo;
+
+ @Autowired
+ protected VnfResourceRepository vnfRepo;
+
+ @Autowired
+ protected VnfCustomizationRepository vnfCustomizationRepo;
+
+ @Autowired
+ protected VFModuleRepository vfModuleRepo;
+
+ @Autowired
+ protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
+
+ @Autowired
+ protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
+
+ @Autowired
+ protected VnfcCustomizationRepository vnfcCustomizationRepo;
+
+ @Autowired
+ protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
+
+ @Autowired
+ protected AllottedResourceRepository allottedRepo;
+
+ @Autowired
+ protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
+
+ @Autowired
+ protected NetworkResourceRepository networkRepo;
+
+ @Autowired
+ protected HeatTemplateRepository heatRepo;
+
+ @Autowired
+ protected NetworkResourceCustomizationRepository networkCustomizationRepo;
+
+ @Autowired
+ protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+ @Autowired
+ protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
+ @Autowired
+ protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
+
+ @Autowired
+ protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
+
+ @Autowired
+ protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
+
+ @Autowired
+ protected PnfResourceRepository pnfResourceRepository;
+
+ @Autowired
+ protected PnfCustomizationRepository pnfCustomizationRepository;
+
+ protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
+
+ public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+ boolean status = false;
+ VfResourceStructure vfResourceStructure = vfResourceStruct;
+ try {
+ status = vfResourceStructure.isDeployedSuccessfully();
+ } catch (RuntimeException e) {
+ status = false;
+ }
+ try {
+ Service existingService = serviceRepo
+ .findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
+ if (existingService != null) {
+ status = true;
+ }
+ if (status) {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(
+ vfResourceStruct.getNotification().getDistributionID(), MSO);
+ wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.saveAndFlush(wdStatus);
+ } else {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ }
+ return status;
+ } catch (Exception e) {
+ logger
+ .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(),
+ ErrorCode.SchemaError.getValue(),
+ "Exception - isResourceAlreadyDeployed");
+ throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
+ }
+ }
+
+ public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
+ logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
+ iStatus.getDistributionID(), iStatus.getComponentName());
+
+ try {
+ WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(
+ iStatus.getDistributionID(),
+ iStatus.getComponentName());
+ cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
+ watchdogCDStatusRepository.save(cdStatus);
+
+ } catch (Exception e) {
+ logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
+ throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
+ }
+ }
+
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+ if (resourceStruct instanceof VfResourceStructure) {
+ installTheVfResouce(toscaResourceStruct, (VfResourceStructure) resourceStruct);
+ } else if (resourceStruct instanceof PnfResourceStructure) {
+ installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
+ } else {
+ logger.warn("Unrecognized resource type");
+ }
+ }
+
+ private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, resourceStruct);
+
+ processResourceSequence(toscaResourceStruct, service);
+ processPnfResources(toscaResourceStruct, service, resourceStruct);
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ resourceStruct.getResourceInstance().getResourceName(),
+ resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of " + resourceStruct.getResourceInstance()
+ .getResourceName()
+ + ". Transaction rollback", e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
+
+ private void installTheVfResouce(ToscaResourceStructure toscaResourceStruct, VfResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+ VfResourceStructure vfResourceStructure = resourceStruct;
+ extractHeatInformation(toscaResourceStruct, vfResourceStructure);
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, resourceStruct);
+
+ processResourceSequence(toscaResourceStruct, service);
+ processVFResources(toscaResourceStruct, service, vfResourceStructure);
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+ processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+ processNetworks(toscaResourceStruct, service);
+ // process Network Collections
+ processNetworkCollections(toscaResourceStruct, service);
+ // Process Service Proxy & Configuration
+ processServiceProxyAndConfiguration(toscaResourceStruct, service);
+
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ vfResourceStructure.getResourceInstance().getResourceName(),
+ vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of " + vfResourceStructure.getResourceInstance()
+ .getResourceName()
+ + ". Transaction rollback", e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
+
+
+ List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
+ ISdcCsarHelper iSdcCsarHelper) {
+
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+ List<RequirementAssignment> reqAs = requirement.getAll();
+ for (RequirementAssignment ra : reqAs) {
+ String reqNode = ra.getNodeTemplateName();
+ for (NodeTemplate rNode : resultList) {
+ if (rNode.getName().equals(reqNode)) {
+ if (!resultList.contains(nodeTemplate)) {
+ resultList.add(nodeTemplate);
+ }
+ if (nodes.contains(nodeTemplate)) {
+ nodes.remove(nodeTemplate);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if (!nodes.isEmpty()) {
+ getRequirementList(resultList, nodes, iSdcCsarHelper);
+ }
+
+ return resultList;
+ }
+
+ // This method retrieve resource sequence from csar file
+ void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
+ List<String> resouceSequence = new ArrayList<String>();
+ List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+
+ if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
+ resultList.add(nodeTemplate);
+ nodes.remove(nodeTemplate);
+ }
+ }
+
+ resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
+
+ for (NodeTemplate node : resultList) {
+ String templateName = node.getMetaData().getValue("name");
+ if (!resouceSequence.contains(templateName)) {
+ resouceSequence.add(templateName);
+ }
+ }
+
+ String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
+ service.setResourceOrder(resourceSeqStr);
+ logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
+ }
+
+ private static String getValue(Object value, List<Input> servInputs) {
+ String output = null;
+ if (value instanceof Map) {
+ // currently this logic handles only one level of nesting.
+ return ((LinkedHashMap) value).values().toArray()[0].toString();
+ } else if (value instanceof GetInput) {
+ String inputName = ((GetInput) value).getInputName();
+
+ for (Input input : servInputs) {
+ if (input.getName().equals(inputName)) {
+ // keep both input name and default value
+ // if service input does not supplies value the use default value
+ String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
+ output = inputName + "|" + defaultValue;// return default value
+ }
+ }
+
+ } else {
+ output = value != null ? value.toString() : "";
+ }
+ return output; // return property value
+ }
+
+ String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
+ throws ArtifactInstallerException {
+ Map<String, String> resouceRequest = new HashMap<>();
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+ List<Input> serInput = iSdcCsarHelper.getServiceInputs();
+ Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
+ .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
+ if (nodeTemplateOpt.isPresent()) {
+ NodeTemplate nodeTemplate = nodeTemplateOpt.get();
+ LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
+
+ for (String key : resourceProperties.keySet()) {
+ Property property = resourceProperties.get(key);
+
+ String value = getValue(property.getValue(), serInput);
+ resouceRequest.put(key, value);
+ }
+ }
+
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String jsonStr = objectMapper.writeValueAsString(resouceRequest);
+
+ jsonStr = jsonStr.replace("\"", "\\\"");
+ logger.debug(
+ "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
+ return jsonStr;
+ } catch (JsonProcessingException e) {
+ logger.error("resource input could not be deserialized for resource customization id ("
+ + resourceCustomizationUuid + ")");
+ throw new ArtifactInstallerException("resource input could not be parsed", e);
+ }
+ }
+
+ protected void processNetworks(ToscaResourceStructure toscaResourceStruct,
+ Service service) throws ArtifactInstallerException {
+ List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
+
+ if (nodeTemplatesVLList != null) {
+ for (NodeTemplate vlNode : nodeTemplatesVLList) {
+ String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
TempNetworkHeatTemplateLookup tempNetworkLookUp =
- tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
+ tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
if (tempNetworkLookUp != null) {
HeatTemplate heatTemplate =
- heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+ heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
if (heatTemplate != null) {
NetworkResourceCustomization networkCustomization =
- createNetwork (vlNode,
- toscaResourceStruct,
- heatTemplate,
- tempNetworkLookUp.getAicVersionMax (),
- tempNetworkLookUp.getAicVersionMin (),
- service);
- service.getNetworkCustomizations ().add (networkCustomization);
+ createNetwork(vlNode,
+ toscaResourceStruct,
+ heatTemplate,
+ tempNetworkLookUp.getAicVersionMax(),
+ tempNetworkLookUp.getAicVersionMin(),
+ service);
+ service.getNetworkCustomizations().add(networkCustomization);
+ } else {
+ throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
+ + tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ }
+ } else {
+ NetworkResourceCustomization networkCustomization = createNetwork(vlNode,
+ toscaResourceStruct,
+ null,
+ null,
+ null,
+ service);
+ service.getNetworkCustomizations().add(networkCustomization);
+ logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ + networkResourceModelName);
+ }
+
+ }
+ }
+ }
+
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ List<NodeTemplate> allottedResourceList) {
+ if (allottedResourceList != null) {
+ for (NodeTemplate allottedNode : allottedResourceList) {
+ service.getAllottedCustomizations()
+ .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ }
+ }
+ }
+
+
+ protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ ConfigurationResource configResource = new ConfigurationResource();
+ configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+ return configResource;
+ }
+
+ protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure,
+ ServiceProxyResourceCustomization spResourceCustomization) {
+ Metadata metadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ configCustomizationResource
+ .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+
+ configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ configCustomizationResource
+ .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
+
+ configCustomizationResource.setConfigurationResource(configResource);
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+ return configCustomizationResource;
+ }
+
+
+ protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(
+ List<NodeTemplate> configurationNodeTemplatesList,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
+ Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
+ for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if (VLAN_NETWORK_RECEPTOR.equals(type)) {
+ configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate,
+ toscaResourceStructure, spResourceCustomization));
+ break;
+ }
+ }
+
+ return configurationResourceCust;
+ }
+
+ protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper()
+ .getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+
+ List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper()
+ .getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+
+ List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
+ List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
+
+ ServiceProxyResourceCustomization serviceProxy = null;
+
+ if (serviceProxyResourceList != null) {
+ for (NodeTemplate spNode : serviceProxyResourceList) {
+ serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
+ serviceProxyList.add(serviceProxy);
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(
+ configurationNodeTemplatesList, toscaResourceStruct, serviceProxy);
+
+ for (NodeTemplate configNode : configurationNodeTemplatesList) {
+
+ List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper()
+ .getRequirementsOf(configNode).getAll();
+ for (RequirementAssignment requirement : requirementsList) {
+ if (requirement.getNodeTemplateName().equals(spNode.getName())) {
+ ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
+ toscaResourceStruct, serviceProxy, vnrResourceCustomization);
+
+ Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList
+ .stream()
+ .filter(configurationResourceCustomization -> configNode.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
+ .equals(configurationResource.getModelCustomizationUUID()))
+ .findFirst();
+ if (!matchingObject.isPresent()) {
+ configurationResourceList.add(configurationResource);
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+ service.setConfigurationCustomizations(configurationResourceList);
+ service.setServiceProxyCustomizations(serviceProxyList);
+ }
+
+ protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper()
+ .getServiceNodeTemplateBySdcType(SdcTypes.CR);
+
+ if (networkCollectionList != null) {
+ for (NodeTemplate crNode : networkCollectionList) {
+
+ createNetworkCollection(crNode, toscaResourceStruct, service);
+ collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
+
+ List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct
+ .getCatalogNetworkInstanceGroup();
+ for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
+ instanceGroupRepo.saveAndFlush(networkInstanceGroup);
+ }
+
+ }
+ }
+ service.getCollectionResourceCustomizations()
+ .add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
+ }
+
+
+ protected void processVFResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ VfResourceStructure vfResourceStructure)
+ throws Exception {
+ logger.debug("processVFResources");
+
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ // Do not treat Allotted Resources as VNF resources
+ if (ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)) {
+ continue;
+ }
+
+ String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca
+ // customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
+
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+ /**
+ * This is used to process the PNF specific resource, including resource and resource_customization. {@link
+ * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
+ */
+ protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ PnfResourceStructure resourceStructure) throws Exception {
+ logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
+
+ ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+
+ List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+ for (IEntityDetails entityDetails : entityDetailsList) {
+ Metadata metadata = entityDetails.getMetadata();
+ String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
+ if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
+ logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+
+ if (checkExistingPnfResourceCutomization(customizationUUID)) {
+ logger.info("Resource customization UUID: {} already deployed", customizationUUID);
+ } else {
+ PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
+ if (pnfResource == null) {
+ pnfResource = createPnfResource(entityDetails);
+ }
+ PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
+ pnfResource);
+ pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
+ toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
+ service.getPnfCustomizations().add(pnfResourceCustomization);
+ }
+ } else {
+ logger
+ .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+ }
+ }
+ }
+
+ private PnfResource findExistingPnfResource(Service service, String modelUuid) {
+ PnfResource pnfResource = null;
+ for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
+ if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
+ .getModelUUID().equals(modelUuid)) {
+ pnfResource = pnfResourceCustomization.getPnfResources();
+ }
+ }
+ if (pnfResource == null) {
+ pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
+ }
+ return pnfResource;
+ }
+
+ private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
+ return pnfCustomizationRepository.findById(customizationUUID).isPresent();
+ }
+
+ /**
+ * Construct the {@link PnfResource} from {@link IEntityDetails} object.
+ */
+ private PnfResource createPnfResource(IEntityDetails entity) {
+ PnfResource pnfResource = new PnfResource();
+ Metadata metadata = entity.getMetadata();
+ pnfResource.setModelInvariantUUID(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ pnfResource.setModelVersion(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ pnfResource.setDescription(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+ pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ pnfResource.setToscaNodeType(entity.getToscaType());
+ return pnfResource;
+ }
+
+ /**
+ * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
+ */
+ private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
+ PnfResource pnfResource) {
+
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ Metadata metadata = entityDetails.getMetadata();
+ Map<String, Property> properties = entityDetails.getProperties();
+ pnfResourceCustomization
+ .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+ pnfResourceCustomization
+ .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
+ pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
+ pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
+ pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
+
+ pnfResourceCustomization.setPnfResources(pnfResource);
+
+ return pnfResourceCustomization;
+ }
+
+ /**
+ * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
+ */
+ private String getStringValue(Property property) {
+ if (null == property) {
+ return "";
+ }
+ Object value = property.getValue();
+ return String.valueOf(value);
+ }
+
+ protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
+ Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
+ throws Exception {
+
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure()
+ .isEmpty()) {
+
+ String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource
+ .getResourceCustomizationUUID() +
+ " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
+
+ Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+ List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
+ .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata
+ .getVfModuleModelCustomizationUUID());
+
+ Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ .peek(group -> logger.debug(
+ "To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata()
+ .getValue("vfModuleModelCustomizationUUID")))
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
+ .equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
+ if (matchingObject.isPresent()) {
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
+ nodeTemplate, toscaResourceStruct,
+ vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
+ vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+ } else {
+ throw new Exception(
+ "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata
+ .getVfModuleModelCustomizationUUID());
+ }
+
+ }
+
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource
+ .getResourceCustomizationUUID() + " doesn't match " +
+ "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+
+ service.getVnfCustomizations().add(vnfResource);
+ }
+
+ public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
+ String consumerId) {
+ WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
+ distributionNotification, consumerId);
+ watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
+
+ try {
+
+ WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
+ watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
+
+ } catch (ObjectOptimisticLockingFailureException e) {
+ logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
+ throw e;
+ }
+ }
+
+ protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
+ VfResourceStructure vfResourceStructure) {
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
+ case ASDCConfiguration.HEAT:
+ case ASDCConfiguration.HEAT_NESTED:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
+ vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_VOL:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
+ vfModuleArtifact);
+ VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure,
+ vfModuleArtifact);
+ createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ENV:
+ createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ARTIFACT:
+ createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
+ toscaResourceStruct);
+ break;
+ case ASDCConfiguration.HEAT_NET:
+ case ASDCConfiguration.OTHER:
+ logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
+ vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact
+ .getArtifactInfo()
+ .getArtifactName() + ")", ErrorCode.DataError.getValue(),
+ "Artifact type not supported");
+ break;
+ default:
+ break;
+
+ }
+ }
+ }
+
+ protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
+ artifactName = artifactName.substring(0, artifactName.indexOf('.'));
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+ if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
+ && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ return moduleArtifact;
+ }
+ }
+ return null;
+ }
+
+ public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
+ List<String> listTypes) {
+ String newFileBody = filebody;
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
+
+ newFileBody = verifyTheFilePrefixInString(newFileBody,
+ moduleArtifact.getArtifactInfo().getArtifactName());
+ }
+ }
+ return newFileBody;
+ }
+
+ public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
+
+ String needlePrefix = "file:///";
+ String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
+
+ if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
+ return body;
+ }
+
+ StringBuilder sb = new StringBuilder(body.length());
+
+ int currentIndex = 0;
+ int startIndex = 0;
+
+ while (currentIndex != -1) {
+ startIndex = currentIndex;
+ currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
+
+ if (currentIndex == -1) {
+ break;
+ }
+ // We append from the startIndex up to currentIndex (start of File
+ // Name)
+ sb.append(body.substring(startIndex, currentIndex));
+ sb.append(filenameToVerify);
+
+ currentIndex += prefixedFilenameToVerify.length();
+ }
+
+ sb.append(body.substring(startIndex));
+
+ return sb.toString();
+ }
+
+ protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
+ ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT_NESTED);
+ typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
+
+ heatTemplate.setTemplateBody(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
+ heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
+ } else {
+ heatTemplate.setTimeoutMinutes(240);
+ }
+
+ heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatTemplate.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatTemplate.setArtifactChecksum(MANUAL_RECORD);
+ }
+
+ Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
+ vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatTemplate.setParameters(heatParam);
+ vfModuleArtifact.setHeatTemplate(heatTemplate);
+ }
+
+ protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT);
+ typeList.add(ASDCConfiguration.HEAT_VOL);
+ heatEnvironment.setEnvironment(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatEnvironment.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatEnvironment(heatEnvironment);
+ }
+
+ protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
+
+ HeatFiles heatFile = new HeatFiles();
+ heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatFile.setFileBody(vfModuleArtifact.getResult());
+ heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ heatFile.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatFile.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatFiles(heatFile);
+ }
+
+ protected Service createService(ToscaResourceStructure toscaResourceStructure,
+ ResourceStructure resourceStructure) {
+
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+
+ Service service = new Service();
+
+ if (serviceMetadata != null) {
+
+ if (toscaResourceStructure.getServiceVersion() != null) {
+ service.setModelVersion(toscaResourceStructure.getServiceVersion());
+ }
+
+ service.setServiceType(serviceMetadata.getValue("serviceType"));
+ service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+ service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
+
+ if (resourceStructure != null) {
+ service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
+ }
+
+ service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
+ }
+
+ toscaResourceStructure.setCatalogService(service);
+ return service;
+ }
+
+ protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata spMetadata = nodeTemplate.getMetaData();
+
+ ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
+
+ Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
+
+ spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ spCustomizationResource
+ .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ spCustomizationResource
+ .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+
+ String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
+
+ Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
+
+ spCustomizationResource.setSourceService(sourceService);
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+ serviceProxyCustomizationSet.add(spCustomizationResource);
+
+ toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
+
+ return spCustomizationResource;
+ }
+
+ protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
+
+ ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(
+ nodeTemplate,
+ toscaResourceStructure, spResourceCustomization);
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if (NODES_VRF_ENTRY.equals(type)) {
+ configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
+ }
+
+ configCustomizationResource.setConfigurationResource(configResource);
+
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+
+ toscaResourceStructure.setCatalogConfigurationResource(configResource);
+
+ toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
+
+ return configCustomizationResource;
+ }
+
+ protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata fabricMetadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = new ConfigurationResource();
+
+ configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+
+ return configResource;
+ }
+
+ protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
+ ToscaCsar toscaCsar = new ToscaCsar();
+ if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
+ toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
+ } else {
+ toscaCsar.setArtifactChecksum(MANUAL_RECORD);
+ }
+ toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
+ toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
+ toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
+ toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
+
+ toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
+ }
+
+ protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
+ VnfcCustomization vnfcCustomization = null;
+ for (VnfcCustomization vnfcCustom : vnfcCustomizations) {
+ if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ vnfcCustomization = vnfcCustom;
+ }
+ }
+
+ if (vnfcCustomization == null) {
+ vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+ }
+
+ return vnfcCustomization;
+ }
+
+ protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations,
+ String customizationUUID) {
+ CvnfcCustomization cvnfcCustomization = null;
+ for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) {
+ if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ cvnfcCustomization = cvnfcCustom;
+ }
+ }
+
+ if (cvnfcCustomization == null) {
+ cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+ }
+
+ return cvnfcCustomization;
+ }
+
+ protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
+ Service service) {
+
+ NetworkResourceCustomization networkResourceCustomization = networkCustomizationRepo
+ .findOneByModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ boolean networkUUIDsMatch = true;
+ // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
+ // If not we'll update the Customization record with latest from the distribution
+ if (networkResourceCustomization != null) {
+ String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
+ String latestNetworkModelUUID = networkNodeTemplate.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+
+ if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
+ networkUUIDsMatch = false;
+ }
+
+ }
+
+ if (networkResourceCustomization != null && !networkUUIDsMatch) {
+
+ NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure,
+ heatTemplate,
+ aicMax, aicMin);
+
+ networkResourceCustomization.setNetworkResource(networkResource);
+
+ networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
+
+ } else if (networkResourceCustomization == null) {
+ networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
+ toscaResourceStructure);
+
+ NetworkResource networkResource = findExistingNetworkResource(service,
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ if (networkResource == null) {
+ networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
+ aicMax, aicMin);
+ }
+
+ networkResource.addNetworkResourceCustomization(networkResourceCustomization);
+ networkResourceCustomization.setNetworkResource(networkResource);
+ }
+
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
+ NetworkResource networkResource = null;
+ for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) {
+ if (networkCustom.getNetworkResource() != null
+ && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
+ networkResource = networkCustom.getNetworkResource();
+ }
+ }
+ if (networkResource == null) {
+ networkResource = networkRepo.findResourceByModelUUID(modelUUID);
+ }
+
+ return networkResource;
+ }
+
+ protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+ networkResourceCustomization.setModelInstanceName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ networkResourceCustomization.setModelCustomizationUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+
+ networkResourceCustomization.setNetworkTechnology(
+ testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
+ networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
+ networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
+ networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
+ NetworkResource networkResource = new NetworkResource();
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource.setModelName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+
+ networkResource.setModelInvariantUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ networkResource.setModelUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ networkResource.setModelVersion(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+
+ networkResource.setAicVersionMax(aicMax);
+ networkResource.setAicVersionMin(aicMin);
+ networkResource.setToscaNodeType(networkNodeTemplate.getType());
+ networkResource.setDescription(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ networkResource.setOrchestrationMode(HEAT);
+ networkResource.setHeatTemplate(heatTemplate);
+ return networkResource;
+ }
+
+ protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+
+ CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
+
+ // **** Build Object to populate Collection_Resource table
+ CollectionResource collectionResource = new CollectionResource();
+
+ collectionResource
+ .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ collectionResource.setModelInvariantUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ collectionResource
+ .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ collectionResource
+ .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ collectionResource
+ .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ collectionResource.setToscaNodeType(networkNodeTemplate.getType());
+
+ toscaResourceStructure.setCatalogCollectionResource(collectionResource);
+
+ // **** Build object to populate Collection_Resource_Customization table
+ NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
+
+ ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_function"));
+ ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_role"));
+ ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_type"));
+
+ ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ ncfc.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
+ networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
+
+ ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
+
+ ncfc.setCollectionResource(collectionResource);
+ toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
+
+ //*** Build object to populate the Instance_Group table
+ List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
+ .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
+ "org.openecomp.groups.NetworkCollection");
+
+ List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
+
+ List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
+
+ for (Group group : groupList) {
+
+ NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
+ Metadata instanceMetadata = group.getMetadata();
+ networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ networkInstanceGroup
+ .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ networkInstanceGroup.setToscaNodeType(group.getType());
+ networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
+ // Role
+ networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
+ // type
+ networkInstanceGroup.setCollectionResource(collectionResource);
+
+ // ****Build object to populate
+ // Collection_Resource_Instance_Group_Customization table
+ CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
+ crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
+ crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ crInstanceGroupCustomization.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
+ List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper()
+ .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate,
+ "org.openecomp.policies.scaling.Fixed");
+
+ if (policyList != null) {
+ for (Policy policy : policyList) {
+ for (String policyNetworkCollection : policy.getTargets()) {
+
+ if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if (propMap.get("quantity") != null) {
+
+ String quantity = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ getPropertyInput(propMap.get("quantity").toString()));
+
+ if (quantity != null) {
+ crInstanceGroupCustomization
+ .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
+ }
+
+ }
+
+ }
+ }
+ }
+ }
+
+ crInstanceGroupCustomization.setDescription(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_description"));
+ crInstanceGroupCustomization.setFunction(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_function"));
+ crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
+ collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
+
+ networkInstanceGroup
+ .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
+
+ networkInstanceGroupList.add(networkInstanceGroup);
+
+ toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
+
+ List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
+
+ List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
+
+ //*****Build object to populate the NetworkResource table
+ NetworkResource networkResource = new NetworkResource();
+
+ for (NodeTemplate vlNodeTemplate : vlNodeList) {
+
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource
+ .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ networkResource.setModelInvariantUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkResource
+ .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkResource
+ .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+
+ networkResource.setAicVersionMax(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo
+ .findFirstBynetworkResourceModelName(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ if (tempNetworkLookUp != null) {
+
+ HeatTemplate heatTemplate = heatRepo
+ .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ networkResource.setHeatTemplate(heatTemplate);
+
+ networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
+
+ }
+
+ networkResource.setToscaNodeType(vlNodeTemplate.getType());
+ networkResource
+ .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ networkResource.setOrchestrationMode(HEAT);
+
+ // Build object to populate the
+ // Collection_Network_Resource_Customization table
+ for (NodeTemplate memberNode : group.getMemberNodes()) {
+ collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
+ }
+
+ collectionNetworkResourceCustomization.setModelCustomizationUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ collectionNetworkResourceCustomization.setNetworkTechnology(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
+ collectionNetworkResourceCustomization.setNetworkResource(networkResource);
+ collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
+
+ collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
+ }
+
+ }
+
+ return collectionNetworkResourceCustomization;
+ }
+
+ protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
+ VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata instanceMetadata = group.getMetadata();
+ // Populate InstanceGroup
+ VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+
+ vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vfcInstanceGroup.setToscaNodeType(group.getType());
+ vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
+ vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
+
+ //Populate VNFCInstanceGroupCustomization
+ VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
+
+ vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
+ vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ String getInputName = null;
+ String groupProperty = toscaResourceStructure.getSdcCsarHelper()
+ .getGroupPropertyLeafValue(group, "vfc_instance_group_function");
+ if (groupProperty != null) {
+ int getInputIndex = groupProperty.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1);
+ }
+ }
+ vfcInstanceGroupCustom.setFunction(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
+
+ vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
+ vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
+
+ return vfcInstanceGroupCustom;
+
+ }
+
+ protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
+ ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
+ IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
+ Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
+
+ VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
+ vfModuleData.getVfModuleModelCustomizationUUID());
+ if (vfModuleCustomization == null) {
+ VfModule vfModule = findExistingVfModule(vnfResource,
+ vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ Metadata vfMetadata = group.getMetadata();
+ if (vfModule == null) {
+ vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
+ }
+
+ vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
+ setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
+ vfMetadata);
+ vfModuleCustomization.setVfModule(vfModule);
+ vfModule.getVfModuleCustomization().add(vfModuleCustomization);
+ vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
+ } else {
+ vfResourceStructure.setAlreadyDeployed(true);
+ }
+
+ //******************************************************************************************************************
+ //* Extract VFC's and CVFC's then add them to VFModule
+ //******************************************************************************************************************
+
+ Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
+ Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
+
+ // Only set the CVNFC if this vfModule group is a member of it.
+ List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper()
+ .getMembersOfVfModule(vfTemplate, group);
+ String vfModuleMemberName = null;
+
+ for (NodeTemplate node : groupMembers) {
+ vfModuleMemberName = node.getName();
+ }
+
+ // Extract CVFC lists
+ List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
+
+ for (NodeTemplate cvfcTemplate : cvfcList) {
+
+ CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet,
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) {
+
+ //Extract associated VFC - Should always be just one
+ List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+ for (NodeTemplate vfcTemplate : vfcList) {
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ VnfcCustomization existingVnfcCustomization = null;
+
+ existingVnfcCustomization = findExistingVfc(existingVnfcSet,
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (existingVnfcCustomization == null) {
+ vnfcCustomization = new VnfcCustomization();
} else {
- throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
- + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
- }
- } else {
- NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
- toscaResourceStruct,
- null,
- null,
- null,
- service);
- service.getNetworkCustomizations().add (networkCustomization);
- logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
- + networkResourceModelName);
- }
-
- }
- }
- }
-
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
- if (allottedResourceList != null) {
- for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
- }
- }
- }
-
-
- protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
- Metadata metadata = nodeTemplate.getMetaData();
- ConfigurationResource configResource = new ConfigurationResource();
- configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
- return configResource;
- }
-
- protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure,
- ServiceProxyResourceCustomization spResourceCustomization ) {
- Metadata metadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-
- configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
-
- configCustomizationResource.setConfigurationResource(configResource);
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
- return configCustomizationResource;
- }
-
-
- protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(List<NodeTemplate> configurationNodeTemplatesList,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
- Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
- for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if(VLAN_NETWORK_RECEPTOR.equals(type)) {
- configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate,
- toscaResourceStructure,spResourceCustomization));
- break;
- }
- }
-
- return configurationResourceCust;
- }
-
- protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
-
- List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
-
- List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
- List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
-
- ServiceProxyResourceCustomization serviceProxy = null;
-
- if (serviceProxyResourceList != null) {
- for (NodeTemplate spNode : serviceProxyResourceList) {
- serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
- serviceProxyList.add(serviceProxy);
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy);
-
- for (NodeTemplate configNode : configurationNodeTemplatesList) {
-
- List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
- for (RequirementAssignment requirement : requirementsList) {
- if (requirement.getNodeTemplateName().equals(spNode.getName())) {
- ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
-
- Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
- .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
- .findFirst();
- if(!matchingObject.isPresent()){
- configurationResourceList.add(configurationResource);
- }
-
- break;
- }
- }
- }
-
- }
- }
-
- service.setConfigurationCustomizations(configurationResourceList);
- service.setServiceProxyCustomizations(serviceProxyList);
- }
-
- protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
-
- if (networkCollectionList != null) {
- for (NodeTemplate crNode : networkCollectionList) {
-
- createNetworkCollection(crNode, toscaResourceStruct, service);
- collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
-
- List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
- for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
- instanceGroupRepo.saveAndFlush(networkInstanceGroup);
- }
-
- }
- }
- service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
- }
-
-
- protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
- throws Exception{
- logger.debug("processVFResources");
-
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-// String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
-// String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
- Metadata metadata = nodeTemplate.getMetaData();
- String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- // Do not treat Allotted Resources as VNF resources
- if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
- continue;
- }
-
- String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca
- // customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
- + vfCustomizationUUID);
-
- if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
- + " matches vfNotificationResource CustomizationUUID");
-
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
- } else {
- logger.debug("Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
- + "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
- }
-
-
- protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
-
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
- {
-
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
- " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
-
- if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
-
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
-
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
-
- Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
-
- logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
- List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
- .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
-
- logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
-
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
- .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
- if(matchingObject.isPresent()){
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
- vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
- vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
- }else
- throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
-
- }
- service.getVnfCustomizations().add(vnfResource);
- } else{
- logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
- "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
- }
-
- public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
- String consumerId) {
- WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
- distributionNotification, consumerId);
- watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
-
- try{
-
- WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
- watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
-
- } catch(ObjectOptimisticLockingFailureException e){
- logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
- throw e;
- }
- }
-
- protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
- VfResourceStructure vfResourceStructure) {
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
- case ASDCConfiguration.HEAT:
- case ASDCConfiguration.HEAT_NESTED:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_VOL:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
- createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ENV:
- createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ARTIFACT:
- createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
- toscaResourceStruct);
- break;
- case ASDCConfiguration.HEAT_NET:
- case ASDCConfiguration.OTHER:
- logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
- vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
- .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
- break;
- default:
- break;
-
- }
- }
- }
-
- protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
- artifactName = artifactName.substring(0, artifactName.indexOf('.'));
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
- if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
- && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- return moduleArtifact;
- }
- }
- return null;
- }
-
- public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
- List<String> listTypes) {
- String newFileBody = filebody;
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
-
- newFileBody = verifyTheFilePrefixInString(newFileBody,
- moduleArtifact.getArtifactInfo().getArtifactName());
- }
- }
- return newFileBody;
- }
-
- public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
-
- String needlePrefix = "file:///";
- String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
-
- if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
- return body;
- }
-
- StringBuilder sb = new StringBuilder(body.length());
-
- int currentIndex = 0;
- int startIndex = 0;
-
- while (currentIndex != -1) {
- startIndex = currentIndex;
- currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
-
- if (currentIndex == -1) {
- break;
- }
- // We append from the startIndex up to currentIndex (start of File
- // Name)
- sb.append(body.substring(startIndex, currentIndex));
- sb.append(filenameToVerify);
-
- currentIndex += prefixedFilenameToVerify.length();
- }
-
- sb.append(body.substring(startIndex));
-
- return sb.toString();
- }
-
- protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
- ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
- HeatTemplate heatTemplate = new HeatTemplate();
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT_NESTED);
- typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
-
- heatTemplate.setTemplateBody(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
- heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
- } else {
- heatTemplate.setTimeoutMinutes(240);
- }
-
- heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatTemplate.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatTemplate.setArtifactChecksum(MANUAL_RECORD);
- }
-
- Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
- vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatTemplate.setParameters(heatParam);
- vfModuleArtifact.setHeatTemplate(heatTemplate);
- }
-
- protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT);
- typeList.add(ASDCConfiguration.HEAT_VOL);
- heatEnvironment.setEnvironment(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatEnvironment.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatEnvironment(heatEnvironment);
- }
-
- protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
-
- HeatFiles heatFile = new HeatFiles();
- heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatFile.setFileBody(vfModuleArtifact.getResult());
- heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- heatFile.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatFile.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatFiles(heatFile);
- }
-
- protected Service createService(ToscaResourceStructure toscaResourceStructure,
- VfResourceStructure vfResourceStructure) {
-
- Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
-
- Service service = new Service();
-
- if (serviceMetadata != null) {
-
- if (toscaResourceStructure.getServiceVersion() != null) {
- service.setModelVersion(toscaResourceStructure.getServiceVersion());
- }
-
- service.setServiceType(serviceMetadata.getValue("serviceType"));
- service.setServiceRole(serviceMetadata.getValue("serviceRole"));
-
- service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
-
- if (vfResourceStructure != null)
- service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
-
- service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
- }
-
-
- toscaResourceStructure.setCatalogService(service);
- return service;
- }
-
- protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata spMetadata = nodeTemplate.getMetaData();
-
- ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
-
- Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
-
- spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
-
- String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
-
- Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
-
- spCustomizationResource.setSourceService(sourceService);
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
- serviceProxyCustomizationSet.add(spCustomizationResource);
-
-
- toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
-
- return spCustomizationResource;
- }
-
- protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
-
- ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate,
- toscaResourceStructure,spResourceCustomization);
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if(NODES_VRF_ENTRY.equals(type)) {
- configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
- }
-
- configCustomizationResource.setConfigurationResource(configResource);
-
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
-
- toscaResourceStructure.setCatalogConfigurationResource(configResource);
-
- toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
-
- return configCustomizationResource;
- }
-
- protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata fabricMetadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = new ConfigurationResource();
-
- configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
-
- return configResource;
- }
-
- protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
- ToscaCsar toscaCsar = new ToscaCsar();
- if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
- toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
- } else {
- toscaCsar.setArtifactChecksum(MANUAL_RECORD);
- }
- toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
- toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
- toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
- toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
- toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
-
- toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
- }
-
- protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
- VnfcCustomization vnfcCustomization = null;
- for(VnfcCustomization vnfcCustom : vnfcCustomizations){
- if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- vnfcCustomization = vnfcCustom;
- }
- }
-
- if(vnfcCustomization==null)
- vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
-
- return vnfcCustomization;
- }
-
- protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
- CvnfcCustomization cvnfcCustomization = null;
- for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
- if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- cvnfcCustomization = cvnfcCustom;
- }
- }
-
- if(cvnfcCustomization==null)
- cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
-
- return cvnfcCustomization;
- }
-
- protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
-
- NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- boolean networkUUIDsMatch = true;
- // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
- // If not we'll update the Customization record with latest from the distribution
- if(networkResourceCustomization != null){
- String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
- String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
-
- if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){
- networkUUIDsMatch = false;
- }
-
- }
-
- if (networkResourceCustomization!=null && !networkUUIDsMatch){
-
- NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
-
- networkResourceCustomization.setNetworkResource(networkResource);
-
- networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
-
- }
- else if(networkResourceCustomization==null){
- networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
- toscaResourceStructure);
-
- NetworkResource networkResource = findExistingNetworkResource(service,
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- if(networkResource == null)
- networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
-
- networkResource.addNetworkResourceCustomization(networkResourceCustomization);
- networkResourceCustomization.setNetworkResource(networkResource);
- }
-
- return networkResourceCustomization;
- }
-
- protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
- NetworkResource networkResource = null;
- for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
- if (networkCustom.getNetworkResource() != null
- && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
- networkResource = networkCustom.getNetworkResource();
- }
- }
- if(networkResource==null)
- networkResource = networkRepo.findResourceByModelUUID(modelUUID);
-
- return networkResource;
- }
-
- protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
- networkResourceCustomization.setModelInstanceName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- networkResourceCustomization.setModelCustomizationUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
-
- networkResourceCustomization.setNetworkTechnology(
- testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
- networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
- networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
- networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
- return networkResourceCustomization;
- }
-
- protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
- NetworkResource networkResource = new NetworkResource();
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource.setModelName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
-
- networkResource.setModelInvariantUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- networkResource.setModelUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- networkResource.setModelVersion(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-
- networkResource.setAicVersionMax(aicMax);
- networkResource.setAicVersionMin(aicMin);
- networkResource.setToscaNodeType(networkNodeTemplate.getType());
- networkResource.setDescription(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- networkResource.setOrchestrationMode(HEAT);
- networkResource.setHeatTemplate(heatTemplate);
- return networkResource;
- }
-
- protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
-
- CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
-
- // **** Build Object to populate Collection_Resource table
- CollectionResource collectionResource = new CollectionResource();
-
- collectionResource
- .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- collectionResource.setModelInvariantUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- collectionResource
- .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- collectionResource
- .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- collectionResource
- .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- collectionResource.setToscaNodeType(networkNodeTemplate.getType());
-
- toscaResourceStructure.setCatalogCollectionResource(collectionResource);
-
- // **** Build object to populate Collection_Resource_Customization table
- NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
-
- ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_function"));
- ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_role"));
- ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_type"));
-
- ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- ncfc.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
- networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
-
- ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
-
- ncfc.setCollectionResource(collectionResource);
- toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
-
- //*** Build object to populate the Instance_Group table
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
- "org.openecomp.groups.NetworkCollection");
-
- List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
-
- List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
-
- for (Group group : groupList) {
-
- NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
- Metadata instanceMetadata = group.getMetadata();
- networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- networkInstanceGroup
- .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- networkInstanceGroup.setToscaNodeType(group.getType());
- networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
- // Role
- networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
- // type
- networkInstanceGroup.setCollectionResource(collectionResource);
-
- // ****Build object to populate
- // Collection_Resource_Instance_Group_Customization table
- CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
- crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- crInstanceGroupCustomization.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
- List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
-
- if(policyList != null){
- for(Policy policy : policyList){
- for(String policyNetworkCollection : policy.getTargets()){
-
- if(policyNetworkCollection.equalsIgnoreCase(group.getName())){
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if(propMap.get("quantity") != null){
-
- String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString()));
-
- if(quantity != null){
- crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
- }
-
- }
-
- }
- }
- }
- }
-
- crInstanceGroupCustomization.setDescription(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_description"));
- crInstanceGroupCustomization.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_function"));
- crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
- collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
-
- networkInstanceGroup
- .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
-
- networkInstanceGroupList.add(networkInstanceGroup);
-
-
- toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
-
- List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
-
- List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
-
- //*****Build object to populate the NetworkResource table
- NetworkResource networkResource = new NetworkResource();
-
- for(NodeTemplate vlNodeTemplate : vlNodeList){
-
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- networkResource.setModelInvariantUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkResource
- .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
-
- networkResource.setAicVersionMax(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- if (tempNetworkLookUp != null ) {
-
- HeatTemplate heatTemplate = heatRepo
- .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
- networkResource.setHeatTemplate(heatTemplate);
-
- networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
-
- }
-
- networkResource.setToscaNodeType(vlNodeTemplate.getType());
- networkResource
- .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- networkResource.setOrchestrationMode(HEAT);
-
- // Build object to populate the
- // Collection_Network_Resource_Customization table
- for (NodeTemplate memberNode : group.getMemberNodes()) {
- collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
- }
-
- collectionNetworkResourceCustomization.setModelCustomizationUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- collectionNetworkResourceCustomization.setNetworkTechnology(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
- collectionNetworkResourceCustomization.setNetworkResource(networkResource);
- collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
-
- collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
- }
-
- }
-
- return collectionNetworkResourceCustomization;
- }
-
- protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
- VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata instanceMetadata = group.getMetadata();
- // Populate InstanceGroup
- VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
-
- vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- vfcInstanceGroup.setToscaNodeType(group.getType());
- vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
- vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
-
- //Populate VNFCInstanceGroupCustomization
- VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
-
- vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
- vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- String getInputName = null;
- String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function");
- if (groupProperty != null) {
- int getInputIndex = groupProperty.indexOf("{get_input=");
- if (getInputIndex > -1) {
- getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
- }
- }
- vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
-
- vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
- vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
-
- return vfcInstanceGroupCustom;
-
- }
-
- protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
- ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
- IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
-
- VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
- vfModuleData.getVfModuleModelCustomizationUUID());
- if(vfModuleCustomization == null){
- VfModule vfModule = findExistingVfModule(vnfResource,
- vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- Metadata vfMetadata = group.getMetadata();
- if(vfModule==null)
- vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
-
- vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
- setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
- vfMetadata);
- vfModuleCustomization.setVfModule(vfModule);
- vfModule.getVfModuleCustomization().add(vfModuleCustomization);
- vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
- } else {
- vfResourceStructure.setAlreadyDeployed(true);
- }
-
- //******************************************************************************************************************
- //* Extract VFC's and CVFC's then add them to VFModule
- //******************************************************************************************************************
-
- Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
- Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
-
- // Only set the CVNFC if this vfModule group is a member of it.
- List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
- String vfModuleMemberName = null;
-
- for(NodeTemplate node : groupMembers){
- vfModuleMemberName = node.getName();
- }
-
- // Extract CVFC lists
- List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
-
- for(NodeTemplate cvfcTemplate : cvfcList) {
-
- if(vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
-
- //Extract associated VFC - Should always be just one
- List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
-
- for(NodeTemplate vfcTemplate : vfcList) {
-
- VnfcCustomization vnfcCustomization = new VnfcCustomization();
- VnfcCustomization existingVnfcCustomization = null;
-
- existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if(existingVnfcCustomization == null){
- vnfcCustomization = new VnfcCustomization();
- } else {
- vnfcCustomization = existingVnfcCustomization;
- }
-
- // Only Add Abstract VNFC's to our DB, ignore all others
- if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
- vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
- vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- vnfcCustomization.setModelVersion(
- testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfcCustomization.setDescription(
- testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
-
- vnfcCustomizations.add(vnfcCustomization);
- existingVnfcSet.add(vnfcCustomization);
- }
-
- // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB.
- if(vnfcCustomization.getModelCustomizationUUID() != null){
-
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
-
- cvnfcCustomization = new CvnfcCustomization();
- cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
- cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- cvnfcCustomization.setModelVersion(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- cvnfcCustomization.setDescription(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
-
- if(existingVnfcCustomization != null){
- cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
- }else{
- cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
- }
-
- cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
- cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
- cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
- cvnfcCustomization.setVnfResourceCustomization(vnfResource);
-
- cvnfcCustomizations.add(cvnfcCustomization);
- existingCvnfcSet.add(cvnfcCustomization);
-
- //*****************************************************************************************************************************************
- //* Extract Fabric Configuration
- //*****************************************************************************************************************************************
-
- List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
-
- for(NodeTemplate fabricTemplate : fabricConfigList) {
-
- ConfigurationResource fabricConfig = null;
-
- ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if(existingConfig == null){
-
- fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
-
- }else {
- fabricConfig = existingConfig;
- }
-
- VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
- vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
- vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
- }
- cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
- }
-
- }
-
- }
- }
- vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
- vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
-
- return vfModuleCustomization;
- }
-
- protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
- VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
- ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
-
- Metadata fabricMetadata = fabricTemplate.getMetaData();
-
- VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
-
- vfModuleToCvnfc.setConfigurationResource(configResource);
- vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
- vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
- vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
- vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
-
- List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
-
- if(policyList != null){
- for(Policy policy : policyList){
-
- for(String policyCvfcTarget : policy.getTargets()){
-
- if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
- vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
- }
- }
- }
- }
- }
-
- vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
- vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
- vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
-
- return vfModuleToCvnfc;
- }
-
- protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
- ConfigurationResource configResource = null;
- for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
- if (configurationResourceCustom.getConfigurationResource() != null
- && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
- configResource = configurationResourceCustom.getConfigurationResource();
- }
- }
- if(configResource==null)
- configResource = configRepo.findResourceByModelUUID(modelUUID);
-
- return configResource;
- }
-
- protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
- String vfModuleModelCustomizationUUID) {
- VfModuleCustomization vfModuleCustomization = null;
- for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
- if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
- vfModuleCustomization = vfModuleCustom;
- }
- }
- if(vfModuleCustomization==null)
- vfModuleCustomization = vfModuleCustomizationRepo
- .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
-
- return vfModuleCustomization;
- }
-
- protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
- VfModule vfModule = null;
- for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
- if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
- vfModule = vfModuleCustom.getVfModule();
- }
- }
- if(vfModule==null)
- vfModule = vfModuleRepo.findByModelUUID(modelUUID);
-
- return vfModule;
- }
-
- protected VfModuleCustomization createVfModuleCustomization(Group group,
- ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
-
- vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
-
- vfModuleCustomization.setVfModule(vfModule);
-
- String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
- if (initialCount != null && initialCount.length() > 0) {
- vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
- }
-
- vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
- .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
-
- String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
- if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
- vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
- }
-
- vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
-
- String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
- if (maxInstances != null && maxInstances.length() > 0) {
- vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
- }
-
- String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
- if (minInstances != null && minInstances.length() > 0) {
- vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
- }
- return vfModuleCustomization;
- }
-
- protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
- IVfModuleData vfModuleData, Metadata vfMetadata) {
- VfModule vfModule = new VfModule();
- String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
-
- if(vfModuleModelUUID == null) {
- vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- } else if (vfModuleModelUUID.indexOf('.') > -1) {
- vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
- }
-
- vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
- vfModule.setModelUUID(vfModuleModelUUID);
- vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-
- String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
- vfModule.setIsBase(true);
- } else {
- vfModule.setIsBase(false);
- }
- return vfModule;
- }
-
- protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
- VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- Metadata vfMetadata) {
-
- Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
- .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
- .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
- .findFirst();
-
- if (matchingObject.isPresent()) {
- List<HeatFiles> heatFilesList = new ArrayList<>();
- List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
- List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
- HeatTemplate parentHeatTemplate = new HeatTemplate();
- String parentArtifactType = null;
- Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
-
- if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
- checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
- childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
- }
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
- parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
-
- if(!childNestedHeatTemplates.isEmpty()){
-
- if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
- volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
- } else {
- heatChildTemplates.add(childNestedHeatTemplates.get(0));
- }
- }
- }
-
- }
- if(!heatFilesList.isEmpty()){
- vfModule.setHeatFiles(heatFilesList);
- }
-
-
- // Set all Child Templates related to HEAT_VOLUME
- if(!volumeHeatChildTemplates.isEmpty()){
- if(vfModule.getVolumeHeatTemplate() != null){
- vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
- }else{
- logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
-
- // Set all Child Templates related to HEAT
- if(!heatChildTemplates.isEmpty()){
- if(vfModule.getModuleHeatTemplate() != null){
- vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
- }else{
- logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
- }
- }
-
- protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
- HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
- if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
- vfModuleArtifact.incrementDeployedInDB();
- vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
- vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
- VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
- vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
- vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
- } else {
- vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
- }
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
- heatFilesList.add(vfModuleArtifact.getHeatFiles());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
- nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
- vfModuleArtifact.incrementDeployedInDB();
- }
- }
-
- protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- if(vnfResourceCustomization == null){
- VnfResource vnfResource = findExistingVnfResource(service,
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if(vnfResource==null)
- vnfResource=createVnfResource(vfNodeTemplate);
-
- vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
- vnfResource);
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
-
- // Fetch VNFC Instance Group Info
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
- "org.openecomp.groups.VfcInstanceGroup");
-
- for (Group group : groupList) {
-
- VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization, toscaResourceStructure);
-
- vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
- }
- }
- return vnfResourceCustomization;
- }
-
- protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
- VnfResource vnfResource = null;
- for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
- if (vnfResourceCustom.getVnfResources() != null
- && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
- vnfResource = vnfResourceCustom.getVnfResources();
- }
- }
- if(vnfResource==null)
- vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
-
- return vnfResource;
- }
-
- protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setModelCustomizationUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
-
- vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
- vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
-
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
-
- CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(vfNodeTemplate);
-
- if (vnfCustomizationCapability != null) {
- CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
-
- }
-
- toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
-
- return vnfResourceCustomization;
- }
-
- protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelInvariantUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
- vnfResource.setModelVersion(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfResource.setDescription(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfResource.setOrchestrationMode(HEAT);
- vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
- vnfResource.setAicVersionMax(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- vnfResource.setAicVersionMin(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
-
- return vnfResource;
- }
-
- protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
- .findOneByModelCustomizationUUID(
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if(allottedResourceCustomization == null){
- AllottedResource allottedResource = findExistingAllottedResource(service,
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if(allottedResource==null)
- allottedResource=createAR(nodeTemplate);
-
- toscaResourceStructure.setAllottedResource(allottedResource);
- allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
- allottedResourceCustomization.setAllottedResource(allottedResource);
- allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
- AllottedResource allottedResource = null;
- for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
- if (allottedResourceCustom.getAllottedResource() != null
- && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
- allottedResource = allottedResourceCustom.getAllottedResource();
- }
- }
- if(allottedResource==null)
- allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
-
- return allottedResource;
- }
-
- protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
- allottedResourceCustomization.setModelCustomizationUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
-
-
- allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
- allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
-
- if(vfcNodes != null){
- for(NodeTemplate vfcNode : vfcNodes){
-
- allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
- allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
- allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
- }
- }
-
-
- CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(nodeTemplate);
-
- if (arCustomizationCapability != null) {
- CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- allottedResourceCustomization.setMinInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- allottedResourceCustomization.setMaxInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource createAR(NodeTemplate nodeTemplate) {
- AllottedResource allottedResource = new AllottedResource();
- allottedResource
- .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- allottedResource.setModelInvariantUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- allottedResource
- .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- allottedResource
- .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
- allottedResource.setSubcategory(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- allottedResource
- .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- return allottedResource;
- }
-
- protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
- // Scan the payload downloadResult and extract the HeatTemplate
- // parameters
- YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
- return yamlEditor.getParameterList(artifactUUID);
- }
-
- protected String testNull(Object object) {
-
- if (object == null) {
- return null;
- } else if (object.equals("NULL")) {
- return null;
- } else if (object instanceof Integer) {
- return object.toString();
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return "Type not recognized";
- }
- }
-
- protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
- VfModuleArtifact heatNestedArtifact) {
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
- .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
- .getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT;
- }
-
- }
- }
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
- && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
- .getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
- .get(0).getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT_VOL;
- }
-
- }
- }
-
- // Does not belong to anything
- return null;
-
- }
-
- protected static String createVNFName(VfResourceStructure vfResourceStructure) {
-
- return vfResourceStructure.getNotification().getServiceName() + "/"
- + vfResourceStructure.getResourceInstance().getResourceInstanceName();
- }
-
- protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
-
- return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
- + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
- }
-
- protected String getPropertyInput(String propertyName){
-
- String inputName = new String();
-
- if (propertyName != null) {
- int getInputIndex = propertyName.indexOf("{get_input=");
- if (getInputIndex > -1) {
- inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1);
- }
- }
-
- return inputName;
- }
-
-
- protected static Timestamp getCurrentTimeStamp() {
-
- return new Timestamp(new Date().getTime());
- }
+ vnfcCustomization = existingVnfcCustomization;
+ }
+
+ // Only Add Abstract VNFC's to our DB, ignore all others
+ if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
+ vnfcCustomization.setModelCustomizationUUID(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+ vnfcCustomization.setModelInvariantUUID(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization
+ .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization
+ .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ vnfcCustomization.setModelVersion(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfcCustomization.setDescription(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+
+ vnfcCustomizations.add(vnfcCustomization);
+ existingVnfcSet.add(vnfcCustomization);
+ }
+
+ // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB.
+ if (vnfcCustomization.getModelCustomizationUUID() != null) {
+
+ CvnfcCustomization cvnfcCustomization = null;
+
+ if (existingCvnfcCustomization != null) {
+ cvnfcCustomization = existingCvnfcCustomization;
+ } else {
+
+ cvnfcCustomization = new CvnfcCustomization();
+ cvnfcCustomization.setModelCustomizationUUID(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+ cvnfcCustomization.setModelInvariantUUID(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ cvnfcCustomization
+ .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ cvnfcCustomization
+ .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ cvnfcCustomization.setModelVersion(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ cvnfcCustomization.setDescription(
+ testNull(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+ if (existingVnfcCustomization != null) {
+ cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+ } else {
+ cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+ }
+
+ cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+ cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+ cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+ cvnfcCustomization.setVnfResourceCustomization(vnfResource);
+
+ cvnfcCustomizations.add(cvnfcCustomization);
+ existingCvnfcSet.add(cvnfcCustomization);
+ }
+
+ //*****************************************************************************************************************************************
+ //* Extract Fabric Configuration
+ //*****************************************************************************************************************************************
+
+ List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
+
+ for (NodeTemplate fabricTemplate : fabricConfigList) {
+
+ ConfigurationResource fabricConfig = null;
+
+ ConfigurationResource existingConfig = findExistingConfiguration(service,
+ fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (existingConfig == null) {
+
+ fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
+
+ } else {
+ fabricConfig = existingConfig;
+ }
+
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(
+ fabricTemplate, toscaResourceStructure,
+ vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate,
+ vfModuleMemberName);
+
+ vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
+ vfModuleCustomization
+ .setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
+
+ return vfModuleCustomization;
+ }
+
+ protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate,
+ ToscaResourceStructure toscaResourceStruct,
+ VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization,
+ CvnfcCustomization cvnfcCustomization,
+ ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
+
+ Metadata fabricMetadata = fabricTemplate.getMetaData();
+
+ VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
+
+ vfModuleToCvnfc.setConfigurationResource(configResource);
+ vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
+ vfModuleToCvnfc
+ .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
+ vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
+ vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
+
+ List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper()
+ .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
+
+ if (policyList != null) {
+ for (Policy policy : policyList) {
+
+ for (String policyCvfcTarget : policy.getTargets()) {
+
+ if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) {
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) {
+ vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
+ }
+ }
+ }
+ }
+ }
+
+ vfModuleToCvnfc.setConfigurationFunction(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
+ vfModuleToCvnfc.setConfigurationRole(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
+ vfModuleToCvnfc.setConfigurationType(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
+
+ return vfModuleToCvnfc;
+ }
+
+ protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
+ ConfigurationResource configResource = null;
+ for (ConfigurationResourceCustomization configurationResourceCustom : service
+ .getConfigurationCustomizations()) {
+ if (configurationResourceCustom.getConfigurationResource() != null
+ && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
+ configResource = configurationResourceCustom.getConfigurationResource();
+ }
+ }
+ if (configResource == null) {
+ configResource = configRepo.findResourceByModelUUID(modelUUID);
+ }
+
+ return configResource;
+ }
+
+ protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
+ String vfModuleModelCustomizationUUID) {
+ VfModuleCustomization vfModuleCustomization = null;
+ for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
+ if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) {
+ vfModuleCustomization = vfModuleCustom;
+ }
+ }
+ if (vfModuleCustomization == null) {
+ vfModuleCustomization = vfModuleCustomizationRepo
+ .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
+ }
+
+ return vfModuleCustomization;
+ }
+
+ protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
+ VfModule vfModule = null;
+ for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
+ if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) {
+ vfModule = vfModuleCustom.getVfModule();
+ }
+ }
+ if (vfModule == null) {
+ vfModule = vfModuleRepo.findByModelUUID(modelUUID);
+ }
+
+ return vfModule;
+ }
+
+ protected VfModuleCustomization createVfModuleCustomization(Group group,
+ ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+
+ vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
+
+ vfModuleCustomization.setVfModule(vfModule);
+
+ String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+ if (initialCount != null && initialCount.length() > 0) {
+ vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
+ }
+
+ vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
+ .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
+
+ String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
+ if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
+ vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
+ }
+
+ vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
+
+ String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
+ if (maxInstances != null && maxInstances.length() > 0) {
+ vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
+ }
+
+ String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
+ if (minInstances != null && minInstances.length() > 0) {
+ vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
+ }
+ return vfModuleCustomization;
+ }
+
+ protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
+ IVfModuleData vfModuleData, Metadata vfMetadata) {
+ VfModule vfModule = new VfModule();
+ String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
+
+ if (vfModuleModelUUID == null) {
+ vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ } else if (vfModuleModelUUID.indexOf('.') > -1) {
+ vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
+ }
+
+ vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
+ vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ vfModule.setModelUUID(vfModuleModelUUID);
+ vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
+ vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+
+ String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
+ if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
+ vfModule.setIsBase(true);
+ } else {
+ vfModule.setIsBase(false);
+ }
+ return vfModule;
+ }
+
+ protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
+ VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ Metadata vfMetadata) {
+
+ Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
+ .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
+ .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
+ .findFirst();
+
+ if (matchingObject.isPresent()) {
+ List<HeatFiles> heatFilesList = new ArrayList<>();
+ List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
+ List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
+ HeatTemplate parentHeatTemplate = new HeatTemplate();
+ String parentArtifactType = null;
+ Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
+
+ if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
+ checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
+ childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
+ }
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
+ parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
+
+ if (!childNestedHeatTemplates.isEmpty()) {
+
+ if (parentArtifactType != null && parentArtifactType
+ .equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
+ volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
+ } else {
+ heatChildTemplates.add(childNestedHeatTemplates.get(0));
+ }
+ }
+ }
+
+ }
+ if (!heatFilesList.isEmpty()) {
+ vfModule.setHeatFiles(heatFilesList);
+ }
+
+ // Set all Child Templates related to HEAT_VOLUME
+ if (!volumeHeatChildTemplates.isEmpty()) {
+ if (vfModule.getVolumeHeatTemplate() != null) {
+ vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
+ } else {
+ logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+
+ // Set all Child Templates related to HEAT
+ if (!heatChildTemplates.isEmpty()) {
+ if (vfModule.getModuleHeatTemplate() != null) {
+ vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
+ } else {
+ logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+ }
+ }
+
+ protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
+ HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
+ if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
+ vfModuleArtifact.incrementDeployedInDB();
+ vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
+ vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ VfModuleArtifact volVfModuleArtifact = this
+ .getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
+ vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
+ vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
+ } else {
+ vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
+ }
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
+ heatFilesList.add(vfModuleArtifact.getHeatFiles());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
+ nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
+ vfModuleArtifact.incrementDeployedInDB();
+ }
+ }
+
+ protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ if (vnfResourceCustomization == null) {
+ VnfResource vnfResource = findExistingVnfResource(service,
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (vnfResource == null) {
+ vnfResource = createVnfResource(vfNodeTemplate);
+ }
+
+ vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
+ vnfResource);
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
+
+ // Fetch VNFC Instance Group Info
+ List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
+ .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
+ "org.openecomp.groups.VfcInstanceGroup");
+
+ for (Group group : groupList) {
+
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate,
+ group, vnfResourceCustomization, toscaResourceStructure);
+
+ vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
+ }
+ }
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
+ VnfResource vnfResource = null;
+ for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
+ if (vnfResourceCustom.getVnfResources() != null
+ && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
+ vnfResource = vnfResourceCustom.getVnfResources();
+ }
+ }
+ if (vnfResource == null) {
+ vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
+ }
+
+ return vnfResource;
+ }
+
+ protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setModelCustomizationUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
+
+ vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
+ vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+
+ vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+
+ vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
+
+ CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilitiesOf(vfNodeTemplate);
+
+ if (vnfCustomizationCapability != null) {
+ CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+
+ }
+
+ toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
+
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelInvariantUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+
+ vnfResource.setModelVersion(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfResource.setDescription(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfResource.setOrchestrationMode(HEAT);
+ vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
+ vnfResource.setAicVersionMax(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ vnfResource.setAicVersionMin(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
+
+ return vnfResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
+ .findOneByModelCustomizationUUID(
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (allottedResourceCustomization == null) {
+ AllottedResource allottedResource = findExistingAllottedResource(service,
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (allottedResource == null) {
+ allottedResource = createAR(nodeTemplate);
+ }
+
+ toscaResourceStructure.setAllottedResource(allottedResource);
+ allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
+ allottedResourceCustomization.setAllottedResource(allottedResource);
+ allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
+ AllottedResource allottedResource = null;
+ for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) {
+ if (allottedResourceCustom.getAllottedResource() != null
+ && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
+ allottedResource = allottedResourceCustom.getAllottedResource();
+ }
+ }
+ if (allottedResource == null) {
+ allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
+ }
+
+ return allottedResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
+ allottedResourceCustomization.setModelCustomizationUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
+
+ allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
+ allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
+ .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
+
+ if (vfcNodes != null) {
+ for (NodeTemplate vfcNode : vfcNodes) {
+
+ allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelInvariantUUID(
+ toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
+ }
+ }
+
+ CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilitiesOf(nodeTemplate);
+
+ if (arCustomizationCapability != null) {
+ CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ allottedResourceCustomization.setMinInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ allottedResourceCustomization.setMaxInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource createAR(NodeTemplate nodeTemplate) {
+ AllottedResource allottedResource = new AllottedResource();
+ allottedResource
+ .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ allottedResource.setModelInvariantUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ allottedResource
+ .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ allottedResource
+ .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
+ allottedResource.setSubcategory(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ allottedResource
+ .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ return allottedResource;
+ }
+
+ protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
+ // Scan the payload downloadResult and extract the HeatTemplate
+ // parameters
+ YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
+ return yamlEditor.getParameterList(artifactUUID);
+ }
+
+ protected String testNull(Object object) {
+
+ if (object == null) {
+ return null;
+ } else if (object.equals("NULL")) {
+ return null;
+ } else if (object instanceof Integer) {
+ return object.toString();
+ } else if (object instanceof String) {
+ return (String) object;
+ } else {
+ return "Type not recognized";
+ }
+ }
+
+ protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
+ VfModuleArtifact heatNestedArtifact) {
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
+ .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
+ .getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT;
+ }
+
+ }
+ }
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
+ && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
+ .getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
+ .get(0).getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT_VOL;
+ }
+
+ }
+ }
+
+ // Does not belong to anything
+ return null;
+
+ }
+
+ protected static String createVNFName(VfResourceStructure vfResourceStructure) {
+
+ return vfResourceStructure.getNotification().getServiceName() + "/"
+ + vfResourceStructure.getResourceInstance().getResourceInstanceName();
+ }
+
+ protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
+
+ return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
+ + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
+ }
+
+ protected String getPropertyInput(String propertyName) {
+
+ String inputName = new String();
+
+ if (propertyName != null) {
+ int getInputIndex = propertyName.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
+ }
+ }
+
+ return inputName;
+ }
+
+
+ protected static Timestamp getCurrentTimeStamp() {
+
+ return new Timestamp(new Date().getTime());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
new file mode 100644
index 0000000000..c0c66123eb
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -0,0 +1,442 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.asdc.client;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import javax.persistence.EntityNotFoundException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.onap.so.asdc.BaseTest;
+import org.onap.so.asdc.client.exceptions.ASDCControllerException;
+import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl;
+import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator;
+import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
+import org.onap.so.asdc.client.test.emulators.ResourceInfoImpl;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ToscaCsar;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
+import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * This is used to run some basic integration test(BIT) for ASDC controller. It will test the csar install and all the
+ * testing csar files are located underneath src/main/resources/download folder,
+ *
+ * PNF csar: service-Testservice140-csar.csar VNF csar: service-Svc140-VF-csar.csar
+ */
+@Transactional
+public class ASDCControllerITTest extends BaseTest {
+
+ private Logger logger = LoggerFactory.getLogger(ASDCControllerITTest.class);
+
+ @Rule
+ public TestName testName = new TestName();
+
+ private String serviceUuid;
+ private String serviceInvariantUuid;
+
+ /**
+ * Random UUID served as distribution UUID.
+ */
+ private String distributionId;
+ private String artifactUuid;
+
+ @Autowired
+ private ASDCController asdcController;
+
+ @Autowired
+ private PnfResourceRepository pnfResourceRepository;
+
+ @Autowired
+ private PnfCustomizationRepository pnfCustomizationRepository;
+
+ @Autowired
+ private VnfResourceRepository vnfResourceRepository;
+
+ @Autowired
+ private VnfCustomizationRepository vnfCustomizationRepository;
+
+ @Autowired
+ private ToscaCsarRepository toscaCsarRepository;
+
+ @Autowired
+ private ServiceRepository serviceRepository;
+
+ private DistributionClientEmulator distributionClient;
+
+ @Before
+ public void setUp() {
+ distributionId = UUID.randomUUID().toString();
+ artifactUuid = UUID.randomUUID().toString();
+ logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid,
+ testName.getMethodName());
+
+ distributionClient = new DistributionClientEmulator();
+ distributionClient.setResourcePath("src/test/resources");
+ asdcController.setDistributionClient(distributionClient);
+ try {
+ asdcController.initASDC();
+ } catch (ASDCControllerException e) {
+ logger.error(e.getMessage(), e);
+ fail(e.getMessage());
+ }
+ }
+
+ @After
+ public void shutDown() {
+ try {
+ asdcController.closeASDC();
+ } catch (ASDCControllerException e) {
+ logger.error(e.getMessage(), e);
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Mock the AAI using wireshark.
+ */
+ private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) {
+ String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid
+ + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
+
+ stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
+ }
+
+ /**
+ * Test with service-Testservice140-csar.csar.
+ */
+ @Test
+ public void treatNotification_ValidPnfResource_ExpectedOutput() {
+
+ /**
+ * service UUID/invariantUUID from global metadata in service-Testservice140-template.yml.
+ */
+ String serviceUuid = "efaea486-561f-4159-9191-a8d3cb346728";
+ String serviceInvariantUuid = "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23";
+
+ initMockAaiServer(serviceUuid, serviceInvariantUuid);
+
+ NotificationDataImpl notificationData = new NotificationDataImpl();
+ notificationData.setServiceUUID(serviceUuid);
+ notificationData.setDistributionID(distributionId);
+ notificationData.setServiceInvariantUUID(serviceInvariantUuid);
+ notificationData.setServiceVersion("1.0");
+
+ ResourceInfoImpl resourceInfo = constructPnfResourceInfo();
+ List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
+ resourceInfoList.add(resourceInfo);
+ notificationData.setResources(resourceInfoList);
+
+ ArtifactInfoImpl artifactInfo = constructPnfServiceArtifact();
+ List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
+ artifactInfoList.add(artifactInfo);
+ notificationData.setServiceArtifacts(artifactInfoList);
+
+ try {
+ asdcController.treatNotification(notificationData);
+ logger.info("Checking the database for PNF ingestion");
+
+ /**
+ * Check the tosca csar entity, it should be the same as provided from NotficationData.
+ */
+ ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
+ assertEquals("tosca csar name", "service-Testservice140-csar.csar", toscaCsar.getName());
+ assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
+ assertNull("tosca csar descrption", toscaCsar.getDescription());
+ assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
+ assertEquals("toscar csar URL", "/download/service-Testservice140-csar.csar", toscaCsar.getUrl());
+
+ /**
+ * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ */
+ Service service = serviceRepository.findById(serviceUuid)
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ assertEquals("model UUID", "efaea486-561f-4159-9191-a8d3cb346728", service.getModelUUID());
+ assertEquals("model name", "TestService140", service.getModelName());
+ assertEquals("model invariantUUID", "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23",
+ service.getModelInvariantUUID());
+ assertEquals("model version", "1.0", service.getModelVersion());
+ assertEquals("description", "Test Service for extended attributes of PNF resource",
+ service.getDescription().trim());
+ assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
+ assertEquals("service type", "Network", service.getServiceType());
+ assertEquals("service role", "nfv", service.getServiceRole());
+ assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
+ assertEquals("service category", "Network Service", service.getCategory());
+ assertNull("workload context", service.getWorkloadContext());
+ assertEquals("resource order", "Test140PNF", service.getResourceOrder());
+
+ /**
+ * Check PNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
+ * OR
+ * global metadata in the resource-Test140pnf-template.yml
+ */
+ String pnfResourceKey = "9c54e269-122b-4e8a-8b2a-6eac849b441a";
+ PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey)
+ .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
+ assertNull("orchestration mode", pnfResource.getOrchestrationMode());
+ assertEquals("Description", "Oracle", pnfResource.getDescription().trim());
+ assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
+ assertEquals("model invariant UUID", "d832a027-75f3-455d-9de4-f02fcdee7e7e",
+ pnfResource.getModelInvariantUUID());
+ assertEquals("model version", "1.0", pnfResource.getModelVersion());
+ assertEquals("model name", "Test140PNF", pnfResource.getModelName());
+ assertEquals("tosca node type", "org.openecomp.resource.pnf.Test140pnf", pnfResource.getToscaNodeType());
+ assertEquals("resource category", "Application L4+", pnfResource.getCategory());
+ assertEquals("resource sub category", "Call Control", pnfResource.getSubCategory());
+
+ /**
+ * Check PNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
+ * OR
+ * global metadata in the resource-Test140pnf-template.yml
+ */
+ String pnfCustomizationKey = "428a3d73-f962-4cc2-ba62-2483c45d6b12";
+ PnfResourceCustomization pnfCustomization = pnfCustomizationRepository
+ .findById(pnfCustomizationKey).orElseThrow(
+ () -> new EntityNotFoundException(
+ "PNF resource customization: " + pnfCustomizationKey + " not found"));
+ assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
+ assertEquals("model instance name", "Test140PNF 0", pnfCustomization.getModelInstanceName());
+ assertEquals("NF type", "", pnfCustomization.getNfType());
+ assertEquals("NF Role", "nf", pnfCustomization.getNfRole());
+ assertEquals("NF function", "nf", pnfCustomization.getNfFunction());
+ assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
+ assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
+ assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
+ assertNull("resource input", pnfCustomization.getResourceInput());
+ assertEquals("cds blueprint name(sdnc_model_name property)", pnfCustomization.getBlueprintName(),
+ pnfCustomization.getBlueprintName());
+ assertEquals("cds blueprint version(sdnc_model_version property)", pnfCustomization.getBlueprintVersion(),
+ pnfCustomization.getBlueprintVersion());
+
+ /**
+ * Check the pnf resource customization with service mapping
+ */
+ List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
+ assertEquals("PNF resource customization entity", 1, pnfCustList.size());
+ assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
+
+ } catch (Exception e) {
+ logger.info(e.getMessage(), e);
+ fail(e.getMessage());
+ }
+ }
+
+ private ArtifactInfoImpl constructPnfServiceArtifact() {
+ ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+ artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+ artifactInfo.setArtifactURL("/download/service-Testservice140-csar.csar");
+ artifactInfo.setArtifactName("service-Testservice140-csar.csar");
+ artifactInfo.setArtifactVersion("1.0");
+ artifactInfo.setArtifactUUID(artifactUuid);
+ return artifactInfo;
+ }
+
+ /**
+ * Construct the PnfResourceInfo based on the resource-Test140Pnf-template.yml from
+ * service-Testservice140-csar.csar.
+ */
+ private ResourceInfoImpl constructPnfResourceInfo() {
+ ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+ resourceInfo.setResourceInstanceName("Test140PNF");
+ resourceInfo.setResourceInvariantUUID("d832a027-75f3-455d-9de4-f02fcdee7e7e");
+ resourceInfo.setResoucreType("PNF");
+ resourceInfo.setCategory("Application L4+");
+ resourceInfo.setSubcategory("Call Control");
+ resourceInfo.setResourceUUID("9c54e269-122b-4e8a-8b2a-6eac849b441a");
+ resourceInfo.setResourceCustomizationUUID("428a3d73-f962-4cc2-ba62-2483c45d6b12");
+ resourceInfo.setResourceVersion("1.0");
+ return resourceInfo;
+ }
+
+ /**
+ * Testing with the service-Svc140-VF-csar.csar.
+ */
+ @Test
+ public void treatNotification_ValidVnfResource_ExpectedOutput() {
+
+ /**
+ * service UUID/invariantUUID from global metadata in resource-Testvf140-template.yml.
+ */
+ String serviceUuid = "28944a37-de3f-46ec-9c60-b57036fbd26d";
+ String serviceInvariantUuid = "9e900d3e-1e2e-4124-a5c2-4345734dc9de";
+
+ initMockAaiServer(serviceUuid, serviceInvariantUuid);
+
+ NotificationDataImpl notificationData = new NotificationDataImpl();
+ notificationData.setServiceUUID(serviceUuid);
+ notificationData.setDistributionID(distributionId);
+ notificationData.setServiceInvariantUUID(serviceInvariantUuid);
+ notificationData.setServiceVersion("1.0");
+
+ ResourceInfoImpl resourceInfo = constructVnfResourceInfo();
+ List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
+ resourceInfoList.add(resourceInfo);
+ notificationData.setResources(resourceInfoList);
+
+ ArtifactInfoImpl artifactInfo = constructVnfServiceArtifact();
+ List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
+ artifactInfoList.add(artifactInfo);
+ notificationData.setServiceArtifacts(artifactInfoList);
+
+ try {
+ asdcController.treatNotification(notificationData);
+ logger.info("Checking the database for VNF ingestion");
+
+ /**
+ * Check the tosca csar entity, it should be the same as provided from NotficationData.
+ */
+ ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
+ assertEquals("tosca csar name", "service-Svc140-VF-csar.csar", toscaCsar.getName());
+ assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
+ assertNull("tosca csar descrption", toscaCsar.getDescription());
+ assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
+ assertEquals("toscar csar URL", "/download/service-Svc140-VF-csar.csar", toscaCsar.getUrl());
+
+ /**
+ * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ */
+ Service service = serviceRepository.findById(serviceUuid)
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ assertEquals("model UUID", serviceUuid, service.getModelUUID());
+ assertEquals("model name", "SVC140", service.getModelName());
+ assertEquals("model invariantUUID", serviceInvariantUuid,
+ service.getModelInvariantUUID());
+ assertEquals("model version", "1.0", service.getModelVersion());
+ assertEquals("description", "SVC140",
+ service.getDescription().trim());
+ assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
+ assertEquals("service type", "ST", service.getServiceType());
+ assertEquals("service role", "Sr", service.getServiceRole());
+ assertEquals("environment context", "General_Revenue-Bearing", service.getEnvironmentContext());
+ assertEquals("service category", "Network Service", service.getCategory());
+ assertNull("workload context", service.getWorkloadContext());
+ assertEquals("resource order", "TestVF140", service.getResourceOrder());
+
+ /**
+ * Check VNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
+ * OR
+ * global metadata in the resource-Testservice140-template.yml
+ */
+ String vnfResourceKey = "d20d3ea9-2f54-4071-8b5c-fd746dde245e";
+ VnfResource vnfResource = vnfResourceRepository.findById(vnfResourceKey)
+ .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
+ assertEquals("orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
+ assertEquals("Description", "TestPNF140", vnfResource.getDescription().trim());
+ assertEquals("model UUID", vnfResourceKey, vnfResource.getModelUUID());
+ assertEquals("model invariant UUID", "7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb",
+ vnfResource.getModelInvariantUUID());
+ assertEquals("model version", "1.0", vnfResource.getModelVersion());
+ assertEquals("model name", "TestVF140", vnfResource.getModelName());
+ assertEquals("tosca node type", "org.openecomp.resource.vf.Testvf140", vnfResource.getToscaNodeType());
+ assertEquals("resource category", "Application L4+", vnfResource.getCategory());
+ assertEquals("resource sub category", "Database", vnfResource.getSubCategory());
+
+ /**
+ * Check VNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
+ * OR
+ * global metadata in the resource-Testservice140-template.yml
+ */
+ String vnfCustomizationKey = "ca1c8455-8ce2-4a76-a037-3f4cf01cffa0";
+ VnfResourceCustomization vnfCustomization = vnfCustomizationRepository
+ .findById(vnfCustomizationKey).orElseThrow(
+ () -> new EntityNotFoundException(
+ "VNF resource customization: " + vnfCustomizationKey + " not found"));
+ assertEquals("model customizationUUID", vnfCustomizationKey, vnfCustomization.getModelCustomizationUUID());
+ assertEquals("model instance name", "TestVF140 0", vnfCustomization.getModelInstanceName());
+ assertNull("NF type", vnfCustomization.getNfType());
+ assertNull("NF Role", vnfCustomization.getNfRole());
+ assertNull("NF function", vnfCustomization.getNfFunction());
+ assertNull("NF naming code", vnfCustomization.getNfNamingCode());
+ assertEquals("VNF resource model UUID", vnfResourceKey, vnfCustomization.getVnfResources().getModelUUID());
+ assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign());
+ assertNull("resource input", vnfCustomization.getResourceInput());
+ assertEquals("cds blueprint name(sdnc_model_name property)", vnfCustomization.getBlueprintName(),
+ vnfCustomization.getBlueprintName());
+ assertEquals("cds blueprint version(sdnc_model_version property)", vnfCustomization.getBlueprintVersion(),
+ vnfCustomization.getBlueprintVersion());
+ /**
+ * Check the vnf resource customization with service mapping
+ */
+ List<VnfResourceCustomization> vnfCustList = service.getVnfCustomizations();
+ assertEquals("VNF resource customization entity", 1, vnfCustList.size());
+ assertEquals(vnfCustomizationKey, vnfCustList.get(0).getModelCustomizationUUID());
+ } catch (Exception e) {
+ logger.info(e.getMessage(), e);
+ fail(e.getMessage());
+ }
+ }
+
+ private ArtifactInfoImpl constructVnfServiceArtifact() {
+ ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
+ artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);
+ artifactInfo.setArtifactURL("/download/service-Svc140-VF-csar.csar");
+ artifactInfo.setArtifactName("service-Svc140-VF-csar.csar");
+ artifactInfo.setArtifactVersion("1.0");
+ artifactInfo.setArtifactUUID(artifactUuid);
+ return artifactInfo;
+ }
+
+ /**
+ * Construct the PnfResourceInfo based on the resource-Testvf140-template.yml from service-Svc140-VF-csar.csar.
+ */
+ private ResourceInfoImpl constructVnfResourceInfo() {
+ ResourceInfoImpl resourceInfo = new ResourceInfoImpl();
+ resourceInfo.setResourceInstanceName("TestVF140");
+ resourceInfo.setResourceInvariantUUID("7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb");
+ resourceInfo.setResoucreType("VF");
+ resourceInfo.setCategory("Application L4+");
+ resourceInfo.setSubcategory("Database");
+ resourceInfo.setResourceUUID("d20d3ea9-2f54-4071-8b5c-fd746dde245e");
+ resourceInfo.setResourceCustomizationUUID("ca1c8455-8ce2-4a76-a037-3f4cf01cffa0");
+ resourceInfo.setResourceVersion("1.0");
+ resourceInfo.setArtifacts(Collections.EMPTY_LIST);
+ return resourceInfo;
+ }
+}
diff --git a/asdc-controller/src/test/resources/ASDC/.gitignore b/asdc-controller/src/test/resources/ASDC/.gitignore
index e54786bc77..836e68d117 100644
--- a/asdc-controller/src/test/resources/ASDC/.gitignore
+++ b/asdc-controller/src/test/resources/ASDC/.gitignore
@@ -1 +1 @@
-/*.csar
+*.*/*.csar
diff --git a/asdc-controller/src/test/resources/application-test.yaml b/asdc-controller/src/test/resources/application-test.yaml
index caaa5dd3b4..5ba8521b3c 100644
--- a/asdc-controller/src/test/resources/application-test.yaml
+++ b/asdc-controller/src/test/resources/application-test.yaml
@@ -14,7 +14,7 @@ spring:
initialization-mode: always
jpa:
generate-ddl: false
- show-sql: false
+ show-sql: true
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
@@ -97,3 +97,5 @@ mso:
enabled: false
aai:
endpoint: http://localhost:${wiremock.server.port}
+ config:
+ defaultpath: src/test/resources
diff --git a/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar b/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar
new file mode 100644
index 0000000000..0de1b0b0a0
--- /dev/null
+++ b/asdc-controller/src/test/resources/download/service-Svc140-VF-csar.csar
Binary files differ
diff --git a/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar b/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar
new file mode 100644
index 0000000000..bd9a1dc775
--- /dev/null
+++ b/asdc-controller/src/test/resources/download/service-Testservice140-csar.csar
Binary files differ
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index aef33c3aed..1035817c3c 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -399,6 +399,8 @@ create table `vnf_resource_customization` (
`vnf_resource_model_uuid` varchar(200) not null,
`multi_stage_design` varchar(20) default null,
`resource_input` varchar(20000) default null,
+ `cds_blueprint_name` varchar(200) default null,
+ `cds_blueprint_version` varchar(20) default null,
primary key (`model_customization_uuid`),
key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`),
constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade
@@ -801,27 +803,41 @@ UPDATE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = l
CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization (
- `ID` INT(11) NOT NULL AUTO_INCREMENT,
- `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
- `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL,
- `CONFIGURATION_TYPE` VARCHAR(200) NULL,
- `CONFIGURATION_ROLE` VARCHAR(200) NULL,
- `CONFIGURATION_FUNCTION` VARCHAR(200) NULL,
- `POLICY_NAME` VARCHAR(200) NULL,
- `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL,
- `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) DEFAULT NULL,
- `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) DEFAULT NULL,
- `CVNFC_CUSTOMIZATION_ID` INT(11) DEFAULT NULL,
- PRIMARY KEY (`ID`),
- INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC),
-
- CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`)
- REFERENCES `configuration` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE = INNODB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = LATIN1;
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `CVNFC_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL,
+ `CONFIGURATION_TYPE` VARCHAR(200) NULL,
+ `CONFIGURATION_ROLE` VARCHAR(200) NULL,
+ `CONFIGURATION_FUNCTION` VARCHAR(200) NULL,
+ `POLICY_NAME` VARCHAR(200) NULL,
+ `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL,
+ PRIMARY KEY (`ID`),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC),
+ UNIQUE INDEX `UK_vnf_vfmodule_cvnfc_configuration_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC , `VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC , `CVNFC_MODEL_CUSTOMIZATION_UUID` ASC , `MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__cvnfc_cust1_idx` (`CVNFC_MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vf_module_cust_idx` (`VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vnf_res_cust_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC),
+ CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`)
+ REFERENCES `configuration` (`MODEL_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_cvnfc_configuration_customization__cvnfc_customization1` FOREIGN KEY (`CVNFC_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `cvnfc_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_vnf_configuration_cvnfc_customization__vf_module_customiza1` FOREIGN KEY (`VF_MODULE_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_vfmodule_cvnfc_configuration_customization__vnf_resource_c1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=INNODB AUTO_INCREMENT=20654 DEFAULT CHARACTER SET=LATIN1;
+
CREATE TABLE IF NOT EXISTS `pnf_resource` (
- `ORCHESTRATION_MODE` varchar(20) NOT NULL DEFAULT 'HEAT',
+ `ORCHESTRATION_MODE` varchar(20) DEFAULT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`MODEL_UUID` varchar(200) NOT NULL,
@@ -857,6 +873,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization_to_service` (
`RESOURCE_MODEL_CUSTOMIZATION_UUID` varchar(200) NOT NULL,
PRIMARY KEY (`SERVICE_MODEL_UUID`,`RESOURCE_MODEL_CUSTOMIZATION_UUID`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
--------START Request DB SCHEMA --------
CREATE DATABASE requestdb;
USE requestdb;
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
index 484be19137..4670b11b71 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
@@ -148,7 +148,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
} catch (BpmnError e) {
throw e
} catch (Exception e) {
- logger.error('Caught exception in ' + method, e)
+ logger.error('Caught exception in {}: {}', method, e.getMessage(), e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
}
}
@@ -416,7 +416,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
*@param name
*@return
**/
- public String getVariable(DelegateExecution execution, String name) {
+ public static String getVariable(DelegateExecution execution, String name) {
def myObj = execution.getVariable(name)
if(myObj instanceof VariableMap){
VariableMap serializedObjectMap = (VariableMap) myObj
@@ -522,8 +522,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
throw bpmnError
}
catch(Exception e) {
- e.printStackTrace()
- logger.debug('Unexpected error encountered - ' + e.getMessage())
+ logger.debug('Unexpected error encountered - {}', e.getMessage(), e)
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
finally {
@@ -645,7 +644,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
rollbackEnabled = defaultRollback
}
}
-
+
execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)
logger.debug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
index c1f9f5b0b3..e9e7d1ed7c 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
@@ -63,8 +63,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CAAIVfMod_moduleExists",false)
execution.setVariable("CAAIVfMod_baseModuleConflict", false)
execution.setVariable("CAAIVfMod_vnfNameFromAAI", null)
-
-
+
+
// CreateAAIVfModule workflow response variable placeholders
execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode",null)
execution.setVariable("CAAIVfMod_queryGenericVnfResponse","")
@@ -80,14 +80,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CreateAAIVfModuleResponse","")
execution.setVariable("RollbackData", null)
- }
-
+ }
+
// parse the incoming CREATE_VF_MODULE request and store the Generic VNF
// and VF Module data in the flow DelegateExecution
public void preProcessRequest(DelegateExecution execution) {
initProcessVariables(execution)
- def vnfId = execution.getVariable("vnfId")
+ def vnfId = execution.getVariable("vnfId")
if (vnfId == null || vnfId.isEmpty()) {
execution.setVariable("CAAIVfMod_newGenericVnf", true)
execution.setVariable("CAAIVfMod_vnfId","")
@@ -96,14 +96,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CAAIVfMod_vnfId",vnfId)
}
- def vnfName = execution.getVariable("vnfName")
+ def vnfName = execution.getVariable("vnfName")
execution.setVariable("CAAIVfMod_vnfName", vnfName)
String vnfType = execution.getVariable("vnfType")
execution.setVariable("CAAIVfMod_vnfType", StringUtils.defaultString(vnfType))
execution.setVariable("CAAIVfMod_serviceId", execution.getVariable("serviceId"))
-
+
String personaModelId = execution.getVariable("personaModelId")
execution.setVariable("CAAIVfMod_personaId",StringUtils.defaultString(personaModelId))
@@ -219,8 +219,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 201)
execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created")
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI PUT: {}", ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createGenericVnf.")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
index dc4871119e..7e46784af2 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
@@ -121,8 +121,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
execution.setVariable('CAAIVfModVG_getVfModuleResponse', "VF-Module Not found!!")
}
}catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 500)
execution.setVariable('CAAIVfModVG_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage())
}
@@ -174,8 +173,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
logger.debug("CreateAAIVfModule Response code: " + 200)
logger.debug("CreateAAIVfModule Response: " + "Success")
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI PUT: {}', ex.getMessage(), ex)
execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 500)
execution.setVariable('CAAIVfModVG_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage())
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
index 83f31450b8..4bce23eff7 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
@@ -76,7 +76,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
// send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id
// expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist
public void queryAAIForGenericVnf(DelegateExecution execution) {
-
+
def vnfId = execution.getVariable("DAAIVfMod_vnfId")
try {
@@ -112,8 +112,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 200)
execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "Vnf Deleted")
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI DELETE: {}", ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteGenericVnf")
}
}
@@ -131,8 +130,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 200)
execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "Vf Module Deleted")
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI PUT: {}", ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteVfModule")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
index 740d9f70b6..f008130c32 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
@@ -151,8 +151,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
}
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
index 92c1579aa0..f371ccef4d 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
@@ -126,7 +126,7 @@ class MsoUtils {
/***** Utilities when using XmlParser *****/
-
+
/**
* Convert a Node into a String by deserializing it and formatting it.
*
@@ -883,7 +883,7 @@ class MsoUtils {
callbackUrlToUse = callbackUrlToUse.replaceAll("(http://)(.*)(:28080*)", {orig, first, torepl, last -> "${first}${qualifiedHostName}${last}"})
}
}catch(Exception e){
- log("DEBUG", "unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: " + e.printStackTrace())
+ logger.debug("Unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: {}", e.getMessage(), e)
}
return callbackUrlToUse
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
index d909a77cc2..a7bb707dff 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
@@ -166,7 +166,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
logger.debug(UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint", execution))
}catch(Exception e){
- logger.debug('Internal Error occured during PreProcess Method: ', e)
+ logger.debug('Internal Error occured during PreProcess Method: {}', e.getMessage(), e)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code?
}
logger.trace("End pre Process SDNCRequestScript ")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
index 9d7ce8234b..69d5f02df5 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
@@ -165,7 +165,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
- "BPMN", ErrorCode.UnknownError.getValue());
+ "BPMN", ErrorCode.UnknownError.getValue(), ex);
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
index c1d68c5f7c..f91bf54edc 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
@@ -161,7 +161,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
- "BPMN", ErrorCode.UnknownError.getValue());
+ "BPMN", ErrorCode.UnknownError.getValue(), ex);
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
index e6d54b8681..eb832224db 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
@@ -47,22 +47,19 @@ class SDNCAdapterUtils {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+ MsoUtils msoUtils = new MsoUtils()
- private AbstractServiceTaskProcessor taskProcessor
-
- public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
- this.taskProcessor = taskProcessor
+ public SDNCAdapterUtils() {
}
String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
- def utils=new MsoUtils()
def prefix = execution.getVariable('prefix')
- def request = taskProcessor.getVariable(execution, requestName)
- def requestInformation = utils.getNodeXml(request, 'request-information', false)
- def serviceInformation = utils.getNodeXml(request, 'service-information', false)
- def featureInformation = utils.getNodeXml(request, 'feature-information', false)
- def featureParameters = utils.getNodeXml(request, 'feature-parameters', false)
+ def request = AbstractServiceTaskProcessor.getVariable(execution, requestName)
+ def requestInformation = msoUtils.getNodeXml(request, 'request-information', false)
+ def serviceInformation = msoUtils.getNodeXml(request, 'service-information', false)
+ def featureInformation = msoUtils.getNodeXml(request, 'feature-information', false)
+ def featureParameters = msoUtils.getNodeXml(request, 'feature-parameters', false)
def requestId = execution.getVariable('testReqId') // for junits
if(requestId==null){
@@ -71,10 +68,10 @@ class SDNCAdapterUtils {
def svcInstanceId = execution.getVariable("mso-service-instance-id")
- def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
- def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
- def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation)
- def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters)
+ def nnsRequestInformation = msoUtils.removeXmlNamespaces(requestInformation)
+ def nnsServiceInformation = msoUtils.removeXmlNamespaces(serviceInformation)
+ def nnsFeatureInformation = msoUtils.removeXmlNamespaces(featureInformation)
+ def nnsFeatureParameters = msoUtils.removeXmlNamespaces(featureParameters)
String sdncAdapterFeatureRequest = """
<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
@@ -95,18 +92,17 @@ class SDNCAdapterUtils {
<sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>
"""
- sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest))
+ sdncAdapterFeatureRequest = msoUtils.removeXmlPreamble(msoUtils.formatXml(sdncAdapterFeatureRequest))
return sdncAdapterFeatureRequest
}
String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {
- def utils=new MsoUtils()
def prefix = execution.getVariable('prefix')
- def request = taskProcessor.getVariable(execution, prefix+'Request')
- def requestInformation = utils.getNodeXml(request, 'request-information', false)
- def serviceInformation = utils.getNodeXml(request, 'service-information', false)
- def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
+ def request = AbstractServiceTaskProcessor.getVariable(execution, prefix+'Request')
+ def requestInformation = msoUtils.getNodeXml(request, 'request-information', false)
+ def serviceInformation = msoUtils.getNodeXml(request, 'service-information', false)
+ def vnfInformationList = msoUtils.getNodeXml(request, 'vnf-information-list', false)
def requestId = execution.getVariable('testReqId') // for junits
if(requestId==null){
@@ -115,9 +111,9 @@ class SDNCAdapterUtils {
def svcInstanceId = execution.getVariable("mso-service-instance-id")
- def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
- def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
- def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList)
+ def nnsRequestInformation = msoUtils.removeXmlNamespaces(requestInformation)
+ def nnsServiceInformation = msoUtils.removeXmlNamespaces(serviceInformation)
+ def nnsVnfInformationList = msoUtils.removeXmlNamespaces(vnfInformationList)
String sdncAdapterActivateVnfRequest = """
<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
@@ -138,15 +134,14 @@ class SDNCAdapterUtils {
<sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>
"""
- sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest))
+ sdncAdapterActivateVnfRequest = msoUtils.removeXmlPreamble(msoUtils.formatXml(sdncAdapterActivateVnfRequest))
return sdncAdapterActivateVnfRequest
}
String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
- def utils=new MsoUtils()
def prefix = execution.getVariable('prefix')
- def request = taskProcessor.getVariable(execution, prefix+'Request')
+ def request = AbstractServiceTaskProcessor.getVariable(execution, prefix+'Request')
String requestInformation = """<request-information>
<request-id>${MsoUtils.xmlEscape(execution.getVariable("mso-request-id"))}</request-id>
@@ -164,8 +159,8 @@ class SDNCAdapterUtils {
}else if("delete".equalsIgnoreCase(action)){
xml.'request-action'.replaceBody('deleteTrinityBonding')
}
- requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
- def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
+ requestInformation = msoUtils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
+ def nnsRequestInformation = msoUtils.removeXmlNamespaces(requestInformation)
def requestId = execution.getVariable('testReqId') // for junits
if(requestId==null){
@@ -234,7 +229,7 @@ class SDNCAdapterUtils {
<sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>
"""
- sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest))
+ sdncAdapterL3ToHLRequest = msoUtils.removeXmlPreamble(msoUtils.formatXml(sdncAdapterL3ToHLRequest))
return sdncAdapterL3ToHLRequest
}
@@ -243,13 +238,12 @@ class SDNCAdapterUtils {
private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,
String svcOperation, String additionalData) {
- def utils=new MsoUtils()
def prefix = execution.getVariable('prefix')
- def request = taskProcessor.getVariable(execution, prefix+'Request')
- def requestInformation = utils.getNodeXml(request, 'request-information', false)
- def serviceInformation = utils.getNodeXml(request, 'service-information', false)
- def serviceParameters = utils.getNodeXml(request, 'service-parameters', false)
+ def request = AbstractServiceTaskProcessor.getVariable(execution, prefix+'Request')
+ def requestInformation = msoUtils.getNodeXml(request, 'request-information', false)
+ def serviceInformation = msoUtils.getNodeXml(request, 'service-information', false)
+ def serviceParameters = msoUtils.getNodeXml(request, 'service-parameters', false)
def requestId = execution.getVariable('testReqId') // for junits
if(requestId==null){
@@ -269,18 +263,18 @@ class SDNCAdapterUtils {
workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
}
- def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false)
- def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
- def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false)
- def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
+ def l2HomingInformation = msoUtils.getNodeXml(serviceParameters, 'l2-homing-information', false)
+ def internetEvcAccessInformation = msoUtils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
+ def vrLan = msoUtils.getNodeXml(serviceParameters, 'vr-lan', false)
+ def upceVmsServiceInformation = msoUtils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
- def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
- def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
- def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
- def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
- def nnsVrLan = utils.removeXmlNamespaces(vrLan)
- def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation)
+ def nnsRequestInformation = msoUtils.removeXmlNamespaces(requestInformation)
+ def nnsServiceInformation = msoUtils.removeXmlNamespaces(serviceInformation)
+ def nnsl2HomingInformation = msoUtils.removeXmlNamespaces(l2HomingInformation)
+ def nnsInternetEvcAccessInformation = msoUtils.removeXmlNamespaces(internetEvcAccessInformation)
+ def nnsVrLan = msoUtils.removeXmlNamespaces(vrLan)
+ def nnsUpceVmsServiceInformation = msoUtils.removeXmlNamespaces(upceVmsServiceInformation)
if (additionalData == null) {
additionalData = ""
@@ -319,7 +313,7 @@ class SDNCAdapterUtils {
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>
"""
- content = utils.removeXmlPreamble(utils.formatXML(content))
+ content = msoUtils.removeXmlPreamble(msoUtils.formatXml(content))
execution.setVariable(resultVar, content)
}
@@ -343,7 +337,7 @@ class SDNCAdapterUtils {
* @param isAic3 boolean to indicate whether request is for AIC3.0
*/
public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {
- sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)
+ sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3)
}
/**
@@ -356,8 +350,8 @@ class SDNCAdapterUtils {
* RequestData element (may be null)
*/
public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
- String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {
- sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)
+ String svcOperation, String additionalData) {
+ sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false)
}
/**
@@ -370,7 +364,7 @@ class SDNCAdapterUtils {
* @param isAic3 boolean to indicate whether request is for AIC3.0
*/
public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
- String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {
+ String svcOperation, String additionalData, boolean isAic3) {
def method = getClass().getSimpleName() + '.sdncPrep(' +
'execution=' + execution.getId() +
', resultVar=' + resultVar +
@@ -380,14 +374,14 @@ class SDNCAdapterUtils {
')'
logger.trace('Entered ' + method)
- MsoUtils utils = taskProcessor.utils
+
try {
def prefix = execution.getVariable('prefix')
- def request = taskProcessor.getVariable(execution, prefix+'Request')
- def requestInformation = utils.getNodeXml(request, 'request-information', false)
- def serviceInformation = utils.getNodeXml(request, 'service-information', false)
- def serviceParameters = utils.getChildNodes(request, 'service-parameters')
- def requestAction = utils.getNodeText(request, 'request-action')
+ def request = AbstractServiceTaskProcessor.getVariable(execution, prefix+'Request')
+ def requestInformation = msoUtils.getNodeXml(request, 'request-information', false)
+ def serviceInformation = msoUtils.getNodeXml(request, 'service-information', false)
+ def serviceParameters = msoUtils.getChildNodes(request, 'service-parameters')
+ def requestAction = msoUtils.getNodeText(request, 'request-action')
def timeoutInMinutes = UrnPropertiesReader.getVariable('mso.sdnc.timeout.firewall.minutes',execution)
@@ -407,23 +401,23 @@ class SDNCAdapterUtils {
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
}
- def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false)
- def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false)
- def vrLan = utils.getNodeXml(request, 'vr-lan', false)
- def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false)
- def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
-
- def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
- def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
- def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
- def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
- def nnsVrLan = utils.removeXmlNamespaces(vrLan)
- def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo)
- def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan)
+ def l2HomingInformation = msoUtils.getNodeXml(request, 'l2-homing-information', false)
+ def internetEvcAccessInformation = msoUtils.getNodeXml(request, 'internet-evc-access-information', false)
+ def vrLan = msoUtils.getNodeXml(request, 'vr-lan', false)
+ def upceVmsServiceInfo = msoUtils.getNodeXml(request, 'ucpe-vms-service-information', false)
+ def vnfInformationList = msoUtils.getNodeXml(request, 'vnf-information-list', false)
+
+ def nnsRequestInformation = msoUtils.removeXmlNamespaces(requestInformation)
+ def nnsServiceInformation = msoUtils.removeXmlNamespaces(serviceInformation)
+ def nnsl2HomingInformation = msoUtils.removeXmlNamespaces(l2HomingInformation)
+ def nnsInternetEvcAccessInformation = msoUtils.removeXmlNamespaces(internetEvcAccessInformation)
+ def nnsVrLan = msoUtils.removeXmlNamespaces(vrLan)
+ def nnsUpceVmsServiceInfo = msoUtils.removeXmlNamespaces(upceVmsServiceInfo)
+ def nnsVnfInformationList = msoUtils.removeXmlNamespaces(vrLan)
def nnsinternetSvcChangeDetails = ""
if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){
- def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters)
+ def internetSvcChangeDetails = msoUtils.removeXmlNamespaces(serviceParameters)
nnsinternetSvcChangeDetails = """<internet-service-change-details>
${internetSvcChangeDetails}
</internet-service-change-details>"""
@@ -466,7 +460,7 @@ class SDNCAdapterUtils {
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>
"""
- content = utils.removeXmlPreamble(utils.formatXML(content))
+ content = msoUtils.removeXmlPreamble(msoUtils.formatXml(content))
execution.setVariable(resultVar, content)
logger.debug(resultVar + ' = ' + System.lineSeparator() + content)
@@ -506,7 +500,6 @@ class SDNCAdapterUtils {
* RequestData element (may be null)
*/
public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, L3Network queryAAIResponse, String additionalData) {
- def utils=new MsoUtils()
// SNDC is expecting request Id for header as unique each call.
String hdrRequestId = ""
@@ -521,17 +514,17 @@ class SDNCAdapterUtils {
try {
requestId = execution.getVariable("mso-request-id")
} catch (Exception ex) {
- requestId = utils.getNodeText(requestXML, "request-id")
+ requestId = msoUtils.getNodeText(requestXML, "request-id")
}
String aicCloudRegion = cloudRegionId
String tenantId = ""
- if (utils.nodeExists(requestXML, "tenant-id")) {
- tenantId = utils.getNodeText(requestXML, "tenant-id")
+ if (msoUtils.nodeExists(requestXML, "tenant-id")) {
+ tenantId = msoUtils.getNodeText(requestXML, "tenant-id")
}
String networkType = ""
- if (utils.nodeExists(requestXML, "network-type")) {
- networkType = utils.getNodeText(requestXML, "network-type")
+ if (msoUtils.nodeExists(requestXML, "network-type")) {
+ networkType = msoUtils.getNodeText(requestXML, "network-type")
}
// Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
@@ -540,20 +533,20 @@ class SDNCAdapterUtils {
}
String serviceId = ""
- if (utils.nodeExists(requestXML, "service-id")) {
- serviceId = utils.getNodeText(requestXML, "service-id")
+ if (msoUtils.nodeExists(requestXML, "service-id")) {
+ serviceId = msoUtils.getNodeText(requestXML, "service-id")
}
String networkName = ""
// Replace/Use the value of network-name from aai query (vs input) if it was already set in AAI
if (queryAAIResponse != null) {
networkName = queryAAIResponse.getNetworkName()
}
- if (networkName.isEmpty() && utils.nodeExists(requestXML, "network-name")) {
- networkName = utils.getNodeText(requestXML, "network-name")
+ if (networkName.isEmpty() && msoUtils.nodeExists(requestXML, "network-name")) {
+ networkName = msoUtils.getNodeText(requestXML, "network-name")
}
String source = ""
- if (utils.nodeExists(requestXML, "source")) {
- source = utils.getNodeText(requestXML, "source")
+ if (msoUtils.nodeExists(requestXML, "source")) {
+ source = msoUtils.getNodeText(requestXML, "source")
}
// get resourceLink from subflow execution variable
@@ -631,7 +624,6 @@ class SDNCAdapterUtils {
* RequestData element (may be null)
*/
public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {
- def utils=new MsoUtils()
// SNDC is expecting request Id for header as unique each call.
String hdrRequestId = ""
@@ -655,35 +647,35 @@ class SDNCAdapterUtils {
String aicCloudRegion = cloudRegionId
String tenantId = ""
- if (utils.nodeExists(requestXML, "tenant-id")) {
- tenantId = utils.getNodeText(requestXML, "tenant-id")
+ if (msoUtils.nodeExists(requestXML, "tenant-id")) {
+ tenantId = msoUtils.getNodeText(requestXML, "tenant-id")
}
String networkType = ""
- if (utils.nodeExists(requestXML, "network-type")) {
- networkType = utils.getNodeText(requestXML, "network-type")
+ if (msoUtils.nodeExists(requestXML, "network-type")) {
+ networkType = msoUtils.getNodeText(requestXML, "network-type")
}
String subscriptionServiceType = ""
- if (utils.nodeExists(requestXML, "subscription-service-type")) {
- subscriptionServiceType = utils.getNodeText(requestXML, "subscription-service-type")
+ if (msoUtils.nodeExists(requestXML, "subscription-service-type")) {
+ subscriptionServiceType = msoUtils.getNodeText(requestXML, "subscription-service-type")
}
String globalCustomerId = ""
- if (utils.nodeExists(requestXML, "global-customer-id")) {
- globalCustomerId = utils.getNodeText(requestXML, "global-customer-id")
+ if (msoUtils.nodeExists(requestXML, "global-customer-id")) {
+ globalCustomerId = msoUtils.getNodeText(requestXML, "global-customer-id")
}
String serviceId = ""
- if (utils.nodeExists(requestXML, "service-id")) {
- serviceId = utils.getNodeText(requestXML, "service-id")
+ if (msoUtils.nodeExists(requestXML, "service-id")) {
+ serviceId = msoUtils.getNodeText(requestXML, "service-id")
}
String networkName = ""
- if (utils.nodeExists(requestXML, "network-name")) {
- networkName = utils.getNodeText(requestXML, "network-name")
+ if (msoUtils.nodeExists(requestXML, "network-name")) {
+ networkName = msoUtils.getNodeText(requestXML, "network-name")
}
String source = ""
- if (utils.nodeExists(requestXML, "source")) {
- source = utils.getNodeText(requestXML, "source")
+ if (msoUtils.nodeExists(requestXML, "source")) {
+ source = msoUtils.getNodeText(requestXML, "source")
}
// get resourceLink from subflow execution variable
@@ -704,28 +696,28 @@ class SDNCAdapterUtils {
}
// network-information from 'networkModelInfo' // verify the DB Catalog response
- String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
- String modelInvariantUuid = utils.getNodeText(networkModelInfo, "modelInvariantUuid") !=null ?
- utils.getNodeText(networkModelInfo, "modelInvariantUuid") : ""
- String modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") !=null ?
- utils.getNodeText(networkModelInfo, "modelCustomizationUuid") : ""
- String modelUuid = utils.getNodeText(networkModelInfo, "modelUuid") !=null ?
- utils.getNodeText(networkModelInfo, "modelUuid") : ""
- String modelVersion = utils.getNodeText(networkModelInfo, "modelVersion") !=null ?
- utils.getNodeText(networkModelInfo, "modelVersion") : ""
- String modelName = utils.getNodeText(networkModelInfo, "modelName") !=null ?
- utils.getNodeText(networkModelInfo, "modelName") : ""
+ String networkModelInfo = msoUtils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
+ String modelInvariantUuid = msoUtils.getNodeText(networkModelInfo, "modelInvariantUuid") !=null ?
+ msoUtils.getNodeText(networkModelInfo, "modelInvariantUuid") : ""
+ String modelCustomizationUuid = msoUtils.getNodeText(networkModelInfo, "modelCustomizationUuid") !=null ?
+ msoUtils.getNodeText(networkModelInfo, "modelCustomizationUuid") : ""
+ String modelUuid = msoUtils.getNodeText(networkModelInfo, "modelUuid") !=null ?
+ msoUtils.getNodeText(networkModelInfo, "modelUuid") : ""
+ String modelVersion = msoUtils.getNodeText(networkModelInfo, "modelVersion") !=null ?
+ msoUtils.getNodeText(networkModelInfo, "modelVersion") : ""
+ String modelName = msoUtils.getNodeText(networkModelInfo, "modelName") !=null ?
+ msoUtils.getNodeText(networkModelInfo, "modelName") : ""
// service-information from 'networkModelInfo' // verify the DB Catalog response
- String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
- String serviceModelInvariantUuid = utils.getNodeText(serviceModelInfo, "modelInvariantUuid") !=null ?
- utils.getNodeText(serviceModelInfo, "modelInvariantUuid") : ""
- String serviceModelUuid = utils.getNodeText(serviceModelInfo, "modelUuid") !=null ?
- utils.getNodeText(serviceModelInfo, "modelUuid") : ""
- String serviceModelVersion = utils.getNodeText(serviceModelInfo, "modelVersion") !=null ?
- utils.getNodeText(serviceModelInfo, "modelVersion") : ""
- String serviceModelName = utils.getNodeText(serviceModelInfo, "modelName") !=null ?
- utils.getNodeText(serviceModelInfo, "modelName") : ""
+ String serviceModelInfo = msoUtils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
+ String serviceModelInvariantUuid = msoUtils.getNodeText(serviceModelInfo, "modelInvariantUuid") !=null ?
+ msoUtils.getNodeText(serviceModelInfo, "modelInvariantUuid") : ""
+ String serviceModelUuid = msoUtils.getNodeText(serviceModelInfo, "modelUuid") !=null ?
+ msoUtils.getNodeText(serviceModelInfo, "modelUuid") : ""
+ String serviceModelVersion = msoUtils.getNodeText(serviceModelInfo, "modelVersion") !=null ?
+ msoUtils.getNodeText(serviceModelInfo, "modelVersion") : ""
+ String serviceModelName = msoUtils.getNodeText(serviceModelInfo, "modelName") !=null ?
+ msoUtils.getNodeText(serviceModelInfo, "modelName") : ""
String content =
@@ -808,27 +800,27 @@ class SDNCAdapterUtils {
}else{
// we need to peer into the request data for error
- def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
+ def String sdncAdapterWorkflowResponse = msoUtils.getNodeXml(response, 'response-data', false)
def String decodedXml = sdncAdapterWorkflowResponse.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- decodedXml = taskProcessor.utils.getNodeXml(response, 'RequestData')
+ decodedXml = msoUtils.getNodeXml(response, 'RequestData')
logger.debug("decodedXml:\n" + decodedXml)
int requestDataResponseCode = 200
def String requestDataResponseMessage = ''
try{
- if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
- requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
- } else if (taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseMessage")) {
- requestDataResponseMessage = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseMessage")
+ if (msoUtils.nodeExists(decodedXml, "response-message")) {
+ requestDataResponseMessage = msoUtils.getNodeText(decodedXml, "response-message")
+ } else if (msoUtils.nodeExists(sdncAdapterWorkflowResponse, "ResponseMessage")) {
+ requestDataResponseMessage = msoUtils.getNodeText(sdncAdapterWorkflowResponse, "ResponseMessage")
}
}catch(Exception e){
logger.debug('Error caught while decoding resposne ' + e.getMessage())
}
- if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
+ if(msoUtils.nodeExists(decodedXml, "response-code")) {
logger.debug("response-code node Exist ")
- String code = taskProcessor.utils.getNodeText(decodedXml, "response-code")
+ String code = msoUtils.getNodeText(decodedXml, "response-code")
if(code.isEmpty() || code.equals("")){
// if response-code is blank then Success
logger.debug("response-code node is empty")
@@ -837,9 +829,9 @@ class SDNCAdapterUtils {
requestDataResponseCode = code.toInteger()
logger.debug("response-code is: " + requestDataResponseCode)
}
- }else if(taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseCode")){
+ }else if(msoUtils.nodeExists(sdncAdapterWorkflowResponse, "ResponseCode")){
logger.debug("ResponseCode node Exist ")
- String code = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseCode")
+ String code = msoUtils.getNodeText(sdncAdapterWorkflowResponse, "ResponseCode")
if(code.isEmpty() || code.equals("")){
// if ResponseCode blank then Success
logger.debug("ResponseCode node is empty")
@@ -918,7 +910,7 @@ class SDNCAdapterUtils {
if (success) {
// we need to look inside the request data for error
- def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
+ def String callbackRequestData = msoUtils.getNodeXml(response, 'RequestData', false)
def String decodedXml = callbackRequestData
logger.debug("decodedXml:\n" + decodedXml)
@@ -926,17 +918,17 @@ class SDNCAdapterUtils {
def requestDataResponseMessage = ''
int intDataResponseCode = 200
- if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
+ if (msoUtils.nodeExists(decodedXml, "response-code")) {
- requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code"))
- if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
- requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
+ requestDataResponseCode = ((String) msoUtils.getNodeText(decodedXml, "response-code"))
+ if (msoUtils.nodeExists(decodedXml, "response-message")) {
+ requestDataResponseMessage = msoUtils.getNodeText(decodedXml, "response-message")
}
- }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
- requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "ResponseCode")).toInteger()
- }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){
- requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(response, "ResponseCode")).toInteger()
- requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
+ }else if(msoUtils.nodeExists(decodedXml, "ResponseCode")){
+ requestDataResponseCode = ((String) msoUtils.getNodeText(decodedXml, "ResponseCode")).toInteger()
+ }else if(msoUtils.nodeExists(response, "ResponseCode")){
+ requestDataResponseCode = ((String) msoUtils.getNodeText(response, "ResponseCode")).toInteger()
+ requestDataResponseMessage = msoUtils.getNodeText(response, "ResponseMessage")
}
logger.debug("SDNC callback response-code: " + requestDataResponseCode)
@@ -944,8 +936,8 @@ class SDNCAdapterUtils {
// Get the AAI Status to determine if rollback is needed on ASSIGN
def aai_status = ''
- if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
- aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
+ if (msoUtils.nodeExists(decodedXml, "aai-status")) {
+ aai_status = ((String) msoUtils.getNodeText(decodedXml, "aai-status"))
logger.debug("SDNC sent AAI STATUS code: " + aai_status)
}
if (aai_status != null && !aai_status.equals("")) {
@@ -955,8 +947,8 @@ class SDNCAdapterUtils {
// Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
def sdncResult = ''
- if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
- sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
+ if (msoUtils.nodeExists(decodedXml, "result")) {
+ sdncResult = ((String) msoUtils.getNodeText(decodedXml, "result"))
logger.debug("SDNC sent result: " + sdncResult)
}
if (sdncResult != null && !sdncResult.equals("")) {
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
index 796ee43cf4..a40bf59097 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
@@ -206,7 +206,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
// Construct payload
managementV6AddressEntry = updateGenericVnfNode(origRequest, 'management-v6-address')
}
-
+
// Handle orchestration-status
String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus')
String orchestrationStatusEntry = null
@@ -214,7 +214,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
// Construct payload
orchestrationStatusEntry = updateGenericVnfNode(origRequest, 'orchestration-status')
}
-
+
org.onap.aai.domain.yang.GenericVnf payload = new org.onap.aai.domain.yang.GenericVnf();
payload.setVnfId(vnfId)
payload.setPersonaModelVersion(personaModelVersionEntry)
@@ -227,8 +227,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
try {
getAAIClient().update(uri,payload)
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI PATCH: {}', ex.getMessage(), ex)
execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 500)
execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', 'AAI PATCH Failed:' + ex.getMessage())
}
@@ -258,9 +257,9 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
return ""
}
else {
- return elementValue
+ return elementValue
}
-
+
}
/**
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
index 259a7872a3..1960cafb0f 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
@@ -69,7 +69,7 @@ class VidUtils {
public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId) {
createXmlVolumeRequest(requestMap, action, serviceInstanceId, '')
}
-
+
/**
* Create a volume-request XML using a map
@@ -84,9 +84,9 @@ class VidUtils {
def serviceName = ''
def modelCustomizationName = ''
def asdcServiceModelVersion = ''
-
+
def suppressRollback = requestMap.requestDetails.requestInfo.suppressRollback
-
+
def backoutOnFailure = ""
if(suppressRollback != null){
if ( suppressRollback == true) {
@@ -95,7 +95,7 @@ class VidUtils {
backoutOnFailure = "true"
}
}
-
+
def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: ''
def serviceId = requestMap.requestDetails.requestParameters?.serviceId ?: ''
def relatedInstanceList = requestMap.requestDetails.relatedInstanceList
@@ -108,16 +108,16 @@ class VidUtils {
modelCustomizationName = it.relatedInstance.modelInfo?.modelInstanceName
}
}
-
+
vnfType = serviceName + '/' + modelCustomizationName
-
+
def userParams = requestMap.requestDetails?.requestParameters?.userParams
def userParamsNode = ''
if(userParams != null) {
userParamsNode = buildUserParams(userParams)
}
def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: ''
-
+
String xmlReq = """
<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
<request-info>
@@ -145,9 +145,9 @@ class VidUtils {
// return a pretty-print of the volume-request xml without the preamble
return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "")
}
-
+
/**
- * A common method that can be used to build volume-params node from a map.
+ * A common method that can be used to build volume-params node from a map.
* @param Map userParams
* @return
*/
@@ -166,9 +166,9 @@ class VidUtils {
}
/**
- * A common method that can be used to extract 'requestDetails'
+ * A common method that can be used to extract 'requestDetails'
* @param String json
- * @return String json requestDetails
+ * @return String json requestDetails
*/
@Deprecated
public getJsonRequestDetails(String jsonInput) {
@@ -183,10 +183,10 @@ class VidUtils {
return rtn
} else {
return rtn
- }
+ }
}
}
-
+
/**
* A common method that can be used to extract 'requestDetails' in Xml
* @param String json
@@ -203,17 +203,17 @@ class VidUtils {
return XmlTool.normalize(XML.toString(jsonObj))
}
}
-
+
/**
* Create a network-request XML using a map
- * @param execution
- * @param xmlRequestDetails - requestDetails in xml
+ * @param execution
+ * @param xmlRequestDetails - requestDetails in xml
* @return
* Note: See latest version: createXmlNetworkRequestInstance()
*/
public String createXmlNetworkRequestInfra(execution, def networkJsonIncoming) {
-
+
def requestId = execution.getVariable("requestId")
def serviceInstanceId = execution.getVariable("serviceInstanceId")
def requestAction = execution.getVariable("requestAction")
@@ -225,13 +225,13 @@ class VidUtils {
def instanceName = reqMap.requestDetails.requestInfo.instanceName
def modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationId
if (modelCustomizationId == null) {
- modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationUuid !=null ?
+ modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationUuid !=null ?
reqMap.requestDetails.modelInfo.modelCustomizationUuid : ""
}
def modelName = reqMap.requestDetails.modelInfo.modelName
def lcpCloudRegionId = reqMap.requestDetails.cloudConfiguration.lcpCloudRegionId
def tenantId = reqMap.requestDetails.cloudConfiguration.tenantId
- def serviceId = reqMap.requestDetails.requestInfo.productFamilyId
+ def serviceId = reqMap.requestDetails.requestInfo.productFamilyId
def suppressRollback = reqMap.requestDetails.requestInfo.suppressRollback.toString()
def backoutOnFailure = "true"
if(suppressRollback != null){
@@ -241,7 +241,7 @@ class VidUtils {
backoutOnFailure = "true"
}
}
-
+
//def userParams = reqMap.requestDetails.requestParameters.userParams
//def userParamsNode = buildUserParams(userParams)
def userParams = reqMap.requestDetails?.requestParameters?.userParams
@@ -249,26 +249,26 @@ class VidUtils {
if(userParams != null) {
userParamsNode = buildUserParams(userParams)
}
-
+
//'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC)
def sdncVersion = execution.getVariable("sdncVersion")
-
+
String xmlReq = """
- <network-request xmlns="http://www.w3.org/2001/XMLSchema">
- <request-info>
+ <network-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
<request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
- <action>${MsoUtils.xmlEscape(requestAction)}</action>
- <source>VID</source>
+ <action>${MsoUtils.xmlEscape(requestAction)}</action>
+ <source>VID</source>
<service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
- </request-info>
+ </request-info>
<network-inputs>
- <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
- <network-name>${MsoUtils.xmlEscape(instanceName)}</network-name>
+ <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
+ <network-name>${MsoUtils.xmlEscape(instanceName)}</network-name>
<network-type>${MsoUtils.xmlEscape(modelName)}</network-type>
- <modelCustomizationId>${MsoUtils.xmlEscape(modelCustomizationId)}</modelCustomizationId>
- <aic-cloud-region>${MsoUtils.xmlEscape(lcpCloudRegionId)}</aic-cloud-region>
+ <modelCustomizationId>${MsoUtils.xmlEscape(modelCustomizationId)}</modelCustomizationId>
+ <aic-cloud-region>${MsoUtils.xmlEscape(lcpCloudRegionId)}</aic-cloud-region>
<tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id>
- <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
+ <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
<backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure>
<sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion>
</network-inputs>
@@ -281,8 +281,7 @@ class VidUtils {
return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "")
} catch(Exception e) {
- logger.debug("{} {}", "Error in Vid Utils", e.getCause())
- e.printStackTrace();
+ logger.debug("Error in Vid Utils: {}", e.getCause(), e)
throw e
}
}
@@ -299,7 +298,7 @@ class VidUtils {
def networkModelVersion = ""
def networkModelCustomizationUuid = ""
def networkModelInvariantUuid = ""
-
+
// verify the DB Catalog response JSON structure
def networkModelInfo = execution.getVariable("networkModelInfo")
def jsonSlurper = new JsonSlurper()
@@ -326,14 +325,14 @@ class VidUtils {
} catch (Exception ex) {
throw ex
}
- }
-
+ }
+
def serviceModelUuid = ""
def serviceModelName = ""
def serviceModelVersion = ""
def serviceModelCustomizationUuid = ""
def serviceModelInvariantUuid = ""
-
+
// verify the DB Catalog response JSON structure
def serviceModelInfo = execution.getVariable("serviceModelInfo")
def jsonServiceSlurper = new JsonSlurper()
@@ -361,8 +360,8 @@ class VidUtils {
throw ex
}
}
-
-
+
+
def subscriptionServiceType = execution.getVariable("subscriptionServiceType") != null ? execution.getVariable("subscriptionServiceType") : ""
def globalSubscriberId = execution.getVariable("globalSubscriberId") != null ? execution.getVariable("globalSubscriberId") : ""
def requestId = execution.getVariable("msoRequestId")
@@ -382,88 +381,88 @@ class VidUtils {
backoutOnFailure = "true"
}
}
-
+
//'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC)
def sdncVersion = execution.getVariable("sdncVersion")
-
+
def source = "VID"
def action = execution.getVariable("action")
-
+
def userParamsNode = ""
def userParams = execution.getVariable("networkInputParams")
if(userParams != null) {
userParamsNode = buildUserParams(userParams)
}
-
+
String xmlReq = """
- <network-request xmlns="http://www.w3.org/2001/XMLSchema">
- <request-info>
+ <network-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
<request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
- <action>${MsoUtils.xmlEscape(action)}</action>
- <source>${MsoUtils.xmlEscape(source)}</source>
+ <action>${MsoUtils.xmlEscape(action)}</action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
<service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
- </request-info>
- <network-inputs>
- <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
- <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
+ </request-info>
+ <network-inputs>
+ <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
+ <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
<network-type>${MsoUtils.xmlEscape(networkModelName)}</network-type>
<subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
<global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
- <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudReqion)}</aic-cloud-region>
+ <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudReqion)}</aic-cloud-region>
<tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id>
- <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
+ <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
<backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure>
<failIfExist>${MsoUtils.xmlEscape(failIfExist)}</failIfExist>
<networkModelInfo>
<modelName>${MsoUtils.xmlEscape(networkModelName)}</modelName>
<modelUuid>${MsoUtils.xmlEscape(networkModelUuid)}</modelUuid>
- <modelInvariantUuid>${MsoUtils.xmlEscape(networkModelInvariantUuid)}</modelInvariantUuid>
+ <modelInvariantUuid>${MsoUtils.xmlEscape(networkModelInvariantUuid)}</modelInvariantUuid>
<modelVersion>${MsoUtils.xmlEscape(networkModelVersion)}</modelVersion>
<modelCustomizationUuid>${MsoUtils.xmlEscape(networkModelCustomizationUuid)}</modelCustomizationUuid>
</networkModelInfo>
<serviceModelInfo>
<modelName>${MsoUtils.xmlEscape(serviceModelName)}</modelName>
<modelUuid>${MsoUtils.xmlEscape(serviceModelUuid)}</modelUuid>
- <modelInvariantUuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</modelInvariantUuid>
+ <modelInvariantUuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</modelInvariantUuid>
<modelVersion>${MsoUtils.xmlEscape(serviceModelVersion)}</modelVersion>
<modelCustomizationUuid>${MsoUtils.xmlEscape(serviceModelCustomizationUuid)}</modelCustomizationUuid>
-
- </serviceModelInfo>
- <sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion>
+
+ </serviceModelInfo>
+ <sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion>
</network-inputs>
<network-params>
${userParamsNode}
- </network-params>
+ </network-params>
</network-request>
"""
// return a pretty-print of the volume-request xml without the preamble
return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "")
-
+
}
-
+
/**
* Create a vnf-request XML using a map
- * @param requestMap - map created from VID JSON
+ * @param requestMap - map created from VID JSON
* @param action
* @return
*/
public String createXmlVfModuleRequest(execution, Map requestMap, String action, String serviceInstanceId) {
-
+
//def relatedInstanceList = requestMap.requestDetails.relatedInstanceList
-
+
//relatedInstanceList.each {
// if (it.relatedInstance.modelInfo.modelType == 'vnf') {
// vnfType = it.relatedInstance.modelInfo.modelName
// vnfId = it.relatedInstance.modelInfo.modelInvariantId
// }
//}
-
+
def vnfName = ''
def asdcServiceModelInfo = ''
-
+
def relatedInstanceList = requestMap.requestDetails?.relatedInstanceList
-
-
+
+
if (relatedInstanceList != null) {
relatedInstanceList.each {
if (it.relatedInstance.modelInfo?.modelType == 'service') {
@@ -474,30 +473,30 @@ class VidUtils {
}
}
}
-
+
def vnfType = execution.getVariable('vnfType')
def vnfId = execution.getVariable('vnfId')
def vfModuleId = execution.getVariable('vfModuleId')
def volumeGroupId = execution.getVariable('volumeGroupId')
def userParams = requestMap.requestDetails?.requestParameters?.userParams
-
-
+
+
def userParamsNode = ''
if(userParams != null) {
userParamsNode = buildUserParams(userParams)
}
-
+
def isBaseVfModule = "false"
if (execution.getVariable('isBaseVfModule') == true) {
isBaseVfModule = "true"
}
-
+
def requestId = execution.getVariable("mso-request-id")
def vfModuleName = requestMap.requestDetails?.requestInfo?.instanceName ?: ''
def vfModuleModelName = requestMap.requestDetails?.modelInfo?.modelName ?: ''
def suppressRollback = requestMap.requestDetails?.requestInfo?.suppressRollback
-
+
def backoutOnFailure = ""
if(suppressRollback != null){
if ( suppressRollback == true) {
@@ -506,14 +505,14 @@ class VidUtils {
backoutOnFailure = "true"
}
}
-
+
def serviceId = requestMap.requestDetails?.requestParameters?.serviceId ?: ''
def aicCloudRegion = requestMap.requestDetails?.cloudConfiguration?.lcpCloudRegionId ?: ''
def tenantId = requestMap.requestDetails?.cloudConfiguration?.tenantId ?: ''
def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantUuid ?: ''
def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelUuid ?: ''
def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: ''
-
+
String xmlReq = """
<vnf-request>
<request-info>
@@ -524,17 +523,17 @@ class VidUtils {
</request-info>
<vnf-inputs>
<!-- not in use in 1610 -->
- <vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>
+ <vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>
<vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
<vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
<volume-group-id>${MsoUtils.xmlEscape(volumeGroupId)}</volume-group-id>
<vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
- <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name>
+ <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name>
<vf-module-model-name>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-model-name>
<model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-id>
<is-base-vf-module>${MsoUtils.xmlEscape(isBaseVfModule)}</is-base-vf-module>
<asdc-service-model-version>${MsoUtils.xmlEscape(asdcServiceModelInfo)}</asdc-service-model-version>
- <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
+ <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
<tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id>
<service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
<backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure>
@@ -546,10 +545,10 @@ class VidUtils {
</vnf-params>
</vnf-request>
"""
-
+
// return a pretty-print of the volume-request xml without the preamble
return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "")
}
-
+
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
index ac67d949a5..aacd385a3b 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
@@ -294,7 +294,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
} catch (IOException ex) {
logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter",
- "BPMN", ErrorCode.UnknownError.getValue());
+ "BPMN", ErrorCode.UnknownError.getValue(), ex);
}
}
@@ -398,7 +398,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
vnfAdapterWorkflowException(execution, callback)
}
} catch (Exception e) {
- logger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e)
+ logger.debug("Error encountered within VnfAdapterRest ProcessCallback method: {}", e.getMessage(), e)
exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
index 5352fc2fe0..2cc6415a50 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
@@ -146,7 +146,7 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo
result.add(klass.newInstance());
}
} catch (InstantiationException | IllegalAccessException e) {
- logger.error("failed to build validator list for " + clazz.getName(), e);
+ logger.error("failed to build validator list for {}", clazz.getName(), e);
throw new RuntimeException(e);
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
index 260a9420c8..8af6e809f4 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
@@ -49,7 +49,7 @@ public class ExtractPojosForBB {
public <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key) throws BBObjectNotFoundException {
return extractByKey(execution, key, execution.getLookupMap().get(key));
}
- protected <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value)
+ public <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value)
throws BBObjectNotFoundException {
Optional<T> result = Optional.empty();
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 29abe4413b..0b2ef928ad 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -25,11 +25,11 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers;
-import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader;
-import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.so.client.PreconditionFailedException;
import org.onap.so.client.RestPropertiesLoader;
import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
index 51dd77d383..570acf4524 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
@@ -53,12 +53,7 @@ public class SDNCAdapterUtilsTest {
map = new HashMap<String,Object>()
svcex = mock(ExecutionEntity.class)
wfex = null
- tp = new AbstractServiceTaskProcessor() {
- @Override
- public void preProcessRequest(DelegateExecution execution) {
- }
- };
- utils = new SDNCAdapterUtils(tp)
+ utils = new SDNCAdapterUtils()
// svcex gets its variables from "map"
when(svcex.getVariable(any())).thenAnswer(
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
index a83337fc5b..5271bb3c53 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
@@ -22,13 +22,17 @@ package org.onap.so.bpmn.core.domain;
import static org.junit.Assert.*;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
public class VnfResourceTest {
-
+
+ private final static String ALL_VF_MODULES_JSON =
+ "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}";
+
private VnfResource vnf= new VnfResource();
List<ModuleResource> moduleResources;
@@ -63,4 +67,34 @@ public class VnfResourceTest {
assertTrue(vnfResource != null);
}
+ @Test
+ public void testVfModules() {
+
+ moduleResources = new ArrayList<>();
+
+ ModuleResource moduleresource = new ModuleResource();
+ moduleresource.setVfModuleName("vfModuleName");
+ moduleresource.setHeatStackId("heatStackId");
+ moduleresource.setIsBase(true);
+ moduleresource.setVfModuleLabel("vfModuleLabel");
+ moduleresource.setInitialCount(0);
+ moduleresource.setVfModuleType("vfModuleType");
+ moduleresource.setHasVolumeGroup(true);
+
+ moduleResources.add(moduleresource);
+
+ vnf.setModules(moduleResources);
+ assertEquals(vnf.getVfModules(), moduleResources);
+
+ List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(1, moduleResources.size());
+
+ vnf.addVfModule(moduleresource);
+ moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(2, moduleResources.size());
+
+ assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson());
+
+ }
+
}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn
new file mode 100644
index 0000000000..92ac5f9f5b
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn
@@ -0,0 +1,116 @@
+<?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_1556kf5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+ <bpmn:process id="ConfigDeployVnfBB" name="ConfigDeployVnfBB" isExecutable="true">
+ <bpmn:startEvent id="Start" name="Start">
+ <bpmn:outgoing>SequenceFlow_0pd4jka</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="UpdateAAIConfigured" name="Update AAI Configured" camunda:expression="${ConfigDeployVnf.updateAAIConfigured(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1tb7fs1</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_00u29dm</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="End" name="End">
+ <bpmn:incoming>SequenceFlow_00u29dm</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0pd4jka" sourceRef="Start" targetRef="UpdateAAIConfigure" />
+ <bpmn:sequenceFlow id="SequenceFlow_03xbj4e" sourceRef="AbstractCDSBB" targetRef="ExclusiveGateway_0duh80v" />
+ <bpmn:sequenceFlow id="SequenceFlow_00u29dm" sourceRef="UpdateAAIConfigured" targetRef="End" />
+ <bpmn:callActivity id="AbstractCDSBB" name="Abstract CDS (CDS Call)" calledElement="AbstractCDSProcessingBB">
+ <bpmn:extensionElements>
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="executionObject" target="executionObject" />
+ <camunda:out source="CDSStatus" target="CDSStatus" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:serviceTask id="UpdateAAIConfigure" name="Update AAI Configure" camunda:expression="${ConfigDeployVnf.updateAAIConfigure(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0pd4jka</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0moyu92</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0moyu92" sourceRef="UpdateAAIConfigure" targetRef="PreProcessAbstractCDSProcessing" />
+ <bpmn:sequenceFlow id="SequenceFlow_0kruy8t" sourceRef="PreProcessAbstractCDSProcessing" targetRef="AbstractCDSBB" />
+ <bpmn:serviceTask id="PreProcessAbstractCDSProcessing" name="PreProcess Abstract CDS Processing" camunda:expression="${ConfigDeployVnf.preProcessAbstractCDSProcessing(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0moyu92</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0kruy8t</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:exclusiveGateway id="ExclusiveGateway_0duh80v" default="SequenceFlow_0o50k2d">
+ <bpmn:incoming>SequenceFlow_03xbj4e</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1tb7fs1</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" />
+ <bpmn:endEvent id="EndEvent_0wwnq4u">
+ <bpmn:incoming>SequenceFlow_0o50k2d</bpmn:incoming>
+ <bpmn:errorEventDefinition errorRef="Error_0zsv500" />
+ </bpmn:endEvent>
+ </bpmn:process>
+ <bpmn:error id="Error_0zsv500" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ConfigDeployVnfBB">
+ <bpmndi:BPMNEdge id="SequenceFlow_0pd4jka_di" bpmnElement="SequenceFlow_0pd4jka">
+ <di:waypoint x="542" y="248" />
+ <di:waypoint x="607" y="248" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_03xbj4e_di" bpmnElement="SequenceFlow_03xbj4e">
+ <di:waypoint x="1039" y="248" />
+ <di:waypoint x="1089" y="248" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_00u29dm_di" bpmnElement="SequenceFlow_00u29dm">
+ <di:waypoint x="1327" y="248" />
+ <di:waypoint x="1399" y="248" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start">
+ <dc:Bounds x="506" y="230" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="512" y="273" width="25" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0c9apxl_di" bpmnElement="UpdateAAIConfigured">
+ <dc:Bounds x="1227" y="208" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0p7ssqo_di" bpmnElement="End">
+ <dc:Bounds x="1399" y="230" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1407" y="273" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="CallActivity_0vg7uiv_di" bpmnElement="AbstractCDSBB">
+ <dc:Bounds x="939" y="208" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_05zt0do_di" bpmnElement="UpdateAAIConfigure">
+ <dc:Bounds x="607" y="208" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0moyu92_di" bpmnElement="SequenceFlow_0moyu92">
+ <di:waypoint x="707" y="248" />
+ <di:waypoint x="770" y="248" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0kruy8t_di" bpmnElement="SequenceFlow_0kruy8t">
+ <di:waypoint x="870" y="248" />
+ <di:waypoint x="939" y="248" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0m4kmps_di" bpmnElement="PreProcessAbstractCDSProcessing">
+ <dc:Bounds x="770" y="208" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ExclusiveGateway_0duh80v_di" bpmnElement="ExclusiveGateway_0duh80v" isMarkerVisible="true">
+ <dc:Bounds x="1089" y="223" width="50" height="50" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1tb7fs1_di" bpmnElement="SequenceFlow_1tb7fs1">
+ <di:waypoint x="1139" y="248" />
+ <di:waypoint x="1227" y="248" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1163" y="230" width="41" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0o50k2d_di" bpmnElement="SequenceFlow_0o50k2d">
+ <di:waypoint x="1114" y="273" />
+ <di:waypoint x="1114" y="348" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="EndEvent_1p3d0t4_di" bpmnElement="EndEvent_0wwnq4u">
+ <dc:Bounds x="1096" y="348" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy
index 19fe018e13..d588da38b0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy
@@ -416,7 +416,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor {
} catch (Exception ex) {
String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse()"
- logger.debug("Exception error in CreateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage())
+ logger.debug("Exception error in CreateNetworkInstance flow, buildErrorResponse(): {}", ex.getMessage(), ex)
falloutHandlerRequest =
"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:ns="http://org.onap/so/request/types/v1"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
index 712512fdc9..fa9fe62df4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
@@ -268,7 +268,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
*/
public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
String responseCodeVar, String errorResponseVar) {
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
index c0e8d5a6ba..e941d50155 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
@@ -349,7 +349,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
logger.debug("SDNCResponse: " + response)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
index ce9df87799..a12c2f4b85 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
@@ -156,7 +156,7 @@ public class DoCreateE2EServiceInstanceRollback extends AbstractServiceTaskProce
logger.debug("SDNCResponse: " + response)
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
index 41bae326a5..22c8a11fae 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
@@ -1081,7 +1081,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
WorkflowException workflowException = execution.getVariable("WorkflowException")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
// reset variable
String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse")
@@ -1109,7 +1109,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
WorkflowException workflowException = execution.getVariable("WorkflowException")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
// reset variable
String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy
index c144dc0f46..41a302f5f1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy
@@ -244,7 +244,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode")
String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse")
String rollbackSDNCReturnInnerCode = ""
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
rollbackSDNCResponse = rollbackSDNCResponse
rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
if (rollbackSDNCReturnCode == "200") {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
index 163bd0f583..bf52b11de2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
@@ -491,7 +491,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
String response = execution.getVariable("sdncAdapterResponse")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy
index a337087105..1eeba493f4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy
@@ -149,7 +149,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
logger.debug("SDNCResponse: " + response)
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index 7a606d515c..6b4fc840f7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -84,7 +84,7 @@ public class DoCreateVfModule extends VfModuleBase {
String Prefix="DCVFM_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
OofInfraUtils oofInfraUtils = new OofInfraUtils()
CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil()
@@ -598,7 +598,7 @@ public class DoCreateVfModule extends VfModuleBase {
*/
public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
String responseCodeVar, String errorResponseVar) {
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
}
@@ -668,8 +668,7 @@ public class DoCreateVfModule extends VfModuleBase {
rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true")
execution.setVariable("rollbackData", rollbackData)
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage())
+ logger.debug('Exception occurred while postProcessing CreateAAIVfModule request: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Bad response from CreateAAIVfModule' + ex.getMessage())
}
logger.trace('Exited ' + method)
@@ -741,8 +740,7 @@ public class DoCreateVfModule extends VfModuleBase {
}
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
@@ -822,17 +820,16 @@ public class DoCreateVfModule extends VfModuleBase {
}
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
'Caught exception in ' + method, "BPMN",
- ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage())
}
}
@@ -1638,7 +1635,7 @@ public class DoCreateVfModule extends VfModuleBase {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
String sdncResponse = response
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
index 07ffa38498..65f6f76a21 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
@@ -463,7 +463,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
WorkflowException workflowException = execution.getVariable("WorkflowException")
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
index 5f160bb068..fb5c0fa0aa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
@@ -61,7 +61,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
VidUtils vidUtils = new VidUtils(this)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
OofInfraUtils oofInfraUtils = new OofInfraUtils()
/**
@@ -362,7 +362,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
resourceClient.connect(uri, siUri)
}catch(Exception ex) {
- logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex)
+ logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process: {}", ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
}
logger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
@@ -530,7 +530,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
logger.debug("SDNCResponse: " + response)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
index 3209f52fef..7ea32d2a60 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
@@ -315,7 +315,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
String sdncResponse = response
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
index a54d90b2bf..2558f7eff5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
@@ -691,7 +691,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
WorkflowException workflowException = execution.getVariable("WorkflowException")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
// reset variable
String deleteSDNCResponseDecodeXml = execution.getVariable(Prefix + "deleteSDNCResponse")
@@ -719,7 +719,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
WorkflowException workflowException = execution.getVariable("WorkflowException")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
// reset variable
String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "deactivateSDNCResponse")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy
index d09fb03445..36c145b0e0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy
@@ -220,7 +220,7 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode")
String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse")
String rollbackSDNCReturnInnerCode = ""
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
if (rollbackSDNCReturnCode == "200") {
if (utils.nodeExists(rollbackSDNCResponse, "response-code")) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
index 2e1cca54a6..0c676b5589 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
@@ -258,7 +258,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
logger.debug("SDNCResponse: " + response)
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
index 05ccfa02ba..b21dcf3433 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
@@ -375,7 +375,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
WorkflowException workflowException = execution.getVariable("WorkflowException")
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
@@ -621,8 +621,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
logger.debug("Received orchestration status from A&AI: " + orchestrationStatus)
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
index 47aec46277..e5306c40de 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory
public class DoDeleteVfModuleFromVnf extends VfModuleBase {
private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleFromVnf.class);
-
+
def Prefix="DDVFMV_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -66,7 +66,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
initProcessVariables(execution)
try {
-
+
// Building Block-type request
// Set mso-request-id to request-id for VNF Adapter interface
@@ -75,7 +75,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
execution.setVariable("requestId", requestId)
logger.debug("msoRequestId: " + requestId)
String tenantId = execution.getVariable("tenantId")
- logger.debug("tenantId: " + tenantId)
+ logger.debug("tenantId: " + tenantId)
String cloudSiteId = execution.getVariable("lcpCloudRegionId")
execution.setVariable("cloudSiteId", cloudSiteId)
logger.debug("cloudSiteId: " + cloudSiteId)
@@ -102,15 +102,15 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
}
else {
execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId)
- }
+ }
String sdncVersion = execution.getVariable("sdncVersion")
if (sdncVersion == null) {
sdncVersion = "1707"
}
execution.setVariable(Prefix + "sdncVersion", sdncVersion)
- logger.debug("Incoming Sdnc Version is: " + sdncVersion)
-
+ logger.debug("Incoming Sdnc Version is: " + sdncVersion)
+
String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
@@ -122,8 +122,6 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
logger.debug("SDNC Callback URL: " + sdncCallbackUrl)
logger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
-
-
}catch(BpmnError b){
throw b
}catch(Exception e){
@@ -131,7 +129,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!")
}
}
-
+
public void queryAAIForVfModule(DelegateExecution execution) {
def method = getClass().getSimpleName() + '.queryAAIForVfModule(' +
'execution=' + execution.getId() +
@@ -154,8 +152,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
execution.setVariable('DDVMFV_getVnfResponse', "Generic Vnf not found!")
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
execution.setVariable('DDVMFV_getVnfResponseCode', 500)
execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage())
}
@@ -169,7 +166,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage())
}
}
-
+
/**
* Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID
* exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module
@@ -342,7 +339,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
logger.debug("SDNCResponse: " + response)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
index fb62babae9..9bd3388b79 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
@@ -60,7 +60,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
VidUtils vidUtils = new VidUtils(this)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
/**
* This method gets and validates the incoming
@@ -322,7 +322,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
}
if (vfModuleBaseEntry != null) {
vfModulesList.add(vfModuleBaseEntry)
- }
+ }
}
}else{
execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 404)
@@ -331,8 +331,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
}
execution.setVariable("DDVAM_vfModules", vfModulesList)
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
@@ -501,7 +500,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
logger.debug("SDNCResponse: " + response)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
index ce61595680..430c16bbef 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
@@ -946,7 +946,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
// reset variable
String changeAssignSDNCResponseDecodeXml = execution.getVariable(Prefix + "changeAssignSDNCResponse")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy
index 1b98451fbe..371e54ca75 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy
@@ -204,7 +204,7 @@ public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcesso
rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode")
String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse")
String rollbackSDNCReturnInnerCode = ""
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
if (rollbackSDNCReturnCode == "200") {
if (utils.nodeExists(rollbackSDNCResponse, "response-code")) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
index 013f66b008..abbcf66323 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
@@ -988,7 +988,7 @@ public class DoUpdateVfModule extends VfModuleBase {
logger.debug("workflowException: " + workflowException)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
logger.debug("SDNCResponse: " + response)
@@ -1041,8 +1041,7 @@ public class DoUpdateVfModule extends VfModuleBase {
}
}
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
@@ -1051,7 +1050,7 @@ public class DoUpdateVfModule extends VfModuleBase {
} catch (Exception e) {
logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
'Caught exception in ' + method, "BPMN",
- ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
index 3dd5e61246..eb788a85b7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
@@ -265,8 +265,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
}
execution.setVariable("DUVAM_vfModules", vfModulesList)
} catch (Exception ex) {
- ex.printStackTrace()
- logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
logger.trace('Exited ' + method)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy
index 0b46a5a849..b12da9f959 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy
@@ -362,7 +362,7 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor {
} catch (Exception ex) {
String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - "
- logger.debug("Exception error in UpdateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage())
+ logger.debug("Exception error in UpdateNetworkInstance flow, buildErrorResponse(): {}", ex.getMessage(), ex)
falloutHandlerRequest =
"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:ns="http://org.onap/so/request/types/v1"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
index 24589a0893..2c5b6430e6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
@@ -511,7 +511,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
index f27b3d94b1..58c0ef2dcf 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
@@ -167,7 +167,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
index b6e7470834..61dd13b4e2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
@@ -446,7 +446,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
index ad2c9e155d..44e27d99cf 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
@@ -168,7 +168,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
index ca1b2ded2a..9dcee3dfb2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
@@ -302,7 +302,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
index 0da6fd26f4..43e095859e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
@@ -306,7 +306,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
logger.debug("SDNCResponse: " + response)
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
index bc6770cc81..82b61c17b5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
@@ -538,4 +538,26 @@ public class AAIUpdateTasks {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+
+ public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution){
+ try{
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE);
+
+ }catch(Exception ex){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
+
+ public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution){
+ try{
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED);
+
+ }catch(Exception ex){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java
new file mode 100644
index 0000000000..1bc7c0f574
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java
@@ -0,0 +1,130 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2019 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.bpmn.infrastructure.flowspecific.tasks;
+
+import java.util.UUID;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf;
+import org.onap.so.client.cds.beans.ConfigDeployRequestVnf;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * Get vnf related data and config Deploy
+ *
+ */
+@Component
+public class ConfigDeployVnf {
+ private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class);
+ private final static String ORIGINATOR_ID = "SO";
+ private final static String ACTION_NAME = "config-deploy";
+ private final static String MODE = "async";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIUpdateTasks aaiUpdateTask;
+
+ /**
+ * Update vnf orch status to configure in AAI
+ *
+ * @param execution
+ */
+ public void updateAAIConfigure(BuildingBlockExecution execution) {
+ aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution);
+
+ }
+ /**
+ * Getting the vnf object and set in execution object
+ *
+ * @param execution
+ *
+ *
+ */
+ public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
+
+
+ logger.info("Start preProcessAbstractCDSProcessing");
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+
+ ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
+ configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
+ configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
+
+ ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
+
+ configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
+ configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
+
+ String blueprintName = vnf.getBlueprintName();
+ String blueprintVersion = vnf.getBlueprintVersion();
+ AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
+
+ abstractCDSPropertiesBean.setBlueprintName(blueprintName);
+ abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
+ abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
+
+
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ abstractCDSPropertiesBean.setOriginatorId( ORIGINATOR_ID);
+ abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
+ abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
+ abstractCDSPropertiesBean.setActionName(ACTION_NAME);
+ abstractCDSPropertiesBean.setMode(MODE);
+
+ execution.setVariable("executionObject", abstractCDSPropertiesBean);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * Update vnf orch status to configured in AAI
+ *
+ * @param execution
+ */
+ public void updateAAIConfigured(BuildingBlockExecution execution) {
+ aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
+
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
new file mode 100644
index 0000000000..e93e216ea3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.adapter.vnf.mapper;
+
+import java.io.Serializable;
+
+public class AttributeNameValue implements Serializable {
+ private final static long serialVersionUID = -5215028275587848311L;
+
+ private String attributeName;
+ private Object attributeValue;
+
+ public AttributeNameValue(String attributeName, Object attributeValue) {
+ this.attributeName = attributeName;
+ this.attributeValue = attributeValue;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public void setAttributeName(String attributeName) {
+ this.attributeName = attributeName;
+ }
+
+ public Object getAttributeValue() {
+ return attributeValue;
+ }
+
+ public void setAttributeValue(Object attributeValue) {
+ this.attributeValue = attributeValue;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder().append("{\"attribute_name\": \"")
+ .append(attributeName.toString())
+ .append("\", \"attribute_value\": \"")
+ .append(attributeValue.toString())
+ .append("\"}").toString();
+ }
+}
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 258bea9a01..dc113e5abc 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,6 +36,7 @@ import java.util.Optional;
import javax.annotation.PostConstruct;
+import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang3.StringUtils;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
@@ -78,6 +79,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.entity.MsoRequest;
import org.onap.so.jsonpath.JsonPathUtil;
+import org.onap.so.openstack.utils.MsoMulticloudUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -94,7 +96,7 @@ public class VnfAdapterVfModuleObjectMapper {
@Autowired
protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils;
private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name");
-
+
private ObjectMapper mapper = new ObjectMapper();
private static final JsonPathUtil jsonPath = JsonPathUtil.getInstance();
private static final String SUB_INT = "subint";
@@ -110,23 +112,23 @@ public class VnfAdapterVfModuleObjectMapper {
private static final String FLOATING_IP = "_floating_ip";
private static final String FLOATING_V6_IP = "_floating_v6_ip";
private static final String UNDERSCORE = "_";
-
+
@PostConstruct
public void init () {
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
}
-
- public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
+
+ public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
-
+
createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
createVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
createVfModuleRequest.setVnfId(genericVnf.getVnfId());
- createVfModuleRequest.setVnfType(genericVnf.getVnfType());
+ createVfModuleRequest.setVnfType(genericVnf.getVnfType());
createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
@@ -134,38 +136,38 @@ public class VnfAdapterVfModuleObjectMapper {
createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
}
- VfModule baseVfModule = getBaseVfModule(genericVnf);
+ VfModule baseVfModule = getBaseVfModule(genericVnf);
if (baseVfModule != null) {
createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
}
createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
-
- createVfModuleRequest.setSkipAAI(true);
+
+ createVfModuleRequest.setSkipAAI(true);
createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
createVfModuleRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
+
+ MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
createVfModuleRequest.setMsoRequest(msoRequest);
-
+
String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
createVfModuleRequest.setMessageId(messageId);
createVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
-
+
return createVfModuleRequest;
}
-
+
private MsoRequest buildMsoRequest(RequestContext requestContext,ServiceInstance serviceInstance) {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- return msoRequest;
+ return msoRequest;
}
-
- private Map<String,Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
+
+ private Map<String,Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
-
-
+
+
GenericResourceApiVnfTopology vnfTop= mapper.readValue(sdncVnfQueryResponse, GenericResourceApiVnfTopology.class);
GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology();
@@ -181,19 +183,41 @@ public class VnfAdapterVfModuleObjectMapper {
buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, false);
buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, networkRoleMap, false);
}
-
+
+ // build the sdnc_directives from paramsMap
+ buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, paramsMap);
+ buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.USER_DIRECTIVES, requestContext.getUserParams());
+
buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule);
-
+
// Parameters received from the request should overwrite any parameters received from SDNC
paramsMap.putAll(requestContext.getUserParams());
-
+
if (vfModule.getCloudParams() != null) {
paramsMap.putAll(vfModule.getCloudParams());
}
return paramsMap;
}
-
- private void buildMandatoryParamsMap(Map<String,Object> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) {
+
+ private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, Map<String, Object> srcMap) {
+ StringBuilder directives = new StringBuilder();
+ if (srcMap.size() > 0) {
+ directives.append("{ \"attributes\": [ ");
+ int i = 0;
+ for (String attributeName : srcMap.keySet()) {
+ directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString()));
+ if (i < (srcMap.size()-1))
+ directives.append(", ");
+ i++;
+ }
+ directives.append("] }");
+ } else {
+ directives.append("{}");
+ }
+ paramsMap.put(directive, directives.toString());
+ }
+
+ private void buildMandatoryParamsMap(Map<String,Object> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) {
paramsMap.put("vnf_id", genericVnf.getVnfId());
paramsMap.put("vnf_name", genericVnf.getVnfName());
paramsMap.put("vf_module_id", vfModule.getVfModuleId());
@@ -205,26 +229,26 @@ public class VnfAdapterVfModuleObjectMapper {
Integer vfModuleIndex = vfModule.getModuleIndex();
if (vfModuleIndex != null) {
paramsMap.put("vf_module_index", vfModuleIndex.toString());
- }
+ }
}
-
- private void buildParamsMapFromVnfSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException {
+
+ private void buildParamsMapFromVnfSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException {
// Get VNF parameters from SDNC response
GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData();
buildParamsMapFromSdncParams(paramsMap, vnfParametersData);
-
+
if(!skipVnfResourceAssignments) {
- GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments();
+ GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments();
if (vnfResourceAssignments != null) {
// Availability Zones
buildAvailabilityZones(paramsMap, vnfResourceAssignments);
// VNF Networks
- buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);
+ buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);
}
}
}
-
- private void buildAvailabilityZones (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {
+
+ private void buildAvailabilityZones (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {
GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones = vnfResourceAssignments.getAvailabilityZones();
if (availabilityZones != null) {
List<String> availabilityZonesList = availabilityZones.getAvailabilityZone();
@@ -235,7 +259,7 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
private void buildVnfNetworks (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) {
GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks();
if (vnfNetworks != null) {
@@ -247,41 +271,41 @@ public class VnfAdapterVfModuleObjectMapper {
String vnfNetworkKey = networkRoleMap.get(networkRole);
if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) {
vnfNetworkKey = networkRole;
- }
-
+ }
+
String vnfNetworkNeutronIdValue = vnfNetwork.getNeutronId();
paramsMap.put(vnfNetworkKey + "_net_id", vnfNetworkNeutronIdValue);
String vnfNetworkNetNameValue = vnfNetwork.getNetworkName();
paramsMap.put(vnfNetworkKey + "_net_name", vnfNetworkNetNameValue);
String vnfNetworkNetFqdnValue = vnfNetwork.getContrailNetworkFqdn();
paramsMap.put(vnfNetworkKey + "_net_fqdn", vnfNetworkNetFqdnValue);
-
+
buildVnfNetworkSubnets(paramsMap, vnfNetwork, vnfNetworkKey);
-
+
}
}
}
}
-
+
private void buildVnfNetworkSubnets(Map<String,Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) {
String vnfNetworkString = convertToString(vnfNetwork);
Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id");
if(ipv4Ips.isPresent())
addPairToMap(paramsMap, vnfNetworkKey, SUBNET_ID, ipv4Ips.get());
-
+
Optional<String> ipv6Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv6' && @.dhcp-enabled == 'Y')].subnet-id");
if(ipv6Ips.isPresent())
addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get());
- }
+ }
- private void buildParamsMapFromVfModuleSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException {
+ private void buildParamsMapFromVfModuleSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException {
// Get VF Module parameters from SDNC response
GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters();
buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData);
-
- if(!skipVfModuleAssignments) {
+
+ if(!skipVfModuleAssignments) {
GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
- if (vfModuleAssignments != null) {
+ if (vfModuleAssignments != null) {
// VNF-VMS
GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
if (vms != null) {
@@ -289,7 +313,7 @@ public class VnfAdapterVfModuleObjectMapper {
if (vmsList != null) {
for (GenericResourceApiVmTopologyData vm : vmsList){
String key = vm.getVmType();
- buildVfModuleVmNames(paramsMap, vm, key);
+ buildVfModuleVmNames(paramsMap, vm, key);
GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
if (vmNetworks != null) {
List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
@@ -297,49 +321,49 @@ public class VnfAdapterVfModuleObjectMapper {
for(int n = 0; n < vmNetworksList.size(); n++){
GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
network.getNetworkRoleTag();
- String networkKey = network.getNetworkRole();
+ String networkKey = network.getNetworkRole();
// Floating IPs
- buildVfModuleFloatingIps(paramsMap, network, key, networkKey);
+ buildVfModuleFloatingIps(paramsMap, network, key, networkKey);
// Interface Route Prefixes
- buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);
+ buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);
// SRIOV Parameters
- buildVfModuleSriovParameters(paramsMap, network, networkKey);
+ buildVfModuleSriovParameters(paramsMap, network, networkKey);
// IPV4 and IPV6 Addresses
buildVfModuleNetworkInformation(paramsMap, network, key, networkKey);
-
+
buildVlanInformation(paramsMap, network, key, networkKey);
-
+
}
}
}
-
+
buildParamsMapFromVfModuleForHeatTemplate(paramsMap, vm);
}
- }
- }
+ }
+ }
}
}
}
-
+
protected void buildVlanInformation(Map<String, Object> paramsMap,
GenericResourceApiVmNetworkData network, String key, String networkKey) {
-
+
String networkString = convertToString(network);
String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter";
String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans";
String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans";
String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans";
-
+
if (network.getSegmentationId() != null) {
paramsMap.put(vlanFilterKey, network.getSegmentationId());
}
-
+
List<String> privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id");
List<String> publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id");
List<String> concat = new ArrayList<>(privateVlans);
concat.addAll(publicVlans);
Collection<String> guestVlans = new HashSet<>(concat);
-
+
if (!privateVlans.isEmpty()) {
paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans));
}
@@ -358,7 +382,7 @@ public class VnfAdapterVfModuleObjectMapper {
List<String> valueList = vmNames.getVmName();
if (valueList != null) {
for(int i = 0; i < valueList.size(); i++){
- String value = valueList.get(i);
+ String value = valueList.get(i);
if (i != valueList.size() - 1) {
values += value + ",";
}
@@ -371,7 +395,7 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
private void buildVfModuleFloatingIps(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps();
if (floatingIps != null) {
@@ -395,7 +419,7 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
private void buildVfModuleInterfaceRoutePrefixes(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes = network.getInterfaceRoutePrefixes();
if (interfaceRoutePrefixes != null) {
@@ -404,14 +428,14 @@ public class VnfAdapterVfModuleObjectMapper {
sbInterfaceRoutePrefixes.append("[");
if (interfaceRoutePrefixesList != null) {
for(int a = 0; a < interfaceRoutePrefixesList.size(); a++){
- String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);
+ String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);
if (a != interfaceRoutePrefixesList.size() - 1) {
sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",");
}
else {
- sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}");
+ sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}");
}
- }
+ }
sbInterfaceRoutePrefixes.append("]");
if (interfaceRoutePrefixesList.size() > 0) {
paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes", sbInterfaceRoutePrefixes.toString());
@@ -419,7 +443,7 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
private void buildVfModuleSriovParameters(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) {
// SRIOV Parameters
GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters();
@@ -430,14 +454,14 @@ public class VnfAdapterVfModuleObjectMapper {
StringBuilder sriovFilterBuf = new StringBuilder();
if (heatVlanFiltersList != null) {
for(int a = 0; a < heatVlanFiltersList.size(); a++){
- String heatVlanFilterValue = heatVlanFiltersList.get(a);
+ String heatVlanFilterValue = heatVlanFiltersList.get(a);
if (a != heatVlanFiltersList.size() - 1) {
sriovFilterBuf.append(heatVlanFilterValue).append(",");
}
else {
- sriovFilterBuf.append(heatVlanFilterValue);
+ sriovFilterBuf.append(heatVlanFilterValue);
}
- }
+ }
if (heatVlanFiltersList.size() > 0) {
paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString());
}
@@ -445,13 +469,13 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
private void buildVfModuleNetworkInformation(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
-
+
GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems = network.getNetworkInformationItems();
StringBuilder sbIpv4Ips = new StringBuilder();
StringBuilder sbIpv6Ips = new StringBuilder();
-
+
if (networkInformationItems != null) {
List<GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem> networkInformationItemList = networkInformationItems.getNetworkInformationItem();
if (networkInformationItemList != null) {
@@ -461,7 +485,7 @@ public class VnfAdapterVfModuleObjectMapper {
GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps ips = ipAddress.getNetworkIps();
if (ips != null) {
List<String> ipsList = ips.getNetworkIp();
- if (ipsList != null) {
+ if (ipsList != null) {
String ipVersion = ipAddress.getIpVersion();
for (int b = 0; b < ipsList.size(); b++) {
String ipAddressValue = ipsList.get(b);
@@ -472,7 +496,7 @@ public class VnfAdapterVfModuleObjectMapper {
else {
sbIpv4Ips.append(ipAddressValue);
}
- paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue);
+ paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue);
}
else if (ipVersion.equals("ipv6")) {
if (b != ipsList.size() - 1) {
@@ -481,11 +505,11 @@ public class VnfAdapterVfModuleObjectMapper {
else {
sbIpv6Ips.append(ipAddressValue);
}
- paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b, ipAddressValue);
- }
+ paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b, ipAddressValue);
+ }
}
paramsMap.put(key + UNDERSCORE + networkKey + "_ips", sbIpv4Ips.toString());
- paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());
+ paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());
}
}
}
@@ -493,43 +517,43 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
/*
* Build Mapping from GenericResourceApi SDNC for Heat Template so that AIC - PO gets accurate requests for vf module assignments.
* Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
* ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
- */
+ */
private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm) {
GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
-
+
if (vmNames != null) {
-
+
List<GenericResourceApiVmtopologydataVmnamesVnfcNames> vnfcNamesList = vmNames.getVnfcNames();
if (vnfcNamesList != null) {
-
+
for(int i = 0; i < vnfcNamesList.size(); i++){
-
+
GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames = vnfcNamesList.get(i);
parseVnfcNamesData(paramsMap, vnfcNames);
}
}
}
}
-
+
/*
* Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template.
- */
+ */
private void parseVnfcNamesData(Map<String,Object> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) {
-
+
if (vnfcNames != null) {
GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks();
if (vnfcNetworks != null) {
List<GenericResourceApiVnfcnetworkdataVnfcNetworkData> vnfcNetworkdataList = vnfcNetworks.getVnfcNetworkData();
-
+
if (vnfcNetworkdataList != null) {
-
+
for(int networkDataIdx = 0; networkDataIdx < vnfcNetworkdataList.size(); networkDataIdx++){
-
+
GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata = vnfcNetworkdataList.get(networkDataIdx);
parseVnfcNetworkData(paramsMap, vnfcNetworkdata, networkDataIdx);
}
@@ -537,72 +561,72 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
}
-
+
/*
* Parse VnfcNetworkData to build Mapping from GenericResourceApi SDNC for Heat Template.
* Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
* ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
- */
+ */
private void parseVnfcNetworkData(Map<String,Object> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) {
-
+
String vmTypeKey = vnfcNetworkdata.getVnfcType();
GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts();
if (vnfcPorts != null) {
- List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList = vnfcPorts.getVnfcPort();
- if (vnfcPortList != null) {
+ List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList = vnfcPorts.getVnfcPort();
+ if (vnfcPortList != null) {
for(int portIdx = 0; portIdx < vnfcPortList.size(); portIdx++){
-
+
GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort vnfcPort = vnfcPortList.get(portIdx);
GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces = vnfcPort.getVnicSubInterfaces();
-
+
String vnicSubInterfacesString = convertToString(vnicSubInterfaces);
- String networkRoleKey = vnfcPort.getCommonSubInterfaceRole();
+ String networkRoleKey = vnfcPort.getCommonSubInterfaceRole();
String subInterfaceKey = createVnfcSubInterfaceKey(vmTypeKey, networkDataIdx, networkRoleKey, portIdx);
String globalSubInterfaceKey = createGlobalVnfcSubInterfaceKey(vmTypeKey, networkRoleKey, portIdx);
-
+
buildVfModuleSubInterfacesCount(paramsMap, globalSubInterfaceKey, vnicSubInterfaces);
-
+
buildVfModuleVlanTag(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleNetworkName(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleNetworkId(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleIpV4AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleIpV6AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleFloatingIpV4HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
-
+
buildVfModuleFloatingIpV6HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
}
}
}
}
-
+
/*
* Build "count" (calculating the total number of sub-interfaces) for Heat Template
* Building Criteria : {vm-type}_subint_{network-role}_port_{index}_subintcount
* vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
* Example: fw_subint_ctrl_port_0_subintcount
- *
+ *
*/
private void buildVfModuleSubInterfacesCount(Map<String,Object> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) {
List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList = vnicSubInterfaces.getSubInterfaceNetworkData();
-
+
if ( (subInterfaceNetworkDataList != null) && !subInterfaceNetworkDataList.isEmpty() ) {
addPairToMap(paramsMap, keyPrefix, SUB_INT_COUNT, String.valueOf(subInterfaceNetworkDataList.size()));
}
}
-
+
protected String createVnfcSubInterfaceKey(String vmTypeKey, int networkDataIdx, String networkRoleKey, int portIdx) {
-
+
return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, networkDataIdx, SUB_INT, networkRoleKey, PORT, portIdx));
}
-
+
protected String createGlobalVnfcSubInterfaceKey(String vmTypeKey,String networkRoleKey, int portIdx) {
-
+
return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, SUB_INT, networkRoleKey, PORT, portIdx));
}
@@ -611,10 +635,10 @@ public class VnfAdapterVfModuleObjectMapper {
* Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_vlan_ids
* vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
* Example: fw_0_subint_ctrl_port_0_vlan_ids
- *
+ *
*/
protected void buildVfModuleVlanTag(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> vlanTagIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id");
addPairToMap(paramsMap, keyPrefix, VLAN_IDS, vlanTagIds);
@@ -624,12 +648,12 @@ public class VnfAdapterVfModuleObjectMapper {
* Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_names
* vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
* Example: fw_0_subint_ctrl_port_0_net_names
- *
+ *
*/
protected void buildVfModuleNetworkName(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> neworkNames = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name");
-
+
addPairToMap(paramsMap, keyPrefix, NET_NAMES, neworkNames);
}
@@ -638,25 +662,25 @@ public class VnfAdapterVfModuleObjectMapper {
* Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_ids
* vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
* Example: fw_0_subint_ctrl_port_0_net_ids
- *
+ *
*/
protected void buildVfModuleNetworkId(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> neworkIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id");
-
+
addPairToMap(paramsMap, keyPrefix, NET_IDS, neworkIds);
}
-
+
/*
* Build ip_address for V4 for Heat Template
- * Building Criteria :
+ * Building Criteria :
* {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4
* key = vm-type, networkRoleKey = NetWork-Role
*/
protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]");
-
+
addPairToMap(paramsMap, keyPrefix, IP, ipv4Ips);
for (int i = 0; i < ipv4Ips.size(); i++) {
@@ -664,15 +688,15 @@ public class VnfAdapterVfModuleObjectMapper {
}
}
-
+
/*
* Build ip_address for Heat Template
- * Building Criteria :
+ * Building Criteria :
* {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6
* key = vm-type, networkRoleKey = NetWork-Role
*/
protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]");
addPairToMap(paramsMap, keyPrefix, V6_IP, ipv6Ips);
@@ -681,14 +705,14 @@ public class VnfAdapterVfModuleObjectMapper {
addPairToMap(paramsMap, keyPrefix, V6_IP + UNDERSCORE + i, ipv6Ips.get(i));
}
}
-
+
/*
* Build floatingip_address for Heat Template
- * Building Criteria :
+ * Building Criteria :
* {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4
*/
protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]");
if (!floatingV4.isEmpty()) {
@@ -697,35 +721,35 @@ public class VnfAdapterVfModuleObjectMapper {
addPairToMap(paramsMap, keyPrefix, FLOATING_IP, floatingV4);
}
-
+
/*
* Build floatingip_address for Heat Template
- * Building Criteria :
+ * Building Criteria :
* {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6
*/
protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
+
List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]");
-
+
if (!floatingV6.isEmpty()) {
floatingV6 = Collections.singletonList(floatingV6.get(0));
}
addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6);
}
-
+
protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) {
-
+
addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value));
}
protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) {
-
+
if (!value.isEmpty()) {
paramsMap.put(keyPrefix + key, Joiner.on(",").join(value));
}
}
-
- private void buildParamsMapFromSdncParams(Map<String,Object> paramsMap, GenericResourceApiParam parametersData) {
+
+ private void buildParamsMapFromSdncParams(Map<String,Object> paramsMap, GenericResourceApiParam parametersData) {
if (parametersData != null) {
List<GenericResourceApiParamParam> paramsList = parametersData.getParam();
if (paramsList != null) {
@@ -736,20 +760,20 @@ public class VnfAdapterVfModuleObjectMapper {
String parameterValue = param.getValue();
paramsMap.put(parameterName, parameterValue);
}
- }
+ }
}
- }
+ }
}
-
+
private Map<String,String> buildNetworkRoleMap(GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology) throws JsonParseException, JsonMappingException, IOException {
- Map<String, String> networkRoleMap = new HashMap<>();
+ Map<String, String> networkRoleMap = new HashMap<>();
GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
- if (vfModuleAssignments != null) {
+ if (vfModuleAssignments != null) {
GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
if (vms != null) {
List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
if (vmsList != null) {
- for (GenericResourceApiVmTopologyData vm : vmsList){
+ for (GenericResourceApiVmTopologyData vm : vmsList){
GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
if (vmNetworks != null) {
List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
@@ -771,8 +795,8 @@ public class VnfAdapterVfModuleObjectMapper {
}
return networkRoleMap;
}
-
- public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext,CloudRegion cloudRegion,
+
+ public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext,CloudRegion cloudRegion,
ServiceInstance serviceInstance, GenericVnf genericVnf,
VfModule vfModule) throws IOException {
DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
@@ -787,20 +811,20 @@ public class VnfAdapterVfModuleObjectMapper {
{
deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName());
}
-
+
deleteVfModuleRequest.setSkipAAI(true);
setIdAndUrl(deleteVfModuleRequest);
- MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
+ MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
deleteVfModuleRequest.setMsoRequest(msoRequest);
return deleteVfModuleRequest;
}
-
+
protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException{
String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
- deleteVfModuleRequest.setMessageId(messageId);
+ deleteVfModuleRequest.setMessageId(messageId);
deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
}
-
+
private String convertToString(Object obj) {
String json;
try {
@@ -808,10 +832,10 @@ public class VnfAdapterVfModuleObjectMapper {
} catch (JsonProcessingException e) {
json = "{}";
}
-
+
return json;
}
-
+
private VfModule getBaseVfModule(GenericVnf genericVnf) {
List<VfModule> vfModules = genericVnf.getVfModules();
VfModule baseVfModule = null;
@@ -819,7 +843,7 @@ public class VnfAdapterVfModuleObjectMapper {
for(int i = 0; i < vfModules.size(); i++) {
if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
baseVfModule = vfModules.get(i);
- break;
+ break;
}
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index 78d08aa1f1..05af58040a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -655,4 +655,17 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
aaiUpdateTasks.updateManagementV6AddressVnf(execution);
verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
}
+
+ @Test
+ public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution);
+ }
+ @Test
+ public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
new file mode 100644
index 0000000000..e5aa702dad
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
@@ -0,0 +1,97 @@
+
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2019 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.bpmn.infrastructure.flowspecific.tasks;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+
+public class ConfigDeployVnfTest extends BaseTaskTest {
+
+ @InjectMocks
+ private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
+ @Mock
+ AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
+
+
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ serviceInstance = setServiceInstance();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
+ }
+
+
+
+ @Test
+ public void preProcessAbstractCDSProcessingTest() throws Exception {
+
+ configDeployVnf.preProcessAbstractCDSProcessing(execution);
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfigureTaskTest() throws Exception {
+
+ configDeployVnf.updateAAIConfigure(execution);
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfiguredTaskTest() throws Exception {
+ configDeployVnf.updateAAIConfigured(execution);
+ assertTrue(true);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json
index c4e7237511..f655e9aa13 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json
@@ -64,6 +64,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json
index 0132068fe4..3387b6d87e 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json
@@ -63,6 +63,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json
index 90326e33eb..8721bdc865 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json
@@ -60,6 +60,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json
index 2f943a67bc..04f64790c4 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json
@@ -62,6 +62,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId4\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json
index 4c50ad1187..1b57fcd33c 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json
@@ -62,6 +62,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{}"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json
index bd06f5f86f..a13740cf80 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json
@@ -63,6 +63,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json
index d80c739916..5468e21ee3 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json
@@ -29,6 +29,8 @@
"vf_module_name": "vfModuleName",
"vnf_id": "vnfId",
"vnf_name": "vnfName",
- "workload_context": "workloadContext"
+ "workload_context": "workloadContext",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json
index 293c6c21ed..dd8e62c0a0 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json
@@ -60,6 +60,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json
index fd3b0a3d58..d44b1924cc 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json
@@ -62,6 +62,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json
index dff1ccf7b0..0d103926b9 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json
@@ -64,6 +64,8 @@
"vmType0_vmNetworkRole0_v6_ips": "ip2,ip3",
"paramOne": "paramOneValue",
"paramTwo": "paramTwoValue",
- "paramThree": "paramThreeValue"
+ "paramThree": "paramThreeValue",
+ "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }",
+ "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }"
}
-} \ No newline at end of file
+}
diff --git a/common/pom.xml b/common/pom.xml
index 883d48c21c..2a9f88f6d2 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -15,7 +15,7 @@
<grpc.version>1.17.1</grpc.version>
<protobuf.version>3.6.1</protobuf.version>
<grpc.netty.version>4.1.30.Final</grpc.netty.version>
- <ccsdk.version>0.4.1-SNAPSHOT</ccsdk.version>
+ <ccsdk.version>0.4.2-SNAPSHOT</ccsdk.version>
</properties>
<dependencies>
@@ -143,7 +143,7 @@
<!-- CDS dependencies -->
<dependency>
- <groupId>org.onap.ccsdk.apps.components</groupId>
+ <groupId>org.onap.ccsdk.cds.components</groupId>
<artifactId>proto-definition</artifactId>
<version>${ccsdk.version}</version>
</dependency>
diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
index 34ad6ef758..0633ae74c9 100644
--- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
+++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@@ -39,6 +40,7 @@ public class RestTemplateConfig {
private HttpComponentsClientConfiguration httpComponentsClientConfiguration;
@Bean
+ @Primary
public RestTemplate restTemplate() {
final RestTemplate restTemplate = new RestTemplate();
restTemplate
diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java
index 756c26ddef..9b2fd3fdb0 100644
--- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java
+++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java
@@ -25,7 +25,7 @@ import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.internal.PickFirstLoadBalancerProvider;
import io.grpc.netty.NettyChannelBuilder;
import java.util.concurrent.CountDownLatch;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.so.client.PreconditionFailedException;
import org.onap.so.client.RestPropertiesLoader;
import org.slf4j.Logger;
diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
index 1791be2991..4b86493f79 100644
--- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
+++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
@@ -23,11 +23,11 @@ package org.onap.so.client.cds;
import io.grpc.ManagedChannel;
import io.grpc.stub.StreamObserver;
import java.util.concurrent.CountDownLatch;
-import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java
index 8c92a5810c..ed7b4e51ba 100644
--- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java
+++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingListener.java
@@ -20,7 +20,7 @@
package org.onap.so.client.cds;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
public interface CDSProcessingListener {
diff --git a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java
index 135277fa47..f6bf21458d 100644
--- a/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java
+++ b/common/src/test/java/org/onap/so/client/cds/CDSProcessingClientTest.java
@@ -42,10 +42,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
-import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
@RunWith(JUnit4.class)
public class CDSProcessingClientTest {
diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java b/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java
index 977f1d41be..ce515e162e 100644
--- a/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java
+++ b/common/src/test/java/org/onap/so/client/cds/TestCDSProcessingListener.java
@@ -21,7 +21,7 @@
package org.onap.so.client.cds;
import io.grpc.Status;
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java
index b0e67090ff..636f92835f 100644
--- a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java
+++ b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java
@@ -15,7 +15,6 @@
*/
package org.onap.so.client.cds;
-import java.net.MalformedURLException;
import java.net.URL;
public class TestCDSPropertiesImpl implements CDSProperties {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
new file mode 100644
index 0000000000..1580c9fb34
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
@@ -0,0 +1,206 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.apihandlerinfra;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.HashMap;
+
+@Component
+@Path("/onap/so/infra/instanceManagement")
+@Api(value="/onap/so/infra/instanceManagement",description="Infrastructure API Requests for Instance Management")
+public class InstanceManagement {
+
+ private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class);
+ private static String uriPrefix = "/instanceManagement/";
+ private static final String SAVE_TO_DB = "save instance to db";
+
+ @Autowired
+ private RequestsDbClient infraActiveRequestsClient;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private RequestHandlerUtils requestHandlerUtils;
+
+ @POST
+ @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/workflows/{workflowUuid}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Execute custom workflow",response=Response.class)
+ @Transactional
+ public Response executeCustomWorkflow(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("workflowUuid", workflowUuid);
+ return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestContext);
+ }
+
+ private Response processCustomWorkflowRequest(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, ContainerRequestContext requestContext) throws ApiException {
+ String serviceInstanceId = null;
+ if (instanceIdMap != null) {
+ serviceInstanceId = instanceIdMap.get("serviceInstanceId");
+ }
+ Boolean aLaCarte = true;
+ long startTime = System.currentTimeMillis ();
+ ServiceInstancesRequest sir = null;
+ String apiVersion = version.substring(1);
+
+ String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix);
+
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
+
+ try {
+ requestHandlerUtils.validateHeaders(requestContext);
+ } catch (ValidationException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+
+ int requestVersion = Integer.parseInt(version.substring(1));
+ String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
+
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){
+ currentActiveReq.setVnfType(vnfType);
+ }
+
+ InfraActiveRequests dup = null;
+ boolean inProgress = false;
+
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+
+ if(dup != null){
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
+ }
+
+ if (dup != null && inProgress) {
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ }
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+ Boolean isBaseVfModule = false;
+
+ String workflowUuid = null;
+ if (instanceIdMap !=null) {
+ workflowUuid = instanceIdMap.get("workflowUuid");
+ }
+
+ RecipeLookupResult recipeLookupResult = getCustomWorkflowUri(workflowUuid);
+ String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true);
+
+ serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
+ String vnfId = "";
+
+ if(sir.getVnfInstanceId () != null){
+ vnfId = sir.getVnfInstanceId ();
+ }
+
+ try{
+ infraActiveRequestsClient.save(currentActiveReq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setVnfId(vnfId)
+ .setServiceType(serviceInstanceType)
+ .setVnfType(vnfType)
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ }
+
+ private RecipeLookupResult getCustomWorkflowUri(String workflowUuid) {
+
+ RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/VnfInPlaceUpdate", 180);
+ return recipeLookupResult;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
index 182e398461..434b9e9364 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
@@ -62,6 +62,8 @@ public class JerseyConfiguration extends ResourceConfig {
register(RuntimeExceptionMapper.class);
register(RequestUriFilter.class);
register(E2EServiceInstances.class);
+ register(WorkflowSpecificationsHandler.class);
+ register(InstanceManagement.class);
// this registration seems to be needed to get predictable
// execution behavior for the above JSON Exception Mappers
register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
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 de7d26379c..dc8e6b6958 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
@@ -50,6 +50,7 @@ import org.onap.so.apihandlerinfra.validation.MembersValidation;
import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
+import org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation;
import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation;
import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation;
import org.onap.so.apihandlerinfra.validation.ModelInfoValidation;
@@ -175,7 +176,14 @@ public class MsoRequest {
rules.add(new InstanceIdMapValidation());
- if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){
+ String workflowUuid = null;
+ if (instanceIdMap != null) {
+ workflowUuid = instanceIdMap.get("workflowUuid");
+ }
+
+ if (workflowUuid != null) {
+ rules.add(new CustomWorkflowValidation());
+ }else if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){
rules.add(new InPlaceSoftwareUpdateValidation());
}else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){
rules.add(new ApplyUpdatedConfigValidation());
@@ -361,7 +369,9 @@ public class MsoRequest {
aq.setInstanceGroupName(requestInfo.getInstanceName());
}
if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
- aq.setVnfName(requestInfo.getInstanceName());
+ if (requestInfo != null) {
+ aq.setVnfName(requestInfo.getInstanceName());
+ }
if (null != servInsReq.getRequestDetails()) {
RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
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
new file mode 100644
index 0000000000..c02b40aeca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -0,0 +1,567 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.apihandlerinfra;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.camundabeans.CamundaResponse;
+import org.onap.so.apihandler.common.CommonConstants;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.onap.so.utils.CryptoUtils;
+import org.onap.so.utils.UUIDChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+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.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
+
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+@Component
+public class RequestHandlerUtils {
+
+ private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class);
+
+ private static final String SAVE_TO_DB = "save instance to db";
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RequestClientFactory reqClientFactory;
+
+ @Autowired
+ private RequestsDbClient infraActiveRequestsClient;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ try {
+ requestClient = reqClientFactory.getRequestClient (orchestrationUri);
+ response = requestClient.post(requestClientParameter);
+ } catch (Exception e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ String url = requestClient != null ? requestClient.getUrl() : "";
+ ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ if (response == null) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ ResponseHandler respHandler = null;
+ int bpelStatus = 500;
+ try {
+ respHandler = new ResponseHandler (response, requestClient.getType ());
+ bpelStatus = respHandler.getStatus ();
+ } catch (ApiException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ // BPEL accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ ServiceInstancesResponse jsonResponse;
+ CamundaResponse camundaResp = respHandler.getResponse();
+
+ if("Success".equalsIgnoreCase(camundaResp.getMessage())) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
+ jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
+ if(selfLinkUrl.isPresent()){
+ jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
+ } else {
+ jsonResponse.getRequestReferences().setRequestSelfLink(null);
+ }
+ } catch (IOException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
+ }
+ }
+
+ List<String> variables = new ArrayList<>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody ();
+ if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+ BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
+
+ throw bpmnException;
+ } else {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+
+
+ BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
+
+ throw servException;
+ }
+ }
+
+ public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage (errorMessage);
+ aq.setProgress(new Long(100));
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
+ aq.setEndTime (endTimeStamp);
+ try{
+ infraActiveRequestsClient.save(aq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ }
+ }
+
+ public String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
+ if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
+ return (ModelType.vnf.name());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ return(ModelType.instanceGroup.toString());
+ }else{
+ String requestScope;
+ if(sir.getRequestDetails().getModelInfo().getModelType() == null){
+ requestScope = requestScopeFromUri(requestUri);
+ }else{
+ requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ }
+ return requestScope;
+ }
+ }
+
+
+ public void validateHeaders(ContainerRequestContext context) throws ValidationException{
+ MultivaluedMap<String, String> headers = context.getHeaders();
+ if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
+ throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
+ }
+ if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
+ throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
+ }
+ if(!headers.containsKey(REQUESTOR_ID)){
+ throw new ValidationException(REQUESTOR_ID + " header", true);
+ }
+ }
+
+ public String getRequestUri(ContainerRequestContext context, String uriPrefix){
+ String requestUri = context.getUriInfo().getPath();
+ String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri);
+ MDC.put(LogConstants.HTTP_URL, httpUrl);
+ requestUri = requestUri.substring(requestUri.indexOf(uriPrefix) + uriPrefix.length());
+ return requestUri;
+ }
+
+ public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
+ InfraActiveRequests dup = null;
+ try {
+ if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){
+ dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
+ }
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage());
+ throw requestDbFailureException;
+ }
+ return dup;
+ }
+
+ public boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{
+ String requestId = duplicateRecord.getRequestId();
+ String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
+ String targetUrl = env.getProperty("mso.camundaURL") + path;
+ HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
+ try{
+ response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){});
+ }catch(HttpStatusCodeException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
+ throw contactCamundaException;
+ }
+ if(response.getBody().isEmpty()){
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ for(HistoricProcessInstance instance : response.getBody()){
+ if(instance.getState().equals("ACTIVE")){
+ return true;
+ }else{
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ }
+ return false;
+ }
+
+ protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
+ 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(auth, msoKey);
+ if(userCredentials != null) {
+ headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
+ }
+ } catch(GeneralSecurityException e) {
+ logger.error("Security exception", e);
+ }
+ return headers;
+ }
+
+ public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
+ ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+
+ } catch (IOException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+ ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ String requestScope = requestScopeFromUri(requestUri);
+
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
+
+ throw validateException;
+ }
+ }
+
+ public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
+ String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException {
+ int reqVersion = Integer.parseInt(version.substring(1));
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
+ } catch (Exception e) {
+ logger.error("failed to parse request", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ }
+
+ public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
+ String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
+
+ String instance = null;
+ if(instanceName != null){
+ instance = instanceName;
+ }else{
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+ DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
+
+ throw dupException;
+ }
+
+ public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
+ String requestId = null;
+ if (requestContext.getProperty("requestId") != null) {
+ requestId = requestContext.getProperty("requestId").toString();
+ }
+ if (UUIDChecker.isValidUUID(requestId)) {
+ return requestId;
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+
+ public void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) {
+ if(StringUtils.isNotBlank(instanceId)) {
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setServiceInstanceId(instanceId);
+ } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVnfId(instanceId);
+ } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVfModuleId(instanceId);
+ } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVolumeGroupId(instanceId);
+ } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setNetworkId(instanceId);
+ } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setConfigurationId(instanceId);
+ }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
+ currentActiveReq.setInstanceGroupId(instanceId);
+ }
+ } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
+ if(instanceIdMap.get("serviceInstanceId") != null){
+ currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
+ }
+ if(instanceIdMap.get("vnfInstanceId") != null){
+ currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId"));
+ }
+ if(instanceIdMap.get("vfModuleInstanceId") != null){
+ currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId"));
+ }
+ if(instanceIdMap.get("volumeGroupInstanceId") != null){
+ currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId"));
+ }
+ if(instanceIdMap.get("networkInstanceId") != null){
+ currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId"));
+ }
+ if(instanceIdMap.get("configurationInstanceId") != null){
+ currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
+ }
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
+ currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
+ }
+ }
+ }
+
+ public String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ if(msoRawRequest != null){
+ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
+ if( serviceInstRequest != null &&
+ serviceInstRequest.getRequestDetails() != null &&
+ serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
+ if( !isAlaCarte && Action.createInstance.equals(action)) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload());
+ }
+
+ logger.debug("Value as string: {}", mapper.writeValueAsString(sir));
+ return mapper.writeValueAsString(sir);
+ }
+ return null;
+ }
+
+ public Optional<String> retrieveModelName(RequestParameters requestParams) {
+ String requestTestApi = null;
+ TestApi testApi = null;
+
+ if (requestParams != null) {
+ requestTestApi = requestParams.getTestApi();
+ }
+
+ if (requestTestApi == null) {
+ if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) {
+ requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API);
+ } else {
+ requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API);
+ }
+ }
+
+ try {
+ testApi = TestApi.valueOf(requestTestApi);
+ return Optional.of(testApi.getModelName());
+ } catch (Exception e) {
+ logger.warn("Catching the exception on the valueOf enum call and continuing", e);
+ throw new IllegalArgumentException("Invalid TestApi is provided", e);
+ }
+ }
+
+ public String getDefaultModel(ServiceInstancesRequest sir) {
+ String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT";
+ Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters());
+ if (oModelName.isPresent()) {
+ defaultModel = oModelName.get();
+ }
+ return defaultModel;
+ }
+
+ public String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){
+ String serviceType = null;
+ if(requestScope.equalsIgnoreCase(ModelType.service.toString())){
+ String defaultServiceModelName = getDefaultModel(sir);
+ org.onap.so.db.catalog.beans.Service serviceRecord;
+ if(aLaCarteFlag){
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }else{
+ serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId());
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }else{
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }
+ }
+ }else{
+ serviceType = msoRequest.getServiceInstanceType(sir, requestScope);
+ }
+ return serviceType;
+ }
+
+ protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){
+ if(sir.getServiceInstanceId () != null){
+ return sir.getServiceInstanceId ();
+ }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){
+ RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList();
+ if(relatedInstances != null){
+ for(RelatedInstanceList relatedInstanceList : relatedInstances){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType() == ModelType.service){
+ return relatedInstance.getInstanceId();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private String requestScopeFromUri(String requestUri){
+ String requestScope;
+ if(requestUri.contains(ModelType.network.name())){
+ requestScope = ModelType.network.name();
+ }else if(requestUri.contains(ModelType.vfModule.name())){
+ requestScope = ModelType.vfModule.name();
+ }else if(requestUri.contains(ModelType.volumeGroup.name())){
+ requestScope = ModelType.volumeGroup.name();
+ }else if(requestUri.contains(ModelType.configuration.name())){
+ requestScope = ModelType.configuration.name();
+ }else if(requestUri.contains(ModelType.vnf.name())){
+ requestScope = ModelType.vnf.name();
+ }else{
+ requestScope = ModelType.service.name();
+ }
+ return requestScope;
+ }
+
+}
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 8c5904fb21..c6a45d540c 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
@@ -23,8 +23,6 @@
package org.onap.so.apihandlerinfra;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -32,22 +30,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.apihandler.camundabeans.CamundaResponse;
import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
-import org.onap.so.apihandler.common.ResponseBuilder;
-import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
-import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
-import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
-import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
@@ -67,7 +54,6 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.LogConstants;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -83,23 +69,11 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.onap.so.serviceinstancebeans.VfModules;
import org.onap.so.serviceinstancebeans.Vnfs;
-import org.onap.so.utils.CryptoUtils;
-import org.onap.so.utils.UUIDChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ParameterizedTypeReference;
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.stereotype.Component;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.web.client.RestTemplate;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
-import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
@@ -112,21 +86,14 @@ import javax.ws.rs.Produces;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
-import java.net.URL;
-import java.security.GeneralSecurityException;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
-
@Component
@Path("/onap/so/infra/serviceInstantiation")
@Api(value="/onap/so/infra/serviceInstantiation",description="Infrastructure API Requests for Service Instances")
@@ -135,28 +102,23 @@ public class ServiceInstances {
private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
private static String NAME = "name";
private static String VALUE = "value";
+ private static String uriPrefix = "/serviceInstantiation/";
private static final String SAVE_TO_DB = "save instance to db";
@Autowired
private Environment env;
@Autowired
- private RequestClientFactory reqClientFactory;
-
- @Autowired
private CatalogDbClient catalogDbClient;
@Autowired
private RequestsDbClient infraActiveRequestsClient;
@Autowired
- private ResponseBuilder builder;
-
- @Autowired
private MsoRequest msoRequest;
@Autowired
- private RestTemplate restTemplate;
+ private RequestHandlerUtils requestHandlerUtils;
@POST
@Path("/{version:[vV][5-7]}/serviceInstances")
@@ -165,8 +127,8 @@ public class ServiceInstances {
@ApiOperation(value="Create a Service Instance on a version provided",response=Response.class)
@Transactional
public Response createServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -176,10 +138,10 @@ public class ServiceInstances {
@ApiOperation(value="Activate provided Service Instance",response=Response.class)
@Transactional
public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -189,10 +151,10 @@ public class ServiceInstances {
@ApiOperation(value="Deactivate provided Service Instance",response=Response.class)
@Transactional
public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -202,10 +164,10 @@ public class ServiceInstances {
@ApiOperation(value="Delete provided Service Instance",response=Response.class)
@Transactional
public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -215,8 +177,8 @@ public class ServiceInstances {
@ApiOperation(value="Assign Service Instance", response=Response.class)
@Transactional
public Response assignServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.assignInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.assignInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -226,10 +188,10 @@ public class ServiceInstances {
@ApiOperation(value="Unassign Service Instance", response=Response.class)
@Transactional
public Response unassignServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -239,10 +201,10 @@ public class ServiceInstances {
@ApiOperation(value="Create Port Mirroring Configuration",response=Response.class)
@Transactional
public Response createPortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -253,11 +215,11 @@ public class ServiceInstances {
@Transactional
public Response deletePortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -268,11 +230,11 @@ public class ServiceInstances {
@Transactional
public Response enablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -283,11 +245,11 @@ public class ServiceInstances {
@Transactional
public Response disablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -298,11 +260,11 @@ public class ServiceInstances {
@Transactional
public Response activatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -313,11 +275,11 @@ public class ServiceInstances {
@Transactional
public Response deactivatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -327,10 +289,10 @@ public class ServiceInstances {
@ApiOperation(value="Add Relationships to a Service Instance",response=Response.class)
@Transactional
public Response addRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -340,10 +302,10 @@ public class ServiceInstances {
@ApiOperation(value="Remove Relationships from Service Instance",response=Response.class)
@Transactional
public Response removeRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -353,10 +315,10 @@ public class ServiceInstances {
@ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class)
@Transactional
public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -367,11 +329,11 @@ public class ServiceInstances {
@Transactional
public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -382,11 +344,11 @@ public class ServiceInstances {
@Transactional
public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -396,11 +358,11 @@ public class ServiceInstances {
@ApiOperation(value="Apply updated configuration",response=Response.class)
public Response applyUpdatedConfig(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -410,11 +372,11 @@ public class ServiceInstances {
@ApiOperation(value="Recreate VNF Instance",response=Response.class)
public Response recreateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@@ -426,11 +388,11 @@ public class ServiceInstances {
@Transactional
public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -441,11 +403,11 @@ public class ServiceInstances {
@Transactional
public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -457,12 +419,12 @@ public class ServiceInstances {
public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -474,12 +436,12 @@ public class ServiceInstances {
public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -490,11 +452,11 @@ public class ServiceInstances {
@Transactional
public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -506,12 +468,12 @@ public class ServiceInstances {
public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -522,12 +484,12 @@ public class ServiceInstances {
@Transactional
public Response deactivateAndCloudDeleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
return response;
}
@@ -539,11 +501,11 @@ public class ServiceInstances {
@Transactional
public Response scaleOutVfModule(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@@ -555,11 +517,11 @@ public class ServiceInstances {
@Transactional
public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -571,12 +533,12 @@ public class ServiceInstances {
public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -588,12 +550,12 @@ public class ServiceInstances {
public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -603,10 +565,10 @@ public class ServiceInstances {
@ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class)
@Transactional
public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -617,11 +579,11 @@ public class ServiceInstances {
@Transactional
public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -632,11 +594,11 @@ public class ServiceInstances {
@Transactional
public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -646,8 +608,8 @@ public class ServiceInstances {
@ApiOperation(value="Create instanceGroups",response=Response.class)
@Transactional
public Response createInstanceGroups(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -657,10 +619,10 @@ public class ServiceInstances {
@ApiOperation(value="Delete instanceGroup",response=Response.class)
@Transactional
public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext);
+ return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix), requestContext);
}
@POST
@@ -670,10 +632,10 @@ public class ServiceInstances {
@ApiOperation(value="Add instanceGroup members",response=Response.class)
@Transactional
public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -683,33 +645,12 @@ public class ServiceInstances {
@ApiOperation(value="Remove instanceGroup members",response=Response.class)
@Transactional
public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
- }
-
- public String getRequestUri(ContainerRequestContext context){
- String requestUri = context.getUriInfo().getPath();
- String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri);
- MDC.put(LogConstants.HTTP_URL, httpUrl);
- requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
- return requestUri;
+ return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
- public void validateHeaders(ContainerRequestContext context) throws ValidationException{
- MultivaluedMap<String, String> headers = context.getHeaders();
- if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
- throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
- }
- if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
- throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
- }
- if(!headers.containsKey(REQUESTOR_ID)){
- throw new ValidationException(REQUESTOR_ID + " header", true);
- }
- }
-
public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
Boolean aLaCarte = null;
@@ -717,17 +658,20 @@ public class ServiceInstances {
ServiceInstancesRequest sir = null;
String apiVersion = version.substring(1);
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
- String requestScope = deriveRequestScope(action, sir, requestUri);
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
if(sir.getRequestDetails().getRequestParameters() != null){
aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
}
- parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
int requestVersion = Integer.parseInt(version.substring(1));
- String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String instanceName = null;
+ if (sir.getRequestDetails().getRequestInfo() != null) {
+ instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ }
boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir);
String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
String networkType = msoRequest.getNetworkType(sir,requestScope);
@@ -743,14 +687,14 @@ public class ServiceInstances {
InfraActiveRequests dup = null;
boolean inProgress = false;
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -760,9 +704,9 @@ public class ServiceInstances {
serviceResponse.setRequestReferences(referencesResponse);
Boolean isBaseVfModule = false;
-
+
RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
- String serviceInstanceType = getServiceType(requestScope, sir, alaCarteFlag);
+ String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag);
ModelType modelType;
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
@@ -803,14 +747,14 @@ public class ServiceInstances {
String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB";
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
throw vfModuleException;
}
}
- serviceInstanceId = setServiceInstanceId(requestScope, sir);
+ serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
String vnfId = "";
String vfModuleId = "";
String volumeGroupId = "";
@@ -870,7 +814,7 @@ public class ServiceInstances {
.setVnfType(vnfType)
.setVfModuleType(vfModuleType)
.setNetworkType(networkType)
- .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
.setApiVersion(apiVersion)
.setALaCarte(aLaCarte)
.setRequestUri(requestUri)
@@ -880,7 +824,7 @@ public class ServiceInstances {
throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
.errorInfo(errorLoggerInfo).build();
}
- return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID);
@@ -892,27 +836,27 @@ public class ServiceInstances {
String requestScope = ModelType.instanceGroup.toString();
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, null, requestScope);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
try {
- validateHeaders(requestContext);
+ requestHandlerUtils.validateHeaders(requestContext);
} catch (ValidationException e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
- InfraActiveRequests dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+ InfraActiveRequests dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
boolean inProgress = false;
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -944,7 +888,7 @@ public class ServiceInstances {
.setRequestUri(requestUri)
.setInstanceGroupId(instanceGroupId).build();
- return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
private String getPnfCorrelationId(ServiceInstancesRequest sir) {
@@ -953,315 +897,7 @@ public class ServiceInstances {
.map(RequestDetails::getRequestParameters)
.map(parameters -> parameters.getUserParamValue("pnfId"))
.orElse("");
- }
-
- private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
- if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
- return (ModelType.vnf.name());
- }else if(action == Action.addMembers || action == Action.removeMembers){
- return(ModelType.instanceGroup.toString());
- }else{
- String requestScope;
- if(sir.getRequestDetails().getModelInfo().getModelType() == null){
- requestScope = requestScopeFromUri(requestUri);
- }else{
- requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
- }
- return requestScope;
- }
- }
- private String requestScopeFromUri(String requestUri){
- String requestScope;
- if(requestUri.contains(ModelType.network.name())){
- requestScope = ModelType.network.name();
- }else if(requestUri.contains(ModelType.vfModule.name())){
- requestScope = ModelType.vfModule.name();
- }else if(requestUri.contains(ModelType.volumeGroup.name())){
- requestScope = ModelType.volumeGroup.name();
- }else if(requestUri.contains(ModelType.configuration.name())){
- requestScope = ModelType.configuration.name();
- }else if(requestUri.contains(ModelType.vnf.name())){
- requestScope = ModelType.vnf.name();
- }else{
- requestScope = ModelType.service.name();
- }
- return requestScope;
- }
- private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
- RequestClient requestClient = null;
- HttpResponse response = null;
- try {
- requestClient = reqClientFactory.getRequestClient (orchestrationUri);
- response = requestClient.post(requestClientParameter);
- } catch (Exception e) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- String url = requestClient != null ? requestClient.getUrl() : "";
- ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
-
- throw clientException;
- }
-
- if (response == null) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
-
- throw clientException;
- }
-
- ResponseHandler respHandler = null;
- int bpelStatus = 500;
- try {
- respHandler = new ResponseHandler (response, requestClient.getType ());
- bpelStatus = respHandler.getStatus ();
- } catch (ApiException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
- }
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- ServiceInstancesResponse jsonResponse;
- CamundaResponse camundaResp = respHandler.getResponse();
-
- if("Success".equalsIgnoreCase(camundaResp.getMessage())) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
- jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
- Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
- if(selfLinkUrl.isPresent()){
- jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
- } else {
- jsonResponse.getRequestReferences().setRequestSelfLink(null);
- }
- } catch (IOException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
- }
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
- }
- }
-
- List<String> variables = new ArrayList<>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getResponseBody ();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
- BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
-
- throw bpmnException;
- } else {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
-
-
- BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
-
- throw servException;
- }
- }
-
- private void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) {
- if(StringUtils.isNotBlank(instanceId)) {
- if(ModelType.service.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setServiceInstanceId(instanceId);
- } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVnfId(instanceId);
- } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVfModuleId(instanceId);
- } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVolumeGroupId(instanceId);
- } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setNetworkId(instanceId);
- } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setConfigurationId(instanceId);
- }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
- currentActiveReq.setInstanceGroupId(instanceId);
- }
- } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
- if(instanceIdMap.get("serviceInstanceId") != null){
- currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
- }
- if(instanceIdMap.get("vnfInstanceId") != null){
- currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId"));
- }
- if(instanceIdMap.get("vfModuleInstanceId") != null){
- currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId"));
- }
- if(instanceIdMap.get("volumeGroupInstanceId") != null){
- currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId"));
- }
- if(instanceIdMap.get("networkInstanceId") != null){
- currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId"));
- }
- if(instanceIdMap.get("configurationInstanceId") != null){
- currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
- }
- if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
- currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
- }
- }
- }
-
- protected String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- if(msoRawRequest != null){
- ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
- if( serviceInstRequest != null &&
- serviceInstRequest.getRequestDetails() != null &&
- serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
- if( !isAlaCarte && Action.createInstance.equals(action)) {
- sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
- sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
- }
- sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload());
- }
-
- logger.debug("Value as string: {}", mapper.writeValueAsString(sir));
- return mapper.writeValueAsString(sir);
- }
- return null;
- }
-
- private void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
- String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
-
- // Found the duplicate record. Return the appropriate error.
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(requestScope + "InstanceId");
- }
- //List<String> variables = new ArrayList<String>();
- //variables.add(dup.getRequestStatus());
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
-
- DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
-
- throw dupException;
- }
-
- private InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
- MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
- InfraActiveRequests dup = null;
- try {
- if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){
- dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- }
- } catch (Exception e) {
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage());
- throw requestDbFailureException;
- }
- return dup;
- }
- protected boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{
- String requestId = duplicateRecord.getRequestId();
- String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
- HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
- HttpEntity<?> requestEntity = new HttpEntity<>(headers);
- ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
- try{
- response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){});
- }catch(HttpStatusCodeException e){
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
- throw contactCamundaException;
- }
- if(response.getBody().isEmpty()){
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- for(HistoricProcessInstance instance : response.getBody()){
- if(instance.getState().equals("ACTIVE")){
- return true;
- }else{
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- }
- return false;
- }
- protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
- 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(auth, msoKey);
- if(userCredentials != null) {
- headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
- }
- } catch(GeneralSecurityException e) {
- logger.error("Security exception", e);
- }
- return headers;
- }
-
- private ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
- ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
- try{
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
-
- } catch (IOException e) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
- ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- String requestScope = requestScopeFromUri(requestUri);
-
- msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
-
- throw validateException;
- }
- }
-
- private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
- String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException {
- int reqVersion = Integer.parseInt(version.substring(1));
- try {
- msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
- } catch (Exception e) {
- logger.error("failed to parse request", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
-
- throw validateException;
- }
- }
+ }
private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag,
InfraActiveRequests currentActiveReq) throws ApiException {
@@ -1284,7 +920,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1299,7 +935,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1313,7 +949,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1328,7 +964,7 @@ public class ServiceInstances {
RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
throw recipeNotFoundExceptionException;
}
return recipeLookupResult;
@@ -1338,7 +974,7 @@ public class ServiceInstances {
// SERVICE REQUEST
// Construct the default service name
// TODO need to make this a configurable property
- String defaultServiceModelName = getDefaultModel(servInstReq);
+ String defaultServiceModelName = requestHandlerUtils.getDefaultModel(servInstReq);
RequestDetails requestDetails = servInstReq.getRequestDetails();
ModelInfo modelInfo = requestDetails.getModelInfo();
org.onap.so.db.catalog.beans.Service serviceRecord;
@@ -1525,7 +1161,7 @@ public class ServiceInstances {
}
Recipe recipe = null;
- String defaultSource = getDefaultModel(servInstReq);
+ String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq);
String modelCustomizationId = modelInfo.getModelCustomizationId();
String modelCustomizationName = modelInfo.getModelCustomizationName();
String relatedInstanceModelVersionId = null;
@@ -1728,7 +1364,7 @@ public class ServiceInstances {
private RecipeLookupResult getDefaultVnfUri(ServiceInstancesRequest sir, Actions action) {
- String defaultSource = getDefaultModel(sir);
+ String defaultSource = requestHandlerUtils.getDefaultModel(sir);
VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
@@ -1742,7 +1378,7 @@ public class ServiceInstances {
private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException {
- String defaultNetworkType = getDefaultModel(sir);
+ String defaultNetworkType = requestHandlerUtils.getDefaultModel(sir);
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
String modelName = modelInfo.getModelName();
@@ -1777,40 +1413,7 @@ public class ServiceInstances {
return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null;
}
- private Optional<String> retrieveModelName(RequestParameters requestParams) {
- String requestTestApi = null;
- TestApi testApi = null;
-
- if (requestParams != null) {
- requestTestApi = requestParams.getTestApi();
- }
-
- if (requestTestApi == null) {
- if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) {
- requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API);
- } else {
- requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API);
- }
- }
-
- try {
- testApi = TestApi.valueOf(requestTestApi);
- return Optional.of(testApi.getModelName());
- } catch (Exception e) {
- logger.warn("Catching the exception on the valueOf enum call and continuing", e);
- throw new IllegalArgumentException("Invalid TestApi is provided", e);
- }
- }
- private String getDefaultModel(ServiceInstancesRequest sir) {
- String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT";
- Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters());
- if (oModelName.isPresent()) {
- defaultModel = oModelName.get();
- }
- return defaultModel;
- }
-
private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
Boolean aLaCarte = null;
@@ -1820,26 +1423,26 @@ public class ServiceInstances {
long startTime = System.currentTimeMillis ();
ServiceInstancesRequest sir = null;
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
- String requestScope = deriveRequestScope(action,sir, requestUri);
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action,sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject ( sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
if(sir.getRequestDetails().getRequestParameters() != null){
aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
}
- parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
InfraActiveRequests dup = null;
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (instanceIdMap != null && dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -1860,7 +1463,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
@@ -1903,7 +1506,7 @@ public class ServiceInstances {
.setServiceInstanceId(serviceInstanceId)
.setPnfCorrelationId(pnfCorrelationId)
.setConfigurationId(configurationId)
- .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
.setApiVersion(apiVersion)
.setALaCarte(aLaCarte)
.setRequestUri(requestUri).build();
@@ -1913,80 +1516,7 @@ public class ServiceInstances {
.errorInfo(errorLoggerInfo).build();
}
- return postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
- }
-
- public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
- String requestId = null;
- if (requestContext.getProperty("requestId") != null) {
- requestId = requestContext.getProperty("requestId").toString();
- }
- if (UUIDChecker.isValidUUID(requestId)) {
- return requestId;
- } else {
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
- .errorInfo(errorLoggerInfo).build();
-
- throw validateException;
- }
- }
- public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (errorMessage);
- aq.setProgress(new Long(100));
- aq.setRequestStatus(status.toString());
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- try{
- infraActiveRequestsClient.save(aq);
- }catch(Exception e){
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- }
- }
- }
- protected String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){
- String serviceType = null;
- if(requestScope.equalsIgnoreCase(ModelType.service.toString())){
- String defaultServiceModelName = getDefaultModel(sir);
- org.onap.so.db.catalog.beans.Service serviceRecord;
- if(aLaCarteFlag){
- serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }
- }else{
- serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId());
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }else{
- serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }
- }
- }
- }else{
- serviceType = msoRequest.getServiceInstanceType(sir, requestScope);
- }
- return serviceType;
- }
- protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){
- if(sir.getServiceInstanceId () != null){
- return sir.getServiceInstanceId ();
- }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){
- RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList();
- if(relatedInstances != null){
- for(RelatedInstanceList relatedInstanceList : relatedInstances){
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if(relatedInstance.getModelInfo().getModelType() == ModelType.service){
- return relatedInstance.getInstanceId();
- }
- }
- }
- }
- return null;
- }
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
new file mode 100644
index 0000000000..b58a3cdddc
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.MessageEnum;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Path("onap/so/infra/workflowSpecifications")
+@Api(value="onap/so/infra/workflowSpecifications",description="Queries of Workflow Specifications")
+@Component
+public class WorkflowSpecificationsHandler {
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Path("/{version:[vV]1}/workflows")
+ @GET
+ @ApiOperation(value="Finds Workflow Specifications",response=Response.class)
+ @Transactional
+ public Response queryFilters (@QueryParam("vnfModelVersionId") String vnfModelVersionId,
+ @PathParam("version") String version) throws Exception {
+
+ String apiVersion = version.substring(1);
+
+ ObjectMapper mapper1 = new ObjectMapper();
+ mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //Replace with Catalog DB Query
+ WorkflowSpecifications workflowSpecifications = mapper1.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), WorkflowSpecifications.class);
+
+ String jsonResponse = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.writeValueAsString(workflowSpecifications);
+ }
+ catch (JsonProcessingException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, "", jsonResponse, apiVersion);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
new file mode 100644
index 0000000000..695213bf20
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+
+import com.google.common.base.Strings;
+
+public class CustomWorkflowValidation implements ValidationRule{
+
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
+ CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration();
+ String workflowUuid = info.getInstanceIdMap().get("workflowUuid");
+
+ if (cloudConfiguration == null) {
+ throw new ValidationException ("cloudConfiguration");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner ()))) {
+ throw new ValidationException ("cloudOwner");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId ()))) {
+ throw new ValidationException ("lcpCloudRegionId");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId ()))) {
+ throw new ValidationException ("tenantId");
+ }
+ if(requestParameters == null){
+ throw new ValidationException("requestParameters");
+ }
+
+ List<Map<String, Object>> userParams = requestParameters.getUserParams();
+ if (!validateCustomUserParams(userParams, workflowUuid)) {
+ throw new ValidationException("userParams");
+ }
+ return info;
+ }
+
+ private boolean validateCustomUserParams(List<Map<String, Object>> userParams, String workflowUuid) {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java
new file mode 100644
index 0000000000..594b43e07d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "name",
+ "description"
+})
+public class ActivitySequence {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("description")
+ private String description;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public ActivitySequence() {
+ }
+
+ /**
+ *
+ * @param description
+ * @param name
+ */
+ public ActivitySequence(String name, String description) {
+ super();
+ this.name = name;
+ this.description = description;
+ }
+
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ActivitySequence withName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @JsonProperty("description")
+ public String getDescription() {
+ return description;
+ }
+
+ @JsonProperty("description")
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public ActivitySequence withDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java
new file mode 100644
index 0000000000..0861ff2033
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java
@@ -0,0 +1,226 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "artifactType",
+ "artifactUuid",
+ "artifactName",
+ "artifactVersion",
+ "artifactDescription",
+ "workflowName",
+ "operationName",
+ "workflowSource",
+ "workflowResourceTarget"
+})
+public class ArtifactInfo {
+
+ @JsonProperty("artifactType")
+ private String artifactType;
+ @JsonProperty("artifactUuid")
+ private String artifactUuid;
+ @JsonProperty("artifactName")
+ private String artifactName;
+ @JsonProperty("artifactVersion")
+ private String artifactVersion;
+ @JsonProperty("artifactDescription")
+ private String artifactDescription;
+ @JsonProperty("workflowName")
+ private String workflowName;
+ @JsonProperty("operationName")
+ private String operationName;
+ @JsonProperty("workflowSource")
+ private String workflowSource;
+ @JsonProperty("workflowResourceTarget")
+ private String workflowResourceTarget;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public ArtifactInfo() {
+ }
+
+ /**
+ *
+ * @param artifactName
+ * @param workflowName
+ * @param artifactType
+ * @param operationName
+ * @param artifactVersion
+ * @param workflowResourceTarget
+ * @param workflowSource
+ * @param artifactUuid
+ * @param artifactDescription
+ */
+ public ArtifactInfo(String artifactType, String artifactUuid, String artifactName, String artifactVersion, String artifactDescription, String workflowName, String operationName, String workflowSource, String workflowResourceTarget) {
+ super();
+ this.artifactType = artifactType;
+ this.artifactUuid = artifactUuid;
+ this.artifactName = artifactName;
+ this.artifactVersion = artifactVersion;
+ this.artifactDescription = artifactDescription;
+ this.workflowName = workflowName;
+ this.operationName = operationName;
+ this.workflowSource = workflowSource;
+ this.workflowResourceTarget = workflowResourceTarget;
+ }
+
+ @JsonProperty("artifactType")
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ @JsonProperty("artifactType")
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public ArtifactInfo withArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ return this;
+ }
+
+ @JsonProperty("artifactUuid")
+ public String getArtifactUuid() {
+ return artifactUuid;
+ }
+
+ @JsonProperty("artifactUuid")
+ public void setArtifactUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public ArtifactInfo withArtifactUuid(String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ return this;
+ }
+
+ @JsonProperty("artifactName")
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ @JsonProperty("artifactName")
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public ArtifactInfo withArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ return this;
+ }
+
+ @JsonProperty("artifactVersion")
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ @JsonProperty("artifactVersion")
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public ArtifactInfo withArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ return this;
+ }
+
+ @JsonProperty("artifactDescription")
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ @JsonProperty("artifactDescription")
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public ArtifactInfo withArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ return this;
+ }
+
+ @JsonProperty("workflowName")
+ public String getWorkflowName() {
+ return workflowName;
+ }
+
+ @JsonProperty("workflowName")
+ public void setWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ }
+
+ public ArtifactInfo withWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ return this;
+ }
+
+ @JsonProperty("operationName")
+ public String getOperationName() {
+ return operationName;
+ }
+
+ @JsonProperty("operationName")
+ public void setOperationName(String operationName) {
+ this.operationName = operationName;
+ }
+
+ public ArtifactInfo withOperationName(String operationName) {
+ this.operationName = operationName;
+ return this;
+ }
+
+ @JsonProperty("workflowSource")
+ public String getWorkflowSource() {
+ return workflowSource;
+ }
+
+ @JsonProperty("workflowSource")
+ public void setWorkflowSource(String workflowSource) {
+ this.workflowSource = workflowSource;
+ }
+
+ public ArtifactInfo withWorkflowSource(String workflowSource) {
+ this.workflowSource = workflowSource;
+ return this;
+ }
+
+ @JsonProperty("workflowResourceTarget")
+ public String getWorkflowResourceTarget() {
+ return workflowResourceTarget;
+ }
+
+ @JsonProperty("workflowResourceTarget")
+ public void setWorkflowResourceTarget(String workflowResourceTarget) {
+ this.workflowResourceTarget = workflowResourceTarget;
+ }
+
+ public ArtifactInfo withWorkflowResourceTarget(String workflowResourceTarget) {
+ this.workflowResourceTarget = workflowResourceTarget;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java
new file mode 100644
index 0000000000..3a4d5cb5f0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "maxLength",
+ "allowableChars"
+})
+public class Validation {
+
+ @JsonProperty("maxLength")
+ private String maxLength;
+ @JsonProperty("allowableChars")
+ private String allowableChars;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public Validation() {
+ }
+
+ /**
+ *
+ * @param maxLength
+ * @param allowableChars
+ */
+ public Validation(String maxLength, String allowableChars) {
+ super();
+ this.maxLength = maxLength;
+ this.allowableChars = allowableChars;
+ }
+
+ @JsonProperty("maxLength")
+ public String getMaxLength() {
+ return maxLength;
+ }
+
+ @JsonProperty("maxLength")
+ public void setMaxLength(String maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ public Validation withMaxLength(String maxLength) {
+ this.maxLength = maxLength;
+ return this;
+ }
+
+ @JsonProperty("allowableChars")
+ public String getAllowableChars() {
+ return allowableChars;
+ }
+
+ @JsonProperty("allowableChars")
+ public void setAllowableChars(String allowableChars) {
+ this.allowableChars = allowableChars;
+ }
+
+ public Validation withAllowableChars(String allowableChars) {
+ this.allowableChars = allowableChars;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java
new file mode 100644
index 0000000000..416442c216
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+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({
+ "label",
+ "inputType",
+ "required",
+ "validation",
+ "soFieldName",
+ "soPayloadLocation"
+})
+public class WorkflowInputParameter {
+
+ @JsonProperty("label")
+ private String label;
+ @JsonProperty("inputType")
+ private String inputType;
+ @JsonProperty("required")
+ private Boolean required;
+ @JsonProperty("validation")
+ private List<Validation> validation = null;
+ @JsonProperty("soFieldName")
+ private String soFieldName;
+ @JsonProperty("soPayloadLocation")
+ private String soPayloadLocation;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public WorkflowInputParameter() {
+ }
+
+ /**
+ *
+ * @param validation
+ * @param inputType
+ * @param soPayloadLocation
+ * @param label
+ * @param required
+ * @param soFieldName
+ */
+ public WorkflowInputParameter(String label, String inputType, Boolean required, List<Validation> validation, String soFieldName, String soPayloadLocation) {
+ super();
+ this.label = label;
+ this.inputType = inputType;
+ this.required = required;
+ this.validation = validation;
+ this.soFieldName = soFieldName;
+ this.soPayloadLocation = soPayloadLocation;
+ }
+
+ @JsonProperty("label")
+ public String getLabel() {
+ return label;
+ }
+
+ @JsonProperty("label")
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public WorkflowInputParameter withLabel(String label) {
+ this.label = label;
+ return this;
+ }
+
+ @JsonProperty("inputType")
+ public String getInputType() {
+ return inputType;
+ }
+
+ @JsonProperty("inputType")
+ public void setInputType(String inputType) {
+ this.inputType = inputType;
+ }
+
+ public WorkflowInputParameter withInputType(String inputType) {
+ this.inputType = inputType;
+ return this;
+ }
+
+ @JsonProperty("required")
+ public Boolean getRequired() {
+ return required;
+ }
+
+ @JsonProperty("required")
+ public void setRequired(Boolean required) {
+ this.required = required;
+ }
+
+ public WorkflowInputParameter withRequired(Boolean required) {
+ this.required = required;
+ return this;
+ }
+
+ @JsonProperty("validation")
+ public List<Validation> getValidation() {
+ return validation;
+ }
+
+ @JsonProperty("validation")
+ public void setValidation(List<Validation> validation) {
+ this.validation = validation;
+ }
+
+ public WorkflowInputParameter withValidation(List<Validation> validation) {
+ this.validation = validation;
+ return this;
+ }
+
+ @JsonProperty("soFieldName")
+ public String getSoFieldName() {
+ return soFieldName;
+ }
+
+ @JsonProperty("soFieldName")
+ public void setSoFieldName(String soFieldName) {
+ this.soFieldName = soFieldName;
+ }
+
+ public WorkflowInputParameter withSoFieldName(String soFieldName) {
+ this.soFieldName = soFieldName;
+ return this;
+ }
+
+ @JsonProperty("soPayloadLocation")
+ public String getSoPayloadLocation() {
+ return soPayloadLocation;
+ }
+
+ @JsonProperty("soPayloadLocation")
+ public void setSoPayloadLocation(String soPayloadLocation) {
+ this.soPayloadLocation = soPayloadLocation;
+ }
+
+ public WorkflowInputParameter withSoPayloadLocation(String soPayloadLocation) {
+ this.soPayloadLocation = soPayloadLocation;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java
new file mode 100644
index 0000000000..86dc44ef39
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+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({
+ "artifactInfo",
+ "activitySequence",
+ "workflowInputParameters"
+})
+public class WorkflowSpecification {
+
+ @JsonProperty("artifactInfo")
+ private ArtifactInfo artifactInfo;
+ @JsonProperty("activitySequence")
+ private List<ActivitySequence> activitySequence = null;
+ @JsonProperty("workflowInputParameters")
+ private List<WorkflowInputParameter> workflowInputParameters = null;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public WorkflowSpecification() {
+ }
+
+ /**
+ *
+ * @param activitySequence
+ * @param artifactInfo
+ * @param workflowInputParameters
+ */
+ public WorkflowSpecification(ArtifactInfo artifactInfo, List<ActivitySequence> activitySequence, List<WorkflowInputParameter> workflowInputParameters) {
+ super();
+ this.artifactInfo = artifactInfo;
+ this.activitySequence = activitySequence;
+ this.workflowInputParameters = workflowInputParameters;
+ }
+
+ @JsonProperty("artifactInfo")
+ public ArtifactInfo getArtifactInfo() {
+ return artifactInfo;
+ }
+
+ @JsonProperty("artifactInfo")
+ public void setArtifactInfo(ArtifactInfo artifactInfo) {
+ this.artifactInfo = artifactInfo;
+ }
+
+ public WorkflowSpecification withArtifactInfo(ArtifactInfo artifactInfo) {
+ this.artifactInfo = artifactInfo;
+ return this;
+ }
+
+ @JsonProperty("activitySequence")
+ public List<ActivitySequence> getActivitySequence() {
+ return activitySequence;
+ }
+
+ @JsonProperty("activitySequence")
+ public void setActivitySequence(List<ActivitySequence> activitySequence) {
+ this.activitySequence = activitySequence;
+ }
+
+ public WorkflowSpecification withActivitySequence(List<ActivitySequence> activitySequence) {
+ this.activitySequence = activitySequence;
+ return this;
+ }
+
+ @JsonProperty("workflowInputParameters")
+ public List<WorkflowInputParameter> getWorkflowInputParameters() {
+ return workflowInputParameters;
+ }
+
+ @JsonProperty("workflowInputParameters")
+ public void setWorkflowInputParameters(List<WorkflowInputParameter> workflowInputParameters) {
+ this.workflowInputParameters = workflowInputParameters;
+ }
+
+ public WorkflowSpecification withWorkflowInputParameters(List<WorkflowInputParameter> workflowInputParameters) {
+ this.workflowInputParameters = workflowInputParameters;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java
new file mode 100644
index 0000000000..c6bf4e3d41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "workflowSpecification"
+})
+public class WorkflowSpecificationList {
+
+ @JsonProperty("workflowSpecification")
+ private WorkflowSpecification workflowSpecification;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public WorkflowSpecificationList() {
+ }
+
+ /**
+ *
+ * @param workflowSpecification
+ */
+ public WorkflowSpecificationList(WorkflowSpecification workflowSpecification) {
+ super();
+ this.workflowSpecification = workflowSpecification;
+ }
+
+ @JsonProperty("workflowSpecification")
+ public WorkflowSpecification getWorkflowSpecification() {
+ return workflowSpecification;
+ }
+
+ @JsonProperty("workflowSpecification")
+ public void setWorkflowSpecification(WorkflowSpecification workflowSpecification) {
+ this.workflowSpecification = workflowSpecification;
+ }
+
+ public WorkflowSpecificationList withWorkflowSpecification(WorkflowSpecification workflowSpecification) {
+ this.workflowSpecification = workflowSpecification;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java
new file mode 100644
index 0000000000..ffe9980af4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+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({
+ "workflowSpecificationList"
+})
+public class WorkflowSpecifications {
+
+ @JsonProperty("workflowSpecificationList")
+ private List<WorkflowSpecificationList> workflowSpecificationList = null;
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public WorkflowSpecifications() {
+ }
+
+ /**
+ *
+ * @param workflowSpecificationList
+ */
+ public WorkflowSpecifications(List<WorkflowSpecificationList> workflowSpecificationList) {
+ super();
+ this.workflowSpecificationList = workflowSpecificationList;
+ }
+
+ @JsonProperty("workflowSpecificationList")
+ public List<WorkflowSpecificationList> getWorkflowSpecificationList() {
+ return workflowSpecificationList;
+ }
+
+ @JsonProperty("workflowSpecificationList")
+ public void setWorkflowSpecificationList(List<WorkflowSpecificationList> workflowSpecificationList) {
+ this.workflowSpecificationList = workflowSpecificationList;
+ }
+
+ public WorkflowSpecifications withWorkflowSpecificationList(List<WorkflowSpecificationList> workflowSpecificationList) {
+ this.workflowSpecificationList = workflowSpecificationList;
+ return this;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java
index 68c5c918ba..e249c2d8ef 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java
@@ -53,6 +53,7 @@ public class BeanMultiTest {
test("org.onap.so.apihandlerinfra.tasksbeans");
test("org.onap.so.apihandlerinfra.vnfbeans");
test("org.onap.so.apihandlerinfra.tenantisolationbeans");
+ test("org.onap.so.apihandlerinfra.workflowspecificationbeans");
}
private void test(String packageName) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
new file mode 100644
index 0000000000..146062533e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
@@ -0,0 +1,181 @@
+/*-
+ * ============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.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import static org.onap.so.logger.MdcConstants.CLIENT_ID;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.logger.HttpHeadersConstants;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class InstanceManagementTest extends BaseTest{
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper errorMapper = new ObjectMapper();
+
+ @Autowired
+ private InstanceManagement instanceManagement;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
+
+ private final String instanceManagementUri = "/onap/so/infra/instanceManagement/";
+
+ private String uri;
+ private URL selfLink;
+ private URL initialUrl;
+ private int initialPort;
+ private HttpHeaders headers;
+
+ @Before
+ public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ // set headers
+ headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(CLIENT_ID, "VID");
+ headers.set(REQUESTOR_ID, "xxxxxx");
+ try { // generate one-time port number to avoid RANDOM port number later.
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialPort = initialUrl.getPort();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ stubFor(post(urlMatching(".*/infraActiveRequests.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
+ }
+
+ private URL createExpectedSelfLink(String version, String requestId) {
+ System.out.println("createdUrl: " + initialUrl.toString());
+ try {
+ selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return selfLink;
+ }
+
+ private String getWiremockResponseForCatalogdb(String file) {
+ try {
+ File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
+ return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
+
+ if (!headers.containsKey(HttpHeaders.ACCEPT)) {
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ }
+ if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
+ headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
+ }
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
+
+ HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
+
+ return restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
+ }
+
+ @Test
+ public void executeCustomWorkflow() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
+ "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ requestReferences.setRequestSelfLink(createExpectedSelfLink("v1","32807a28-1a14-4b88-b7b3-2950918aa76d"));
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = instanceManagementUri + "v1" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/workflows/71526781-e55c-4cb7-adb3-97e09d9c76be";
+ ResponseEntity<String> response = sendRequest(inputStream("/ExecuteCustomWorkflow.json"), uri, HttpMethod.POST, headers);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index ee98accfdc..d6fff7bdfb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -153,6 +153,27 @@ public class MsoRequestTest extends BaseTest {
});
}
@Test
+ @Parameters(method = "customWorkflowSuccessParameters")
+ public void customWorkflowSuccessTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, int reqVersion) throws ValidationException, IOException{
+ this.sir = sir;
+ this.instanceIdMapTest = instanceIdMapTest;
+ this.action = action;
+ this.reqVersion = reqVersion;
+ this.version = "v" + reqVersion;
+ this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("workflowUuid", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Parameters
+ private Collection<Object[]> customWorkflowSuccessParameters() throws JsonParseException, JsonMappingException, IOException{
+ return Arrays.asList(new Object[][]{
+ {mapper.readValue(inputStream("/SuccessfulValidation/v1ExecuteCustomWorkflow.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "1"}
+
+ });
+ }
+ @Test
@Parameters(method = "aLaCarteParameters")
public void aLaCarteFlagTest(boolean expected, ServiceInstancesRequest sir) throws JsonParseException, IOException, ValidationException{
this.expected = expected;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
new file mode 100644
index 0000000000..b1a6e9f826
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
@@ -0,0 +1,331 @@
+/*-
+ * ============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.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import static org.onap.so.logger.MdcConstants.CLIENT_ID;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+
+import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.HttpHeadersConstants;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RequestHandlerUtilsTest extends BaseTest{
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper errorMapper = new ObjectMapper();
+
+ @Autowired
+ private RequestHandlerUtils requestHandlerUtils;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
+
+ private URL initialUrl;
+ private int initialPort;
+ private HttpHeaders headers;
+
+ @Before
+ public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ // set headers
+ headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(CLIENT_ID, "VID");
+ headers.set(REQUESTOR_ID, "xxxxxx");
+ try { // generate one-time port number to avoid RANDOM port number later.
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialPort = initialUrl.getPort();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ stubFor(post(urlMatching(".*/infraActiveRequests.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
+
+ if (!headers.containsKey(HttpHeaders.ACCEPT)) {
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ }
+ if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
+ headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
+ }
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
+
+ HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
+
+ return restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
+ }
+
+ @Test
+ public void test_mapJSONtoMSOStyle() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ String resultString = requestHandlerUtils.mapJSONtoMSOStyle(testRequest, null, false, null);
+ ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
+ assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
+ assertEquals("10",modelInfo.getModelUuid());
+
+ }
+
+
+ @Test
+ public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails rd = new RequestDetails();
+ RequestParameters rp = new RequestParameters();
+ rp.setUsePreload(true);
+ rd.setRequestParameters(rp);
+ sir.setRequestDetails(rd);
+ String resultString = requestHandlerUtils.mapJSONtoMSOStyle(testRequest, sir, false, null);
+ ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
+ }
+
+ @Test
+ public void setServiceTypeTestALaCarte() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = true;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceTypeALaCarte");
+
+ stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceTypeALaCarte");
+ }
+ @Test
+ public void setServiceTypeTest() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestDefault() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+ stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestNetwork() throws JsonProcessingException{
+ String requestScope = ModelType.network.toString();
+ Boolean aLaCarteFlag = null;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelName("networkModelName");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "networkModelName");
+ }
+ @Test
+ public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
+ String requestScope = "instanceGroup";
+ ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
+ assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdReturnNullTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertTrue(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
+ public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+ HttpHeaders headers = requestHandlerUtils.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 17fa011c93..639367074b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -29,9 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
@@ -63,20 +61,14 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
-import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
-import org.onap.so.serviceinstancebeans.ModelInfo;
-import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestError;
-import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -108,7 +100,7 @@ public class ServiceInstancesTest extends BaseTest{
@Autowired
private ServiceInstances servInstances;
-
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -190,39 +182,7 @@ public class ServiceInstancesTest extends BaseTest{
public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
}
-
- @Test
- public void test_mapJSONtoMSOStyle() throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String testRequest= inputStream("/ServiceInstanceDefault.json");
- String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
- ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
- ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
- assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
- assertEquals("10",modelInfo.getModelUuid());
-
- }
-
-
- @Test
- public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String testRequest= inputStream("/ServiceInstanceDefault.json");
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails rd = new RequestDetails();
- RequestParameters rp = new RequestParameters();
- rp.setUsePreload(true);
- rd.setRequestParameters(rp);
- sir.setRequestDetails(rd);
- String resultString = servInstances.mapJSONtoMSOStyle(testRequest, sir, false, null);
- ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
- assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
- }
-
+
@Test
public void createServiceInstanceVIDDefault() throws IOException{
TestAppender.events.clear();
@@ -2569,160 +2529,5 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
}
- @Test
- public void setServiceTypeTestALaCarte() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = true;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setSource("VID");
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceTypeALaCarte");
-
- stubFor(get(urlMatching(".*/service/search/.*"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceTypeALaCarte");
- }
- @Test
- public void setServiceTypeTest() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = false;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceType");
-
- stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceType");
- }
- @Test
- public void setServiceTypeTestDefault() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = false;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceType");
-
- stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(get(urlMatching(".*/service/search/.*"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceType");
- }
- @Test
- public void setServiceTypeTestNetwork() throws JsonProcessingException{
- String requestScope = ModelType.network.toString();
- Boolean aLaCarteFlag = null;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelName("networkModelName");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "networkModelName");
- }
- @Test
- public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
- String requestScope = "instanceGroup";
- ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
- assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void setServiceInstanceIdTest(){
- String requestScope = "vnf";
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void setServiceInstanceIdReturnNullTest(){
- String requestScope = "vnf";
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- assertNull(servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertTrue(inProgress);
- }
- @Test
- public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertFalse(inProgress);
- }
- @Test
- public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertFalse(inProgress);
- }
- @Test
- public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
- String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
- String key = "07a7159d3bf51a0e53be7a8f89699be7";
- HttpHeaders headers = servInstances.setCamundaHeaders(encryptedAuth, key);
- List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
- String expectedAcceptedType = "application/json";
- assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
- String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
- String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
- assertEquals(expectedBasicAuth, basicAuth);
- }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
new file mode 100644
index 0000000000..1a2eca6300
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.ParseException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.json.JSONException;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class WorkflowSpecificationsHandlerTest extends BaseTest{
+
+ private final String basePath = "onap/so/infra/workflowSpecifications/v1/workflows";
+
+ @Test
+ public void getTasksTestByOriginalRequestId() throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException{
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
+ .queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ WorkflowSpecifications expectedResponse = mapper.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), WorkflowSpecifications.class);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java
new file mode 100644
index 0000000000..90c994fce0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.apihandlerinfra.validation;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class CustomWorkflowValidationTest extends BaseTest{
+
+ @Test
+ public void testCustomWorkflowValidation() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.inPlaceSoftwareUpdate,
+ 1, false, sir.getRequestDetails().getRequestParameters());
+ info.setRequestScope("vnf");
+
+ CustomWorkflowValidation validation = new CustomWorkflowValidation();
+ validation.validate(info);
+
+ assertEquals(info.getSir().getRequestDetails().getCloudConfiguration().getCloudOwner(), "att-aic");
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java
new file mode 100644
index 0000000000..c469a56e48
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationBeansTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra.workflowspecificationbeans;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+
+import com.openpojo.reflection.filters.FilterPackageInfo;
+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 WorkflowSpecificationBeansTest extends BaseTest{
+ @Test
+ public void validateGettersAndSetters() {
+ Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule())
+ .with(new SetterTester(), new GetterTester()).build();
+ validator.validate("org.onap.so.apihandlerinfra.tasksbeans", new FilterPackageInfo());
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json
new file mode 100644
index 0000000000..611ccb3c66
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "cloudConfiguration": {
+ "cloudOwner": "att-aic",
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestParameters": {
+ "userParams": [
+ {
+ "existing_software_version": "3.1",
+ "new_software_version": "3.2",
+ "operations_timeout": "3600"
+ }
+ ]
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json
new file mode 100644
index 0000000000..611ccb3c66
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "cloudConfiguration": {
+ "cloudOwner": "att-aic",
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestParameters": {
+ "userParams": [
+ {
+ "existing_software_version": "3.1",
+ "new_software_version": "3.2",
+ "operations_timeout": "3600"
+ }
+ ]
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json
new file mode 100644
index 0000000000..beca93bd70
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/WorkflowSpecifications.json
@@ -0,0 +1,116 @@
+{
+ "workflowSpecificationList": [
+ {
+ "workflowSpecification": {
+ "artifactInfo": {
+ "artifactType": "workflow",
+ "artifactUuid": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn",
+ "artifactVersion": "1.0",
+ "artifactDescription": "xyz xyz",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "operationName": "inPlaceSoftwareUpdate",
+ "workflowSource": "sdc",
+ "workflowResourceTarget": "vnf"
+ },
+ "activitySequence": [
+ {
+ "name": "VNFQuiesceTrafficActivity",
+ "description": "Activity to QuiesceTraffic on VNF"
+ },
+ {
+ "name": "VNFHealthCheckActivity",
+ "description": "Activity to HealthCheck VNF"
+ },
+ {
+ "name": "FlowCompleteActivity",
+ "description": "Activity to Complete the BPMN Flow"
+ }
+ ],
+ "workflowInputParameters": [
+ {
+ "label": "Cloud Owner",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "7",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "cloudOwner",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Cloud Region ID",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "7",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "lcpCloudRegionId",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Tenant/Project ID",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "36",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "tenantId",
+ "soPayloadLocation": "cloudConfiguration"
+ },
+ {
+ "label": "Operations Timeout",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "50",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "operations_timeout",
+ "soPayloadLocation": "userParams"
+ },
+ {
+ "label": "Existing Software Version",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "50",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "existing_software_version",
+ "soPayloadLocation": "userParams"
+ },
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "validation": [
+ {
+ "maxLength": "50",
+ "allowableChars": "someRegEx"
+ }
+ ],
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams"
+ }
+ ]
+ }
+ },
+ {
+ "workflowSpecification": {}
+ }
+ ]
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
index 6902d8f36a..0fa07cfe0f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
@@ -30,7 +30,9 @@ public enum OrchestrationStatus {
PENDING_CREATE("PendingCreate", "pending.?create"),
PENDING_DELETE("PendingDelete", "pending.?delete"),
PRECREATED("PreCreated", "pre.?created"),
- CONFIGASSIGNED("ConfigAssigned", "config.?assigned");
+ CONFIGASSIGNED("ConfigAssigned", "config.?assigned"),
+ CONFIGURE("Configure" , "configure"),
+ CONFIGURED("Configured" , "configured");
private final String name;
private final String fuzzyMatcher;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java
index 8252b2427e..7527a79842 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepository.java
@@ -21,11 +21,8 @@ package org.onap.so.db.catalog.data.repository;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-import java.util.List;
-
@RepositoryRestResource(collectionResourceRel = "pnfResourceCustomization", path = "pnfResourceCustomization")
public interface PnfCustomizationRepository extends JpaRepository<PnfResourceCustomization, String> {
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java
index 17ae017da4..525c628e1c 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,6 @@
package org.onap.so.db.catalog.data.repository;
import java.util.List;
-
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
@@ -29,11 +28,13 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "vnfResourceCustomization", path = "vnfResourceCustomization")
public interface VnfCustomizationRepository extends JpaRepository<VnfResourceCustomization, String> {
- List<VnfResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID);
- VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid);
+ List<VnfResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID);
+
+ VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid);
- @Query(value = "SELECT * FROM vnf_resource_customization WHERE MODEL_INSTANCE_NAME = ?1 AND VNF_RESOURCE_MODEL_UUID = ?2 LIMIT 1;", nativeQuery = true)
- VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName, String vnfResourceModelUUID);
+ @Query(value = "SELECT * FROM vnf_resource_customization WHERE MODEL_INSTANCE_NAME = ?1 AND VNF_RESOURCE_MODEL_UUID = ?2 LIMIT 1;", nativeQuery = true)
+ VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName,
+ String vnfResourceModelUUID);
} \ No newline at end of file
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java
index c5e95fcfbc..7ac80e222f 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java
@@ -20,7 +20,6 @@
package org.onap.so.db.catalog.data.repository;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
@@ -29,9 +28,6 @@ import org.onap.so.db.catalog.beans.PnfResource;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.exceptions.NoEntityFoundException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
-
-import java.util.List;
public class PnfCustomizationRepositoryTest extends BaseTest {
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java
index 8e2e1e0446..be21ea9b35 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepositoryTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import java.util.List;
import org.junit.Test;
import org.onap.so.db.catalog.BaseTest;
import org.onap.so.db.catalog.beans.VnfResource;
@@ -30,8 +31,6 @@ import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
-import java.util.List;
-
public class VnfCustomizationRepositoryTest extends BaseTest {
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index d53d8925e2..7068ef9ba5 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -956,7 +956,7 @@ CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization (
) ENGINE = INNODB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = LATIN1;
CREATE TABLE IF NOT EXISTS `pnf_resource` (
- `ORCHESTRATION_MODE` varchar(20) NOT NULL DEFAULT 'HEAT',
+ `ORCHESTRATION_MODE` varchar(20) DEFAULT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`MODEL_UUID` varchar(200) NOT NULL,
diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
index de446b734a..cf50868ca5 100644
--- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
+++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image
@@ -11,7 +11,7 @@ ENV https_proxy=$HTTPS_PROXY
RUN apk update && apk upgrade
# Install commonly needed tools
-RUN apk --no-cache add curl netcat-openbsd sudo
+RUN apk --no-cache add curl netcat-openbsd sudo nss
# Create 'so' user
RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so