diff options
35 files changed, 740 insertions, 189 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java index 00602af216..8fbccaaf69 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java @@ -128,6 +128,6 @@ public class KeystoneV3Authentication { } } } - throw new ServiceEndpointNotFoundException("endpoint url not found"); + throw new ServiceEndpointNotFoundException("endpoint url not found: type:" + type +" region: " + region + " facing: " + facing); } } 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 ee1c79c09c..a0fbd485d1 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 @@ -999,6 +999,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ OpenStackRequest <Stack> request = heatClient.getStacks ().byName (stackName); return executeAndRecordOpenstackRequest (request); } catch (OpenStackResponseException e) { + logger.error("Error in Query Stack", e); if (e.getStatus () == 404) { logger.debug ("queryHeatStack - stack not found: {}", stackName); return null; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml index aa9317c920..07b000875e 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml +++ b/adapters/mso-catalog-db-adapter/src/main/resources/application.yaml @@ -28,6 +28,7 @@ spring: password: ${DB_ADMIN_PASSWORD} outOfOrder: true validateOnMigrate: false + repeatableSqlMigrationPrefix: RATT jpa: show-sql: true hibernate: diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index f2f411d5b6..cb35e90860 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -13,8 +13,8 @@ <build> <finalName>${project.artifactId}-${project.version}</finalName> - - <plugins> + + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@ -36,25 +36,75 @@ </executions> </plugin> - <!-- run the following plugin only when there's a wsdl change and you - need to recompile the java classes <plugin> <groupId>org.codehaus.mojo</groupId> - <artifactId>jaxws-maven-plugin</artifactId> <version>2.4.1</version> <executions> - <execution> <id>generate-network-async-stubs</id> <phase>process-classes</phase> - <goals> <goal>wsimport</goal> </goals> <configuration> <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> - </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> <wsdlFiles> - <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.network.async.client</packageName> <xnocompile>false</xnocompile> - <keep>true</keep> </configuration> </execution> <execution> <id>generate-vnf-async-stubs</id> - <phase>process-classes</phase> <goals> <goal>wsimport</goal> </goals> <configuration> - <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> - <wsdlFiles> <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> - <packageName>org.onap.so.adapters.vnf.async.client</packageName> <xnocompile>false</xnocompile> - <keep>true</keep> </configuration> </execution> </executions> </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> - <version>3.0.0</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> - <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-sources/wsimport/</source> - </sources> </configuration> </execution> </executions> </plugin> --> +<!-- run the following plugin only when there's a wsdl change and you need to recompile the java classes + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.4.1</version> + <executions> + <execution> + <id>generate-network-async-stubs</id> + <phase>process-classes</phase> + <goals> + <goal>wsimport</goal> + </goals> + <configuration> + <vmArgs> + <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> + </vmArgs> + <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> + <wsdlFiles> + <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> + </wsdlFiles> + <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> + <packageName>org.onap.so.adapters.network.async.client</packageName> + <xnocompile>false</xnocompile> + <keep>true</keep> + </configuration> + </execution> + + <execution> + <id>generate-vnf-async-stubs</id> + <phase>process-classes</phase> + <goals> + <goal>wsimport</goal> + </goals> + <configuration> + <vmArgs> + <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> + </vmArgs> + <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> + <wsdlFiles> + <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> + </wsdlFiles> + <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> + <packageName>org.onap.so.adapters.vnf.async.client</packageName> + <xnocompile>false</xnocompile> + <keep>true</keep> + </configuration> + </execution> + </executions> + </plugin> <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/generated-sources/wsimport/</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> </plugin> @@ -76,12 +126,12 @@ </execution> </executions> </plugin> - </plugins> - - + </plugins> + + <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -118,10 +168,10 @@ </build> <dependencies> - <!-- added for spring boot support --> + <!-- added for spring boot support --> <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -134,7 +184,7 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> @@ -142,9 +192,9 @@ <version>${cxf.version}</version> </dependency> <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>${cxf.version}</version> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.webjars</groupId> @@ -157,16 +207,16 @@ <scope>test</scope> </dependency> <dependency> - <groupId>janino</groupId> - <artifactId>janino</artifactId> - <version>2.5.15</version> + <groupId>janino</groupId> + <artifactId>janino</artifactId> + <version>2.5.15</version> </dependency> - - <!-- end added for spring boot support --> - - - - <!-- added for unit testing --> + + <!-- end added for spring boot support --> + + + + <!-- added for unit testing --> <dependency> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> @@ -181,11 +231,11 @@ <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>test</scope> - </dependency> + </dependency> <dependency> <groupId>org.mariadb.jdbc</groupId> <artifactId>mariadb-java-client</artifactId> - </dependency> + </dependency> <dependency> <groupId>org.onap.so</groupId> <artifactId>common</artifactId> @@ -214,9 +264,9 @@ <version>${openstack.version}</version> </dependency> <dependency> - <groupId>org.camunda.bpm</groupId> - <artifactId>camunda-external-task-client</artifactId> - <version>1.0.0</version> - </dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-external-task-client</artifactId> + <version>1.1.1</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java index 773705d566..24980ae4e0 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.audit; - import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; import org.onap.logging.ref.slf4j.ONAPLogConstants; @@ -35,14 +34,14 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class AuditStackServiceData { +public class AuditCreateStackService { private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI"; private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20}; - private static final Logger logger = LoggerFactory.getLogger(AuditStackServiceData.class); + private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class); @Autowired public HeatStackAudit heatStackAudit; @@ -56,7 +55,7 @@ public class AuditStackServiceData { boolean success = false; try { logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries()); - success=heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), + success=heatStackAudit.auditHeatStackCreate(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName()); } catch (Exception e) { logger.error("Error during audit of stack", e); @@ -72,7 +71,7 @@ public class AuditStackServiceData { }else if(externalTask.getRetries() != null && externalTask.getRetries()-1 == 0){ logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); - externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure"); + externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); }else{ logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java new file mode 100644 index 0000000000..66d8fbd47c --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-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.adapters.audit; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.audit.beans.AuditInventory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class AuditDeleteStackService { + + private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "All VServers have not been deleted in A&AI"; + + private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20}; + + + private static final Logger logger = LoggerFactory.getLogger(AuditDeleteStackService.class); + + @Autowired + public HeatStackAudit heatStackAudit; + + @Autowired + public Environment env; + + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){ + AuditInventory auditInventory = externalTask.getVariable("auditInventory"); + setupMDC(externalTask); + boolean success = false; + try { + logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries()); + success=heatStackAudit.auditHeatStackDeleted(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), + auditInventory.getTenantId(), auditInventory.getHeatStackName()); + } catch (Exception e) { + logger.error("Error during audit of stack", e); + } + + if (success) { + externalTaskService.complete(externalTask); + logger.debug("The External Task Id: {} Successful", externalTask.getId()); + } else { + if(externalTask.getRetries() == null){ + logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", externalTask.getId(),RETRY_SEQUENCE.length); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, RETRY_SEQUENCE.length, 10000); + }else if(externalTask.getRetries() != null && + externalTask.getRetries()-1 == 0){ + logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); + externalTaskService.complete(externalTask); + }else{ + logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + } + logger.debug("The External Task Id: {} Failed", externalTask.getId()); + } + } + private void setupMDC(ExternalTask externalTask) { + String msoRequestId = (String)externalTask.getVariable("mso-request-id"); + if(msoRequestId != null && !msoRequestId.isEmpty()) + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); + } + protected long calculateRetryDelay(int currentRetries){ + int retrySequence = RETRY_SEQUENCE.length - currentRetries; + long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000")); + return RETRY_SEQUENCE[retrySequence] * retryMultiplier; + } +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java index 499c1137c7..6ea14dcac7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java @@ -46,10 +46,30 @@ public class AuditStackService { public Environment env; @Autowired - private AuditStackServiceData auditStack; + private AuditCreateStackService auditCreateStack; + + @Autowired + private AuditDeleteStackService auditDeleteStack; @PostConstruct - public void auditAAIInventory() { + public void auditAddAAIInventory() { + String auth = ""; + try { + auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); + } catch (IllegalStateException | GeneralSecurityException e) { + logger.error("Error Decrypting Password", e); + } + ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), + auth); + ExternalTaskClient client = ExternalTaskClient.create() + .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) + .asyncResponseTimeout(120000).build(); + client.subscribe("InventoryAddAudit").lockDuration(60000) + .handler(auditCreateStack::executeExternalTask).open(); + } + + @PostConstruct + public void auditDeleteAAIInventory() { String auth = ""; try { auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); @@ -60,9 +80,9 @@ public class AuditStackService { auth); ExternalTaskClient client = ExternalTaskClient.create() .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) - .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build(); - client.subscribe("InventoryAudit").lockDuration(60000) - .handler(auditStack::executeExternalTask).open(); + .asyncResponseTimeout(120000).build(); + client.subscribe("InventoryDeleteAudit").lockDuration(60000) + .handler(auditDeleteStack::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java index 6e6ecd51d4..c81dac7c6f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java @@ -39,23 +39,32 @@ import org.springframework.stereotype.Component; public class AuditVServer extends AbstractAudit { private static final Logger logger = LoggerFactory.getLogger(AuditVServer.class); - public boolean auditVservers(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { + public boolean auditAllVserversDoExist(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { if (vServersToAudit == null || vServersToAudit.isEmpty()){ return false; } return vServersToAudit.stream() - .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion)).findFirst() + .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,true)).findFirst() + .map(v -> false).orElse(true); + } + + public boolean auditAllVserversDoNotExist(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { + if (vServersToAudit == null || vServersToAudit.isEmpty()){ + return true; + } + return vServersToAudit.stream() + .filter(vServer -> doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,false)).findFirst() .map(v -> false).orElse(true); } - private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion) { + private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion, boolean checkLinterfaces) { AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenantId, vServer.getVserverId()); boolean vServerExists = getAaiClient().exists(vserverURI); boolean doesExist = getAaiClient().exists(vserverURI); logger.info("v-server {} exists: {}", vServer.getVserverId(), doesExist); boolean allNeutronNetworksExist = true; - if (vServerExists && vServer.getLInterfaces() != null) { + if (vServerExists && vServer.getLInterfaces() != null && checkLinterfaces) { allNeutronNetworksExist = vServer.getLInterfaces() .getLInterface().stream().filter(lInterface -> !doesLinterfaceExistinAAI(lInterface, vServer.getVserverId(), tenantId, cloudOwner, cloudRegion)) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java index da833c7b07..19e3ab71f5 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java @@ -57,26 +57,51 @@ public class HeatStackAudit { @Autowired protected AuditVServer auditVservers; - public boolean auditHeatStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { + public boolean auditHeatStackCreate(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { try { - logger.debug("Fetching Top Level Stack Information"); - Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName); - List<Resource> novaResources = resources.getList().stream() - .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); - List<Resource> resourceGroups = resources.getList().stream() - .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList()); - if(novaResources.isEmpty()) - return true; - else{ - Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources); - Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups, - vserversToAudit); - return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); - } + return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,true); } catch (Exception e) { logger.error("Error during auditing stack resources", e); return false; } + } + + public boolean auditHeatStackDeleted(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { + try { + return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,false); + } catch (Exception e) { + logger.error("Error during auditing stack resources", e); + return false; + } + } + + private boolean auditStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName,boolean isCreateAudit) throws Exception{ + logger.debug("Fetching Top Level Stack Information"); + Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName); + List<Resource> novaResources = extractNovaResources(resources); + if(novaResources.isEmpty()) + return true; + else{ + List<Resource> resourceGroups = extractResourceGroups(resources); + Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources); + Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups, + vserversToAudit); + if(isCreateAudit){ + return auditVservers.auditAllVserversDoExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); + }else{ + return auditVservers.auditAllVserversDoNotExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); + } + } + } + + private List<Resource> extractResourceGroups(Resources resources) { + return resources.getList().stream() + .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList()); + } + + private List<Resource> extractNovaResources(Resources resources) { + return resources.getList().stream() + .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); } protected Set<Vserver> processSubInterfaces(String cloudRegion, String tenantId, List<Resource> resourceGroups, @@ -208,5 +233,4 @@ public class HeatStackAudit { return Optional.empty(); } - } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index 8f9152a86d..253f13d57d 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -90,6 +90,7 @@ public class NetworkAdapterRest { @Autowired private MsoNetworkAdapterImpl adapter; + @Autowired private Provider<BpelRestClient> bpelRestClientProvider; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 7265a59397..8a5a083c63 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -59,7 +59,7 @@ import org.springframework.stereotype.Component; * org.onap.so.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code * 900 means "connection was not established") */ -@Component() +@Component @Scope("prototype") public class BpelRestClient { public static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 4e8d389998..cdd04b8c21 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -30,8 +30,19 @@ spring: ddl-auto: validate naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy enable-lazy-load-no-trans: true - - +org: + onap: + so: + adapters: + default_keystone_url_version: /v2.0 + default_keystone_reg_ex: "/[vV][0-9]" + po: + retryCodes: 504 + retryDelay: 5 + retryCount: 3 + pollTimeout: 7500 + pollInterval: 15 + #Actuator management: endpoints: diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java index d7739e56f6..bcf126d887 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java @@ -40,10 +40,10 @@ import org.springframework.core.env.Environment; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; -public class AuditStackServiceDataTest extends AuditStackServiceData { +public class AuditCreateStackServiceTest extends AuditCreateStackService { @InjectMocks - AuditStackServiceData auditStackService = new AuditStackServiceData(); + AuditCreateStackService auditStackService = new AuditCreateStackService(); @Mock HeatStackAudit heatStackAuditMock; @@ -73,14 +73,14 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_success_Test() { - doReturn(true).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(true).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).complete(mockExternalTask); } @Test public void execute_external_task_audit_first_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(null).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, @@ -90,7 +90,7 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_intermediate_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(6).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, @@ -101,11 +101,11 @@ public class AuditStackServiceDataTest extends AuditStackServiceData { @Test public void execute_external_task_audit_final_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); doReturn(1).when(mockExternalTask).getRetries(); auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, - "AuditAAIInventoryFailure"); + "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java index 02557d8c20..9176b58de8 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java @@ -58,8 +58,6 @@ import com.woorea.openstack.heat.model.Resources; @RunWith(MockitoJUnitRunner.Silent.class) public class AuditVServerTest extends AuditVServer { - private ObjectMapper objectMapper = new ObjectMapper(); - @InjectMocks private AuditVServer auditNova = new AuditVServer(); @@ -225,9 +223,13 @@ public class AuditVServerTest extends AuditVServer { @Test public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException { - boolean exists = auditNova.auditVservers(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } + @Test public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException { @@ -246,8 +248,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(true, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -268,8 +273,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -288,16 +296,23 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test - public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { + public void audit_Vservers_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { doReturn(false).when(aaiResourcesMock).exists(vserverURI); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } @Test @@ -306,8 +321,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(vserverURI2); doReturn(Optional.of(test_port_1_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_1_uri); doReturn(Optional.of(test_port_2_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_2_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -325,8 +343,12 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java index 696784110b..5eea46d09f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java @@ -203,7 +203,7 @@ public class HeatStackAuditTest extends HeatStackAudit { Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName"); - boolean actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName"); + boolean actual = heatStackAudit.auditHeatStackCreate(cloudRegion, "cloudOwner", tenantId, "heatStackName"); assertEquals(true, actual); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 75cea9eafc..376076a0a0 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -65,7 +65,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ @Test public void createVfModule() throws Exception { - //expectedException.expect(VnfException.class); + Map<String, Object> stackInputs = new HashMap<>(); stackInputs.put("oof_directives", "{}"); stackInputs.put("sdnc_directives", "{}"); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java new file mode 100644 index 0000000000..a23f85bae9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java @@ -0,0 +1,58 @@ +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Tenant implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8704478668505531590L; + @Id + @JsonProperty("tenant-id") + private String tenantId; + @JsonProperty("tenant-name") + private String tenantName; + @JsonProperty("tenant-context") + private String tenantContext; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Tenant)) { + return false; + } + Tenant castOther = (Tenant) other; + return new EqualsBuilder().append(tenantId, castOther.tenantId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(tenantId).toHashCode(); + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getTenantName() { + return tenantName; + } + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + public String getTenantContext() { + return tenantContext; + } + public void setTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + } + + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java index adea99c4f3..6d3be0f822 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java @@ -26,6 +26,7 @@ import java.util.Map; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -39,10 +40,20 @@ public class GeneralBuildingBlock implements Serializable { private OrchestrationContext orchContext; private Map<String, String> userInput; private CloudRegion cloudRegion; + private Tenant tenant; private Customer customer; private ServiceInstance serviceInstance; + + public Tenant getTenant() { + return tenant; + } + + public void setTenant(Tenant tenant) { + this.tenant = tenant; + } + public CloudRegion getCloudRegion() { return cloudRegion; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index fb3094665e..77372bcd88 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -49,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; @@ -831,7 +832,7 @@ public class BBInputSetup implements JavaDelegate { } protected GeneralBuildingBlock populateGBBWithSIAndAdditionalInfo(RequestDetails requestDetails, - ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) { + ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) throws Exception { GeneralBuildingBlock outputBB = new GeneralBuildingBlock(); OrchestrationContext orchContext = mapperLayer.mapOrchestrationContext(requestDetails); RequestContext requestContext = mapperLayer.mapRequestContext(requestDetails); @@ -840,9 +841,11 @@ public class BBInputSetup implements JavaDelegate { org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils .getCloudRegion(requestDetails.getCloudConfiguration()); CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); + Tenant tenant = getTenant(requestDetails.getCloudConfiguration(), aaiCloudRegion); outputBB.setOrchContext(orchContext); outputBB.setRequestContext(requestContext); outputBB.setCloudRegion(cloudRegion); + outputBB.setTenant(tenant); if(customer == null){ Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); String globalCustomerId = uriKeys.get("global-customer-id"); @@ -857,6 +860,23 @@ public class BBInputSetup implements JavaDelegate { return outputBB; } + protected Tenant getTenant(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) throws Exception { + Tenant tenant = new Tenant(); + if(cloudConfiguration != null && cloudConfiguration.getTenantId() != null + && aaiCloudRegion != null && aaiCloudRegion.getTenants() != null) { + for(org.onap.aai.domain.yang.Tenant aaiTenant : aaiCloudRegion.getTenants().getTenant()) { + if(aaiTenant.getTenantId().equalsIgnoreCase(cloudConfiguration.getTenantId())) { + tenant = mapperLayer.mapTenant(aaiTenant); + } + } + if(tenant.getTenantId() == null || tenant.getTenantName() == null) { + throw new Exception("Invalid tenant information retrieved: tenantId = " + tenant.getTenantId() + + " tenantName = " + tenant.getTenantName()); + } + } + return tenant; + } + protected ServiceSubscription getServiceSubscription(RequestDetails requestDetails, Customer customer) { org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = bbInputSetupUtils .getAAIServiceSubscription(customer.getGlobalCustomerId(), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 108fd66488..a838ffdbae 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -53,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; @@ -383,6 +384,14 @@ public class BBInputSetupMapperLayer { modelMapper.map(aaiCloudRegion, cloudRegion); return cloudRegion; } + + protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) { + Tenant tenant = new Tenant(); + if(aaiTenant != null) { + modelMapper.map(aaiTenant, tenant); + } + return tenant; + } protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) { Collection collection = new Collection(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index b3b4559f1d..486164e75f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -173,7 +173,7 @@ public class BBInputSetupUtils { if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, - cloudRegionId)).orElse(null); + cloudRegionId).depth(Depth.TWO)).orElse(null); } else { return null; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 3cb7b241dc..7e4afb7a12 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -50,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; @@ -604,6 +605,23 @@ public class BBInputSetupMapperLayerTest { assertThat(actual, sameBeanAs(expected)); } + + @Test + public void testMapTenant() { + Tenant expected = new Tenant(); + expected.setTenantId("tenantId"); + expected.setTenantName("tenantName"); + expected.setTenantContext("tenantContext"); + + org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant(); + aaiTenant.setTenantId("tenantId"); + aaiTenant.setTenantName("tenantName"); + aaiTenant.setTenantContext("tenantContext"); + + Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant); + + assertThat(actual, sameBeanAs(expected)); + } @Test public void testMapCloudRegionWithNullCheck() { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index cea8fc3cc2..d7c681b938 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -787,7 +787,9 @@ public class BBInputSetupTest { ServiceInstance serviceInstance = mapper.readValue( new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class); - + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setTenantId("tenantId"); + requestDetails.setCloudConfiguration(cloudConfiguration); OrchestrationContext orchestrationContext = new OrchestrationContext(); orchestrationContext.setIsRollbackEnabled(false); @@ -808,17 +810,30 @@ public class BBInputSetupTest { customer.setSubscriberName("subscriberName"); customer.setSubscriberType("subscriberType"); customer.setServiceSubscription(serviceSubscription); + + org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant = new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant(); + tenant.setTenantContext("tenantContext"); + tenant.setTenantId("tenantId"); + tenant.setTenantName("tenantName"); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); + org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class); + org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant(); + aaiTenant.setTenantId("tenantId"); + List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>(); + tenants.add(aaiTenant); String requestAction = "createInstance"; - + doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type")); doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails); doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails); doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); + doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant); + doReturn(aaiTenants).when(aaiCloudRegion).getTenants(); + doReturn(tenants).when(aaiTenants).getTenant(); GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index ae1af8f960..d1d66ae28d 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -181,10 +181,10 @@ public class BBInputSetupUtilsTest { expected.get().setCloudRegionId("lcpCloudRegionId"); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), - cloudConfig.getLcpCloudRegionId())); + cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO)); AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), - cloudConfig.getLcpCloudRegionId()); + cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO); bbInputSetupUtils.getCloudRegion(cloudConfig); verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index a53ed4dfde..fe33308d78 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -16,6 +16,8 @@ "cloudRegion": { "lcp-cloud-region-id" : "myRegionId", "cloud-owner": "CloudOwner" + }, + "tenant": { }, "userInput": null, "customer": { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index 5eb9a26901..b18cad0620 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -44,6 +44,11 @@ "tenant-id": "tenantId", "complex": "complexName" }, + "tenant": { + "tenant-name": "tenantName", + "tenant-context": "tenantContext", + "tenant-id": "tenantId" + }, "userInput": null, "customer": { "global-customer-id": "globalCustomerId", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json index 5ac07c6546..f07f060b06 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json @@ -55,6 +55,11 @@ "complex": "complexName" }, "userInput": null, + "tenant": { + "tenant-id": "tenantId", + "tenant-name": "tenantName", + "tenant-context": "tenantContext" + }, "customer": { "global-customer-id": "globalCustomerId", "subscriber-name": "subscriberName", diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index fd24be100b..c841da3e3a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -35,7 +35,7 @@ <bpmn:incoming>SequenceFlow_0ghzwlo</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xndboi</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:serviceTask id="Audit_AAI_Inventory" name="Validate A&AI Inventory" camunda:type="external" camunda:topic="InventoryAudit"> + <bpmn:serviceTask id="Audit_AAI_Inventory" name="Validate A&AI Inventory" camunda:type="external" camunda:topic="InventoryAddAudit"> <bpmn:incoming>SequenceFlow_0xndboi</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ee42yq</bpmn:outgoing> </bpmn:serviceTask> @@ -54,7 +54,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_07ybdik" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="ActivateVfModule" /> <bpmn:sequenceFlow id="SequenceFlow_0ghzwlo" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="Setup_AAI_Inventory_Audit"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded").equals("true")}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0ee42yq" sourceRef="Audit_AAI_Inventory" targetRef="ActivateVfModule" /> <bpmn:serviceTask id="CheckAuditVariable" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 804ae70c58..e1b36cfe65 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1"> <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true"> <bpmn:startEvent id="DeleteVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1537yw5</bpmn:outgoing> </bpmn:startEvent> <bpmn:serviceTask id="DeleteVfModuleVnfAdapter" name="Delete Vf Module VnfAdapter" camunda:expression="${VnfAdapterDeleteTasks.deleteVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1537yw5</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1n8gab5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_08tvhtf</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_1537yw5" sourceRef="DeleteVfModuleBB_Start" targetRef="DeleteVfModuleVnfAdapter" /> + <bpmn:sequenceFlow id="SequenceFlow_1537yw5" sourceRef="DeleteVfModuleBB_Start" targetRef="ExclusiveGateway_0xrgzm7" /> <bpmn:serviceTask id="UpdateVfModuleDeleteStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusDeleteVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_01vfwtp</bpmn:incoming> <bpmn:outgoing>SequenceFlow_09l7pcg</bpmn:outgoing> @@ -32,7 +32,7 @@ <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="DeleteNetworkPolicies" /> + <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="ExclusiveGateway_1yvh16a" /> <bpmn:subProcess id="SubProcess_11p7mrh" name="Error Handling " triggeredByEvent="true"> <bpmn:startEvent id="StartEvent_1xp6ewt"> <bpmn:outgoing>SequenceFlow_0h607z0</bpmn:outgoing> @@ -52,7 +52,7 @@ <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" /> <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> <bpmn:serviceTask id="DeleteNetworkPolicies" name="AAI Delete (network policies)" camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:incoming>SequenceFlow_14bu4ys</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -70,133 +70,280 @@ <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1n8gab5" sourceRef="ExclusiveGateway_0xrgzm7" targetRef="DeleteVfModuleVnfAdapter" /> + <bpmn:parallelGateway id="ExclusiveGateway_0xrgzm7"> + <bpmn:incoming>SequenceFlow_1537yw5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1n8gab5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1v3jgqe</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:sequenceFlow id="SequenceFlow_032jv5j" name="Yes " sourceRef="ExclusiveGateway_1h2ystu" targetRef="Setup_Audit_Variable"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0qfmmgt" sourceRef="Audit_Inventory" targetRef="ExclusiveGateway_1pydilb" /> + <bpmn:sequenceFlow id="SequenceFlow_14bu4ys" sourceRef="ExclusiveGateway_1yvh16a" targetRef="DeleteNetworkPolicies" /> + <bpmn:parallelGateway id="ExclusiveGateway_1yvh16a"> + <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ut7n32</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing> + </bpmn:parallelGateway> + <bpmn:sequenceFlow id="SequenceFlow_1mgunf3" name="No" sourceRef="ExclusiveGateway_1h2ystu" targetRef="ExclusiveGateway_1pydilb" /> + <bpmn:serviceTask id="Check_Audit" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1v3jgqe</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1odt2wt</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1v3jgqe" sourceRef="ExclusiveGateway_0xrgzm7" targetRef="Check_Audit" /> + <bpmn:sequenceFlow id="SequenceFlow_1odt2wt" sourceRef="Check_Audit" targetRef="ExclusiveGateway_1h2ystu" /> + <bpmn:sequenceFlow id="SequenceFlow_1swistn" sourceRef="Setup_Audit_Variable" targetRef="Audit_Inventory" /> + <bpmn:serviceTask id="Audit_Inventory" name="Audit Inventory For Delete in AAI" camunda:type="external" camunda:topic="InventoryDeleteAudit"> + <bpmn:incoming>SequenceFlow_1swistn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qfmmgt</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="Setup_Audit_Variable" name="Setup Audit Variable" camunda:expression="${AuditTasks.setupAuditVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_032jv5j</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1swistn</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1ut7n32" sourceRef="ExclusiveGateway_1pydilb" targetRef="ExclusiveGateway_1yvh16a" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1h2ystu" name="Audit Enabled?" default="SequenceFlow_1mgunf3"> + <bpmn:incoming>SequenceFlow_1odt2wt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_032jv5j</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1mgunf3</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:exclusiveGateway id="ExclusiveGateway_1pydilb"> + <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1mgunf3</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ut7n32</bpmn:outgoing> + </bpmn:exclusiveGateway> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteVfModuleBB_Start"> - <dc:Bounds x="173" y="102" width="36" height="36" /> + <dc:Bounds x="159" y="241" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="179" y="138" width="24" height="12" /> + <dc:Bounds x="132" y="277" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_16798zf_di" bpmnElement="DeleteVfModuleVnfAdapter"> - <dc:Bounds x="261" y="80" width="100" height="80" /> + <dc:Bounds x="382" y="278" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1537yw5_di" bpmnElement="SequenceFlow_1537yw5"> - <di:waypoint xsi:type="dc:Point" x="209" y="120" /> - <di:waypoint xsi:type="dc:Point" x="261" y="120" /> + <di:waypoint xsi:type="dc:Point" x="195" y="259" /> + <di:waypoint xsi:type="dc:Point" x="282" y="259" /> <bpmndi:BPMNLabel> - <dc:Bounds x="190" y="99" width="90" height="12" /> + <dc:Bounds x="193.5" y="238" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus"> - <dc:Bounds x="758" y="243" width="100" height="80" /> + <dc:Bounds x="840" y="443" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf"> - <di:waypoint xsi:type="dc:Point" x="361" y="120" /> - <di:waypoint xsi:type="dc:Point" x="427" y="120" /> + <di:waypoint xsi:type="dc:Point" x="482" y="318" /> + <di:waypoint xsi:type="dc:Point" x="511" y="318" /> <bpmndi:BPMNLabel> - <dc:Bounds x="349" y="99" width="90" height="12" /> + <dc:Bounds x="451.5" y="297" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End"> - <dc:Bounds x="918" y="265" width="36" height="36" /> + <dc:Bounds x="1087" y="465" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="936" y="305" width="0" height="0" /> + <dc:Bounds x="1060" y="505" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="427" y="80" width="100" height="80" /> + <dc:Bounds x="511" y="278" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87"> - <di:waypoint xsi:type="dc:Point" x="527" y="120" /> - <di:waypoint xsi:type="dc:Point" x="591" y="120" /> + <di:waypoint xsi:type="dc:Point" x="611" y="318" /> + <di:waypoint xsi:type="dc:Point" x="836" y="318" /> + <di:waypoint xsi:type="dc:Point" x="836" y="284" /> <bpmndi:BPMNLabel> - <dc:Bounds x="559" y="105" width="0" height="0" /> + <dc:Bounds x="678.5" y="303" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true"> - <dc:Bounds x="295" y="412" width="231" height="135" /> + <dc:Bounds x="294" y="618" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt"> - <dc:Bounds x="338" y="474" width="36" height="36" /> + <dc:Bounds x="337" y="680" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="311" y="510" width="0" height="0" /> + <dc:Bounds x="265" y="716" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau"> - <dc:Bounds x="467" y="474" width="36" height="36" /> + <dc:Bounds x="466" y="680" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="440" y="510" width="0" height="0" /> + <dc:Bounds x="394" y="716" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0"> - <di:waypoint xsi:type="dc:Point" x="374" y="492" /> - <di:waypoint xsi:type="dc:Point" x="467" y="492" /> + <di:waypoint xsi:type="dc:Point" x="373" y="698" /> + <di:waypoint xsi:type="dc:Point" x="466" y="698" /> <bpmndi:BPMNLabel> - <dc:Bounds x="421" y="471" width="0" height="0" /> + <dc:Bounds x="375" y="677" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="591" y="243" width="100" height="80" /> + <dc:Bounds x="706" y="443" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp"> - <di:waypoint xsi:type="dc:Point" x="691" y="283" /> - <di:waypoint xsi:type="dc:Point" x="758" y="283" /> + <di:waypoint xsi:type="dc:Point" x="806" y="483" /> + <di:waypoint xsi:type="dc:Point" x="840" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="725" y="268" width="0" height="0" /> + <dc:Bounds x="778" y="468" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg"> - <di:waypoint xsi:type="dc:Point" x="858" y="283" /> - <di:waypoint xsi:type="dc:Point" x="918" y="283" /> + <di:waypoint xsi:type="dc:Point" x="940" y="483" /> + <di:waypoint xsi:type="dc:Point" x="1087" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="888" y="258" width="0" height="0" /> + <dc:Bounds x="968.5" y="468" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk"> - <di:waypoint xsi:type="dc:Point" x="691" y="120" /> - <di:waypoint xsi:type="dc:Point" x="751" y="120" /> + <di:waypoint xsi:type="dc:Point" x="998" y="259" /> + <di:waypoint xsi:type="dc:Point" x="1072" y="259" /> + <di:waypoint xsi:type="dc:Point" x="1072" y="399" /> + <di:waypoint xsi:type="dc:Point" x="233" y="399" /> + <di:waypoint xsi:type="dc:Point" x="233" y="483" /> + <di:waypoint xsi:type="dc:Point" x="280" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="721" y="105" width="0" height="0" /> + <dc:Bounds x="607.5" y="384" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies"> - <dc:Bounds x="591" y="80" width="100" height="80" /> + <dc:Bounds x="898" y="219" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="261" y="243" width="100" height="80" /> + <dc:Bounds x="421" y="443" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b"> - <di:waypoint xsi:type="dc:Point" x="851" y="120" /> - <di:waypoint xsi:type="dc:Point" x="941" y="120" /> - <di:waypoint xsi:type="dc:Point" x="941" y="205" /> - <di:waypoint xsi:type="dc:Point" x="182" y="205" /> - <di:waypoint xsi:type="dc:Point" x="182" y="283" /> - <di:waypoint xsi:type="dc:Point" x="261" y="283" /> + <di:waypoint xsi:type="dc:Point" x="380" y="483" /> + <di:waypoint xsi:type="dc:Point" x="421" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="562" y="190" width="0" height="0" /> + <dc:Bounds x="355.5" y="468" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="751" y="80" width="100" height="80" /> + <dc:Bounds x="280" y="443" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc"> - <di:waypoint xsi:type="dc:Point" x="361" y="283" /> - <di:waypoint xsi:type="dc:Point" x="427" y="283" /> + <di:waypoint xsi:type="dc:Point" x="521" y="483" /> + <di:waypoint xsi:type="dc:Point" x="561" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="394" y="268" width="0" height="0" /> + <dc:Bounds x="496" y="468" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z"> - <di:waypoint xsi:type="dc:Point" x="527" y="283" /> - <di:waypoint xsi:type="dc:Point" x="591" y="283" /> + <di:waypoint xsi:type="dc:Point" x="661" y="483" /> + <di:waypoint xsi:type="dc:Point" x="706" y="483" /> <bpmndi:BPMNLabel> - <dc:Bounds x="559" y="268" width="0" height="0" /> + <dc:Bounds x="638.5" y="468" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="427" y="243" width="100" height="80" /> + <dc:Bounds x="561" y="443" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1n8gab5_di" bpmnElement="SequenceFlow_1n8gab5"> + <di:waypoint xsi:type="dc:Point" x="307" y="284" /> + <di:waypoint xsi:type="dc:Point" x="307" y="318" /> + <di:waypoint xsi:type="dc:Point" x="382" y="318" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="277" y="294.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ParallelGateway_18x6mx2_di" bpmnElement="ExclusiveGateway_0xrgzm7"> + <dc:Bounds x="282" y="234" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="262" y="287" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_032jv5j_di" bpmnElement="SequenceFlow_032jv5j"> + <di:waypoint xsi:type="dc:Point" x="492" y="149" /> + <di:waypoint xsi:type="dc:Point" x="492" y="108" /> + <di:waypoint xsi:type="dc:Point" x="531" y="108" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="499" y="114" width="18" height="25" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qfmmgt_di" bpmnElement="SequenceFlow_0qfmmgt"> + <di:waypoint xsi:type="dc:Point" x="754" y="108" /> + <di:waypoint xsi:type="dc:Point" x="784" y="108" /> + <di:waypoint xsi:type="dc:Point" x="784" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="724" y="86.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_14bu4ys_di" bpmnElement="SequenceFlow_14bu4ys"> + <di:waypoint xsi:type="dc:Point" x="861" y="259" /> + <di:waypoint xsi:type="dc:Point" x="898" y="259" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="834.5" y="237.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ParallelGateway_02fjfb8_di" bpmnElement="ExclusiveGateway_1yvh16a"> + <dc:Bounds x="811" y="234" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="790" y="287" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1mgunf3_di" bpmnElement="SequenceFlow_1mgunf3"> + <di:waypoint xsi:type="dc:Point" x="492" y="199" /> + <di:waypoint xsi:type="dc:Point" x="492" y="232" /> + <di:waypoint xsi:type="dc:Point" x="784" y="232" /> + <di:waypoint xsi:type="dc:Point" x="784" y="199" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="499" y="212" width="15" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1vmz3zo_di" bpmnElement="Check_Audit"> + <dc:Bounds x="339" y="134" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1v3jgqe_di" bpmnElement="SequenceFlow_1v3jgqe"> + <di:waypoint xsi:type="dc:Point" x="307" y="234" /> + <di:waypoint xsi:type="dc:Point" x="307" y="174" /> + <di:waypoint xsi:type="dc:Point" x="339" y="174" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="277" y="197.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1odt2wt_di" bpmnElement="SequenceFlow_1odt2wt"> + <di:waypoint xsi:type="dc:Point" x="439" y="174" /> + <di:waypoint xsi:type="dc:Point" x="467" y="174" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="408" y="152.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1swistn_di" bpmnElement="SequenceFlow_1swistn"> + <di:waypoint xsi:type="dc:Point" x="631" y="108" /> + <di:waypoint xsi:type="dc:Point" x="654" y="108" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="597.5" y="86.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1l8r2a6_di" bpmnElement="Audit_Inventory"> + <dc:Bounds x="654" y="68" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1gttdjr_di" bpmnElement="Setup_Audit_Variable"> + <dc:Bounds x="531" y="68" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ut7n32_di" bpmnElement="SequenceFlow_1ut7n32"> + <di:waypoint xsi:type="dc:Point" x="809" y="174" /> + <di:waypoint xsi:type="dc:Point" x="836" y="174" /> + <di:waypoint xsi:type="dc:Point" x="836" y="234" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="777.5" y="152.5" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1olwkdn_di" bpmnElement="ExclusiveGateway_1h2ystu" isMarkerVisible="true"> + <dc:Bounds x="467" y="149" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="518" y="162" width="47" height="25" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1d1pmqz_di" bpmnElement="ExclusiveGateway_1pydilb" isMarkerVisible="true"> + <dc:Bounds x="759" y="149" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="694" y="202" width="0" height="13" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java index 9ffcd9d77a..2dae1173d6 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java @@ -47,13 +47,13 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{ mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables); List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAudit", 60L * 1000L).execute(); + .topic("InventoryAddAudit", 60L * 1000L).execute(); while (!tasks.isEmpty()) { for (LockedExternalTask task : tasks) { externalTaskService.complete(task.getId(), "externalWorkerId"); } tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAudit", 60L * 1000L).execute(); + .topic("InventoryAddAudit", 60L * 1000L).execute(); } assertThat(pi).isNotNull(); @@ -68,13 +68,13 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{ doThrow(BpmnError.class).when(aaiUpdateTasks).updateOrchestrationStatusActivateVfModule(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables); List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAudit", 60L * 1000L).execute(); + .topic("InventoryAddAudit", 60L * 1000L).execute(); while (!tasks.isEmpty()) { for (LockedExternalTask task : tasks) { externalTaskService.complete(task.getId(), "externalWorkerId"); } tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAudit", 60L * 1000L).execute(); + .topic("InventoryAddAudit", 60L * 1000L).execute(); } assertThat(pi).isNotNull().isStarted() diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java index cedffb77d4..48ae22cb1a 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.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. @@ -23,21 +23,40 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import java.io.IOException; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; import org.junit.Test; import org.onap.so.bpmn.BaseBPMNTest; import org.onap.so.bpmn.common.BuildingBlockExecution; public class DeleteVfModuleBBTest extends BaseBPMNTest{ + + @Before + public void before() { + variables.put("auditInventoryNeeded", true); + } + @Test public void sunnyDay() throws InterruptedException, IOException { mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub"); mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables); + List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") + .topic("InventoryDeleteAudit", 60L * 1000L).execute(); + while (!tasks.isEmpty()) { + for (LockedExternalTask task : tasks) { + externalTaskService.complete(task.getId(), "externalWorkerId"); + } + tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") + .topic("InventoryDeleteAudit", 60L * 1000L).execute(); + } assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter", "VnfAdapter", + assertThat(pi).isStarted().hasPassed("DeleteVfModuleBB_Start","ExclusiveGateway_0xrgzm7","ExclusiveGateway_1yvh16a","Check_Audit", + "Setup_Audit_Variable","Audit_Inventory","DeleteVfModuleVnfAdapter", "VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); @@ -48,10 +67,19 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ public void rainyDay() throws Exception { doThrow(BpmnError.class).when(vnfAdapterDeleteTasks).deleteVfModule(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables); + List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") + .topic("InventoryDeleteAudit", 60L * 1000L).execute(); + while (!tasks.isEmpty()) { + for (LockedExternalTask task : tasks) { + externalTaskService.complete(task.getId(), "externalWorkerId"); + } + tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") + .topic("InventoryDeleteAudit", 60L * 1000L).execute(); + } assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter") - .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + .hasPassed("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter") + .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml b/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml index d8f6ba3930..c080bc90f8 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml @@ -21,7 +21,8 @@ <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> <appender-ref ref="STDOUT" /> </logger> - <root level="WARN"> + + <root level="INFO"> <appender-ref ref="STDOUT" /> </root> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java index 932558d8ad..1815fcd827 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java @@ -9,9 +9,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. @@ -43,6 +43,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import static org.apache.commons.lang3.StringUtils.*; @Component public class VnfAdapterCreateTasks { @@ -91,25 +92,27 @@ public class VnfAdapterCreateTasks { public void createVfModule(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - + ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); VolumeGroup volumeGroup = null; try { volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); - } catch(BBObjectNotFoundException bbException) { + } catch(BBObjectNotFoundException bbException) { } CloudRegion cloudRegion = gBBInput.getCloudRegion(); RequestContext requestContext = gBBInput.getRequestContext(); OrchestrationContext orchestrationContext = gBBInput.getOrchContext(); String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()); String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()); - + CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse); execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString()); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java index aaa9e51d15..8cb7cbbe91 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.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. @@ -38,22 +38,22 @@ import org.springframework.stereotype.Component; @Component public class AuditTasks { - + private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class); @Autowired private ExceptionBuilder exceptionUtil; - + @Autowired private ExtractPojosForBB extractPojosForBB; - + @Autowired private Environment env; - + public void isAuditNeeded(BuildingBlockExecution execution) { - try { + try { logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory")); - execution.setVariable("auditInventoryNeeded",env.getProperty("mso.infra.auditInventory")); + execution.setVariable("auditInventoryNeeded", Boolean.parseBoolean(env.getProperty("mso.infra.auditInventory"))); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -66,14 +66,14 @@ public class AuditTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - + private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException { AuditInventory auditInventory = new AuditInventory(); - + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - + auditInventory.setCloudOwner(cloudRegion.getCloudOwner()); auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId()); auditInventory.setTenantId(cloudRegion.getTenantId()); 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 1f9f5f5fbe..0b2b1e73b4 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 @@ -1249,6 +1249,7 @@ public class ServiceInstances { 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, MsoLogger.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(); |