diff options
54 files changed, 903 insertions, 157 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql new file mode 100644 index 0000000000..c0cec5da31 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql @@ -0,0 +1,17 @@ +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; + +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGASSIGNED', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; + +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGURE', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; + +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGURE', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; + +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGURED', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; + +INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES +('VNF', 'CONFIGURED', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql index 81e6092f5f..1d26c4c8d9 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql @@ -1,2 +1,2 @@ INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) -VALUES ('VNF', 'CONFIGURED', 'ACTIVATE', 'CONTINUE'); +VALUES ('VNF', 'CONFIGURED', 'ACTIVATE', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE='CONTINUE'; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java index 9f48144eb8..4fe49e38dd 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java @@ -143,6 +143,8 @@ public class ArchiveInfraRequestsScheduler { archivedInfra.setProductFamilyName(iar.getProductFamilyName()); archivedInfra.setTenantName(iar.getTenantName()); archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage()); + archivedInfra.setWorkflowName(iar.getWorkflowName()); + archivedInfra.setOperationName(iar.getOperationName()); newArchivedReqs.add(archivedInfra); oldInfraReqs.add(iar); diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.3__Add_Columns_Workflow_Name_Operation_Name.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.3__Add_Columns_Workflow_Name_Operation_Name.sql new file mode 100644 index 0000000000..d493bc01ac --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.3__Add_Columns_Workflow_Name_Operation_Name.sql @@ -0,0 +1,7 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS WORKFLOW_NAME varchar(200); +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS WORKFLOW_NAME varchar(200); + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS OPERATION_NAME varchar(200); +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS OPERATION_NAME varchar(200);
\ No newline at end of file diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java index aa8c7f68c9..e8660086c0 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.vevnfm.aai; import java.net.MalformedURLException; import java.net.URL; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; import org.onap.so.spring.SpringContextHelper; @@ -29,15 +30,18 @@ import org.springframework.context.ApplicationContext; public class AaiPropertiesExt implements AAIProperties { + private static final String MSO = "MSO"; + private final String endpoint; private final String encryptedBasicAuth; private final String encryptionKey; public AaiPropertiesExt() { final ApplicationContext context = SpringContextHelper.getAppContext(); - this.endpoint = context.getEnvironment().getProperty("aai.endpoint"); - this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth"); - this.encryptionKey = context.getEnvironment().getProperty("mso.key"); + final ConfigProperties configProperties = context.getBean(ConfigProperties.class); + this.endpoint = configProperties.getAaiEndpoint(); + this.encryptedBasicAuth = configProperties.getAaiAuth(); + this.encryptionKey = configProperties.getMsoKey(); } @Override @@ -47,7 +51,7 @@ public class AaiPropertiesExt implements AAIProperties { @Override public String getSystemName() { - return "MSO"; + return MSO; } @Override diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java new file mode 100644 index 0000000000..d4ca5af0f2 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java @@ -0,0 +1,134 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. 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.vevnfm.configuration; + +import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ConfigProperties { + + @Value("${vevnfmadapter.vnf-filter-json}") + private String vevnfmadapterVnfFilterJson; + + @Value("${vevnfmadapter.endpoint}") + private String vevnfmadapterEndpoint; + + @Value("${mso.key}") + private String msoKey; + + @Value("${aai.endpoint}") + private String aaiEndpoint; + + @Value("${aai.auth}") + private String aaiAuth; + + @Value("${vnfm.default-endpoint}") + private String vnfmDefaultEndpoint; + + @Value("${vnfm.subscription}") + private String vnfmSubscription; + + @Value("${vnfm.notification}") + private String vnfmNotification; + + @Value("${notification.vnf-filter-type}") + private NotificationVnfFilterType notificationVnfFilterType; + + @Value("${dmaap.endpoint}") + private String dmaapEndpoint; + + @Value("${dmaap.topic}") + private String dmaapTopic; + + @Value("${dmaap.closed-loop.control.name}") + private String dmaapClosedLoopControlName; + + @Value("${dmaap.version}") + private String dmaapVersion; + + @Value("${spring.security.usercredentials[0].username}") + private String springSecurityUsername; + + @Value("${spring.security.usercredentials[0].openpass}") + private String springSecurityOpenpass; + + public String getVevnfmadapterVnfFilterJson() { + return vevnfmadapterVnfFilterJson; + } + + public String getVevnfmadapterEndpoint() { + return vevnfmadapterEndpoint; + } + + public String getMsoKey() { + return msoKey; + } + + public String getAaiEndpoint() { + return aaiEndpoint; + } + + public String getAaiAuth() { + return aaiAuth; + } + + public String getVnfmDefaultEndpoint() { + return vnfmDefaultEndpoint; + } + + public String getVnfmSubscription() { + return vnfmSubscription; + } + + public String getVnfmNotification() { + return vnfmNotification; + } + + public NotificationVnfFilterType getNotificationVnfFilterType() { + return notificationVnfFilterType; + } + + public String getDmaapEndpoint() { + return dmaapEndpoint; + } + + public String getDmaapTopic() { + return dmaapTopic; + } + + public String getDmaapClosedLoopControlName() { + return dmaapClosedLoopControlName; + } + + public String getDmaapVersion() { + return dmaapVersion; + } + + public String getSpringSecurityUsername() { + return springSecurityUsername; + } + + public String getSpringSecurityOpenpass() { + return springSecurityOpenpass; + } +} diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java index c033fc3f96..8b5afbf6a1 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java @@ -36,14 +36,17 @@ public class StartupConfiguration { public static final String TEST_PROFILE = "test"; - @Autowired - private Environment environment; - - @Autowired - private StartupService startupService; + private final Environment environment; + private final StartupService startupService; + private final SubscriptionScheduler subscriptionScheduler; @Autowired - private SubscriptionScheduler subscriptionScheduler; + public StartupConfiguration(final Environment environment, final StartupService startupService, + final SubscriptionScheduler subscriptionScheduler) { + this.environment = environment; + this.startupService = startupService; + this.subscriptionScheduler = subscriptionScheduler; + } @EventListener(ApplicationReadyEvent.class) public void onApplicationReadyEvent() throws Exception { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/constant/VnfNotificationFilterType.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/constant/NotificationVnfFilterType.java index 09a6ae186d..57935a9fda 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/constant/VnfNotificationFilterType.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/constant/NotificationVnfFilterType.java @@ -21,9 +21,9 @@ package org.onap.so.adapters.vevnfm.constant; /** - * Which incoming Notification with particular VNF id is supported + * Select which incoming Notification with particular VNF id should be supported */ -public enum VnfNotificationFilterType { +public enum NotificationVnfFilterType { /** * None */ diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java index e187ec99d0..5b1f27f2ca 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java @@ -20,14 +20,14 @@ package org.onap.so.adapters.vevnfm.controller; -import org.onap.so.adapters.vevnfm.constant.VnfNotificationFilterType; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; +import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.onap.so.adapters.vevnfm.service.DmaapService; import org.onap.so.adapters.vevnfm.service.VnfAaiChecker; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -38,15 +38,14 @@ public class NotificationController { private static final Logger logger = LoggerFactory.getLogger(NotificationController.class); - private final VnfNotificationFilterType vnfFilterType; + private final NotificationVnfFilterType notificationVnfFilterType; private final VnfAaiChecker vnfAaiChecker; private final DmaapService dmaapService; @Autowired - public NotificationController( - @Value("${notification.vnf-filter-type}") final VnfNotificationFilterType vnfFilterType, - final VnfAaiChecker vnfAaiChecker, final DmaapService dmaapService) { - this.vnfFilterType = vnfFilterType; + public NotificationController(final ConfigProperties configProperties, final VnfAaiChecker vnfAaiChecker, + final DmaapService dmaapService) { + this.notificationVnfFilterType = configProperties.getNotificationVnfFilterType(); this.vnfAaiChecker = vnfAaiChecker; this.dmaapService = dmaapService; } @@ -57,7 +56,7 @@ public class NotificationController { final String vnfInstanceId = notification.getVnfInstanceId(); - if (vnfAaiChecker.vnfCheck(vnfFilterType, vnfInstanceId)) { + if (vnfAaiChecker.vnfCheck(notificationVnfFilterType, vnfInstanceId)) { logger.info("The info with the VNF id '{}' is sent to DMaaP", vnfInstanceId); dmaapService.send(notification); } else { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java index c685ae815a..d6fa86cd29 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java @@ -20,13 +20,13 @@ package org.onap.so.adapters.vevnfm.service; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.event.DmaapEvent; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -36,20 +36,20 @@ public class DmaapService { private static final Logger logger = LoggerFactory.getLogger(DmaapService.class); - @Value("${dmaap.endpoint}") - private String endpoint; - - @Value("${dmaap.topic}") - private String topic; - - @Value("${dmaap.closed-loop.control.name}") - private String closedLoopControlName; - - @Value("${dmaap.version}") - private String version; + private final String endpoint; + private final String topic; + private final String closedLoopControlName; + private final String version; + private final HttpRestServiceProvider restProvider; @Autowired - private HttpRestServiceProvider restProvider; + public DmaapService(final ConfigProperties configProperties, final HttpRestServiceProvider restProvider) { + this.endpoint = configProperties.getDmaapEndpoint(); + this.topic = configProperties.getDmaapTopic(); + this.closedLoopControlName = configProperties.getDmaapClosedLoopControlName(); + this.version = configProperties.getDmaapVersion(); + this.restProvider = restProvider; + } public void send(final VnfLcmOperationOccurrenceNotification notification) { try { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index 92906ef35c..c128275e43 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -24,11 +24,11 @@ import java.util.Collections; import java.util.List; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.aai.AaiConnection; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Recover; @@ -41,11 +41,14 @@ public class StartupService { private static final Logger logger = LoggerFactory.getLogger(StartupService.class); - @Value("${vnfm.default-endpoint}") - private String vnfmDefaultEndpoint; + private final String vnfmDefaultEndpoint; + private final AaiConnection aaiConnection; @Autowired - private AaiConnection aaiConnection; + public StartupService(final ConfigProperties configProperties, final AaiConnection aaiConnection) { + this.vnfmDefaultEndpoint = configProperties.getVnfmDefaultEndpoint(); + this.aaiConnection = aaiConnection; + } @Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(delay = 5000, multiplier = 2)) public List<EsrSystemInfo> receiveVnfm() throws VeVnfmException { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java index d01c3c8f66..4cce0773fb 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java @@ -22,13 +22,13 @@ package org.onap.so.adapters.vevnfm.service; import com.fasterxml.jackson.annotation.JsonProperty; import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -41,11 +41,14 @@ public class SubscribeSender { private static final Logger logger = LoggerFactory.getLogger(SubscribeSender.class); - @Value("${vnfm.subscription}") - private String vnfmSubscription; + private final String vnfmSubscription; + private final HttpRestServiceProvider restProvider; @Autowired - private HttpRestServiceProvider restProvider; + public SubscribeSender(final ConfigProperties configProperties, final HttpRestServiceProvider restProvider) { + this.vnfmSubscription = configProperties.getVnfmSubscription(); + this.restProvider = restProvider; + } public String send(final EsrSystemInfo info, final LccnSubscriptionRequest request) throws VeVnfmException { final ResponseEntity<SubscribeToManoResponse> response = diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java index d2cf4833ba..cad44eaeed 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java @@ -25,6 +25,7 @@ import com.squareup.okhttp.Credentials; import java.util.Collections; import org.apache.logging.log4j.util.Strings; import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; @@ -32,7 +33,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthe import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service @@ -40,26 +40,25 @@ public class SubscriberService { private static final Gson gson = new Gson(); - @Value("${vevnfmadapter.vnf-filter-json}") - private String vnfFilter; - - @Value("${vevnfmadapter.endpoint}") - private String endpoint; - - @Value("${vnfm.notification}") - private String notification; - - @Value("${spring.security.usercredentials[0].username}") - private String username; - - @Value("${spring.security.usercredentials[0].openpass}") - private String openpass; + private final String vnfFilter; + private final String endpoint; + private final String notification; + private final String username; + private final String openpass; + private final AuthorizationHeadersProvider headersProvider; + private final SubscribeSender sender; @Autowired - private AuthorizationHeadersProvider headersProvider; - - @Autowired - private SubscribeSender sender; + public SubscriberService(final ConfigProperties configProperties, + final AuthorizationHeadersProvider headersProvider, final SubscribeSender sender) { + this.vnfFilter = configProperties.getVevnfmadapterVnfFilterJson(); + this.endpoint = configProperties.getVevnfmadapterEndpoint(); + this.notification = configProperties.getVnfmNotification(); + this.username = configProperties.getSpringSecurityUsername(); + this.openpass = configProperties.getSpringSecurityOpenpass(); + this.headersProvider = headersProvider; + this.sender = sender; + } private static String getAuthorization(final EsrSystemInfo info) { if (info == null) { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java index d9f3acc3df..a696336011 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java @@ -38,11 +38,14 @@ public class SubscriptionScheduler { private static final Logger logger = LoggerFactory.getLogger(SubscriptionScheduler.class); - @Autowired - private SubscriberService subscriberService; - + private final SubscriberService subscriberService; private List<EsrId> esrIds; + @Autowired + public SubscriptionScheduler(final SubscriberService subscriberService) { + this.subscriberService = subscriberService; + } + public void setInfos(final List<EsrSystemInfo> infos) { esrIds = new LinkedList<>(); diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/VnfAaiChecker.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/VnfAaiChecker.java index 02a9c1855c..1442fa2862 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/VnfAaiChecker.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/VnfAaiChecker.java @@ -21,7 +21,7 @@ package org.onap.so.adapters.vevnfm.service; import org.onap.so.adapters.vevnfm.aai.AaiConnection; -import org.onap.so.adapters.vevnfm.constant.VnfNotificationFilterType; +import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -35,7 +35,7 @@ public class VnfAaiChecker { this.aaiConnection = aaiConnection; } - public boolean vnfCheck(final VnfNotificationFilterType filterType, final String vnfId) { + public boolean vnfCheck(final NotificationVnfFilterType filterType, final String vnfId) { switch (filterType) { case ALL: return true; diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java index 56c53a72e8..27def126ef 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java @@ -26,9 +26,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -52,8 +52,8 @@ public class NotificationControllerTest { private static final String MINIMAL_JSON_CONTENT = "{}"; private static final int ZERO = 0; - @Value("${vnfm.notification}") - private String notification; + @Autowired + private ConfigProperties configProperties; @Autowired private WebApplicationContext webApplicationContext; @@ -61,11 +61,13 @@ public class NotificationControllerTest { @Autowired private RestTemplate restTemplate; + private String notification; private MockMvc mvc; private MockRestServiceServer mockRestServer; @Before public void init() { + notification = configProperties.getVnfmNotification(); mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); mockRestServer = MockRestServiceServer.bindTo(restTemplate).build(); } diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java index 9b18cf96dc..5d5ffa6555 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java @@ -34,16 +34,21 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.aai.AaiConnection; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; @RunWith(MockitoJUnitRunner.class) public class StartupServiceTest { private static final String URL = "rt"; + private static final String ENDPOINT = "localhost"; @Rule public ExpectedException thrown = ExpectedException.none(); @Mock + private ConfigProperties configProperties; + + @Mock private AaiConnection aaiConnection; @InjectMocks diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java index b7f1f982a2..02d664e206 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java @@ -33,11 +33,11 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -64,8 +64,8 @@ public class SubscribeSenderTest { GSON = builder.create(); } - @Value("${vnfm.subscription}") - private String vnfmSubscription; + @Autowired + private ConfigProperties configProperties; @Autowired private SubscribeSender sender; @@ -73,10 +73,12 @@ public class SubscribeSenderTest { @Autowired private RestTemplate restTemplate; + private String vnfmSubscription; private MockRestServiceServer mockRestServer; @Before public void init() { + vnfmSubscription = configProperties.getVnfmSubscription(); mockRestServer = MockRestServiceServer.bindTo(restTemplate).build(); } diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java index 84705d10ce..da5992ee42 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java @@ -30,7 +30,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.adapters.vevnfm.aai.AaiConnection; -import org.onap.so.adapters.vevnfm.constant.VnfNotificationFilterType; +import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; @RunWith(MockitoJUnitRunner.class) public class VnfAaiCheckerTest { @@ -46,7 +46,7 @@ public class VnfAaiCheckerTest { @Test public void testAll() { // when - final boolean response = checker.vnfCheck(VnfNotificationFilterType.ALL, VNF_ID); + final boolean response = checker.vnfCheck(NotificationVnfFilterType.ALL, VNF_ID); // then assertTrue(response); @@ -58,7 +58,7 @@ public class VnfAaiCheckerTest { when(aaiConnection.checkGenericVnfId(eq(VNF_ID))).thenReturn(true); // when - final boolean response = checker.vnfCheck(VnfNotificationFilterType.AAI_CHECKED, VNF_ID); + final boolean response = checker.vnfCheck(NotificationVnfFilterType.AAI_CHECKED, VNF_ID); // then assertTrue(response); @@ -70,7 +70,7 @@ public class VnfAaiCheckerTest { when(aaiConnection.checkGenericVnfId(eq(VNF_ID))).thenReturn(false); // when - final boolean response = checker.vnfCheck(VnfNotificationFilterType.AAI_CHECKED, VNF_ID); + final boolean response = checker.vnfCheck(NotificationVnfFilterType.AAI_CHECKED, VNF_ID); // then assertFalse(response); @@ -79,7 +79,7 @@ public class VnfAaiCheckerTest { @Test public void testNone() { // when - final boolean response = checker.vnfCheck(VnfNotificationFilterType.NONE, VNF_ID); + final boolean response = checker.vnfCheck(NotificationVnfFilterType.NONE, VNF_ID); // then assertFalse(response); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java index 9294677b95..3d6fbb21ef 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java @@ -343,6 +343,43 @@ public class ASDCRestInterfaceTest extends BaseTest { } @Test + public void test_E2ESlicing_Distribution() throws Exception { + wireMockServer.stubFor(post(urlPathMatching("/aai/.*")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json"))); + + wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withStatus(org.springframework.http.HttpStatus.ACCEPTED.value()))); + String resourceLocation = "src/test/resources/resource-examples/e2eSlicing/"; + ObjectMapper mapper = new ObjectMapper(); + + NotificationDataImpl request; + HttpEntity<NotificationDataImpl> entity; + ResponseEntity<String> response; + headers.add("resource-location", resourceLocation); + + request = mapper.readValue(new File(resourceLocation + "nsst-notification.json"), NotificationDataImpl.class); + entity = new HttpEntity<NotificationDataImpl>(request, headers); + response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, + String.class); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + request = mapper.readValue(new File(resourceLocation + "nst-notification.json"), NotificationDataImpl.class); + entity = new HttpEntity<NotificationDataImpl>(request, headers); + response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, + String.class); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + Optional<Service> service = serviceRepo.findById("7981375e-5e0a-4bf5-93fa-f3e3c02f2b11"); + assertTrue(service.isPresent()); + assertEquals("EmbbNst", service.get().getModelName()); + + service = serviceRepo.findById("637e9b93-208b-4b06-80f2-a2021c228174"); + assertTrue(service.isPresent()); + assertEquals("EmbbCn", service.get().getModelName()); + } + + @Test public void test_PublicNS_Distribution() throws Exception { wireMockServer.stubFor(post(urlPathMatching("/aai/.*")) .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json"))); diff --git a/asdc-controller/src/test/resources/resource-examples/e2eSlicing/eMBB.zip b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/eMBB.zip Binary files differnew file mode 100644 index 0000000000..ce0b901fdd --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/eMBB.zip diff --git a/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nsst-notification.json b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nsst-notification.json new file mode 100644 index 0000000000..49b1c10124 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nsst-notification.json @@ -0,0 +1,32 @@ +{ + "distributionID": "28ffbae6-f44a-408c-9ec1-e329c4a48e77", + "serviceName": "EmbbCn", + "serviceVersion": "1.0", + "serviceUUID": "2763777c-27bd-4df7-93b8-c690e23f4d3f", + "serviceDescription": "EmbbCn", + "serviceInvariantUUID": "0402fb4c-4a0c-4ff2-ad2b-29218ea1d629", + "resources": [], + "serviceArtifacts": [ + { + "artifactName": "eMBB.zip", + "artifactType": "OTHER", + "artifactURL": "/eMBB.zip", + "artifactChecksum": "ZWRkMGM3NzNjMmE3NzliYTFiZGNmZjVlMDE4OWEzMTA\u003d", + "artifactDescription": "EmbbCn", + "artifactTimeout": 0, + "artifactVersion": "1", + "artifactUUID": "3f669cc1-dbe7-48ea-b606-42f497b2ac46" + }, + { + "artifactName": "service-Embbcn-csar.csar", + "artifactType": "TOSCA_CSAR", + "artifactURL": "/service-Embbcn-csar.csar", + "artifactChecksum": "NTk5MDZhNzJkOWIwZDQ0YTNlNWM0Y2MyODI5Mzk0ZWU\u003d", + "artifactDescription": "TOSCA definition package of the asset", + "artifactTimeout": 0, + "artifactVersion": "1", + "artifactUUID": "dc0f2a41-4f71-452f-91c7-0444e4d8c33b" + } + ], + "workloadContext": "Production" +}
\ No newline at end of file diff --git a/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nst-notification.json b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nst-notification.json new file mode 100644 index 0000000000..8471a28b70 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/nst-notification.json @@ -0,0 +1,35 @@ +{ + "distributionID": "ece2fb37-6e4e-4989-b54e-9b0e00afb7cc", + "serviceName": "EmbbNst", + "serviceVersion": "1.0", + "serviceUUID": "e3958a85-65e0-4a77-8981-a51755aa9d39", + "serviceDescription": "Embb Nst Template", + "serviceInvariantUUID": "1899e5c1-df4e-43a8-a889-48c157dad7bc", + "resources": [ + { + "resourceInstanceName": "embbcn_proxy 0", + "resourceCustomizationUUID": "dd6f6ce9-1a23-4303-9466-22abf2a889dc", + "resourceName": "serviceProxy", + "resourceVersion": "1.0", + "resoucreType": "Service Proxy", + "resourceUUID": "4e8212a4-2a7a-4e76-9e0f-54411bc1c17d", + "resourceInvariantUUID": "b1fc926c-8cc3-4bda-8e50-27ba3536c47f", + "category": "Generic", + "subcategory": "Abstract", + "artifacts": [] + } + ], + "serviceArtifacts": [ + { + "artifactName": "service-Embbnst-csar.csar", + "artifactType": "TOSCA_CSAR", + "artifactURL": "/service-Embbnst-csar.csar", + "artifactChecksum": "YmEzMGFlOGY1MDBhMTg4MmFlYjkwODU1YjYzOTA5NDU\u003d", + "artifactDescription": "TOSCA definition package of the asset", + "artifactTimeout": 0, + "artifactVersion": "1", + "artifactUUID": "2a690bd3-4529-4437-9e9f-805eaaa25b4a" + } + ], + "workloadContext": "Production" +}
\ No newline at end of file diff --git a/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbcn-csar.csar b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbcn-csar.csar Binary files differnew file mode 100644 index 0000000000..775f35046a --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbcn-csar.csar diff --git a/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbnst-csar.csar b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbnst-csar.csar Binary files differnew file mode 100644 index 0000000000..e6e42e489f --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/e2eSlicing/service-Embbnst-csar.csar diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 5d9c1a3acd..ec8ad3127c 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -1,6 +1,5 @@ <?xml version="1.0"?> -<project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> @@ -23,7 +22,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> - <configuration> + <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> 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 f0954c3695..488b4aab41 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 @@ -631,18 +631,22 @@ public class BBInputSetup implements JavaDelegate { break; } } + VfModuleCustomization vfResourceCustomization = null; if (vnfResourceCustomization != null) { - VfModuleCustomization vfResourceCustomization = vnfResourceCustomization.getVfModuleCustomizations() - .stream() // Convert to steam + vfResourceCustomization = vnfResourceCustomization.getVfModuleCustomizations().stream() // Convert to steam .filter(x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID()))// find // what // we // want .findAny() // If 'findAny' then return found .orElse(null); - if (vfResourceCustomization != null) { - vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization)); - } + } + if (vfResourceCustomization == null) { + vfResourceCustomization = bbInputSetupUtils + .getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); + } + if (vfResourceCustomization != null) { + vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization)); } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index 59b34c4074..79b40ba385 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -57,9 +57,10 @@ abstract class MsoGroovyTest { protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString(); protected void init(String procName){ - mockExecution = setupMock(procName) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + // mockExecution = setupMock(procName) + // when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") client = mock(AAIResourcesClient.class) + mockExecution = mock(ExecutionEntity.class) } protected ExecutionEntity setupMock(String procName) { diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy index 99b178c044..39aadd29d7 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy @@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException import static org.mockito.Mockito.* import javax.ws.rs.NotFoundException - +import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before @@ -57,6 +57,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { void init() throws IOException { super.init("UpdateAAIVfModule") when(updateAAIVfModule.getAAIClient()).thenReturn(client) + mockExecution = setupMock("UpdateAAIVfModule") } @Test @@ -110,7 +111,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule) doNothing().when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) updateAAIVfModule.updateVfModule(mockExecution) - verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200) + verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200) } @Test @@ -126,7 +127,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) thrown.expect(BpmnError.class) updateAAIVfModule.updateVfModule(mockExecution) - verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404) + verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404) } @@ -143,7 +144,6 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject()) thrown.expect(BpmnError.class) updateAAIVfModule.updateVfModule(mockExecution) - verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500) - + verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500) } } 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 df7337c0d9..be9965b5b7 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 @@ -2947,6 +2947,31 @@ public class BBInputSetupTest { } @Test + public void testMapCatalogVfModuleIfNoVfUnderVnf() { + String vnfModelCustomizationUUID = "vnfResourceCustUUID"; + String vfModuleCustomizationUUID = "vfModelCustomizationUUID"; + VfModule vfModule = new VfModule(); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID); + Service service = new Service(); + VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization(); + vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID); + VfModuleCustomization vfModuleCust = new VfModuleCustomization(); + vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + doReturn(vfModuleCust).when(SPY_bbInputSetupUtils) + .getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID); + doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust); + + SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + + assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule)); + + verify(SPY_bbInputSetupUtils, times(1)) + .getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); + } + + @Test public void testPopulateVfModule() throws Exception { String vnfId = "vnfId"; String vfModuleId = "vfModuleId"; diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 1a4e9c6ee8..86df60bb54 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -32,11 +32,11 @@ </execution> </executions> </plugin> - <plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> - <configuration> + <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 1cde9fb8f6..e2dd73f9ec 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -24,6 +24,8 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.util.EnumSet; +import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; @@ -34,11 +36,15 @@ import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; +import org.onap.so.db.catalog.beans.ResourceType; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; @Component public class OrchestrationStatusValidator { @@ -52,6 +58,14 @@ public class OrchestrationStatusValidator { "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)"; private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult"; private static final String ALACARTE = "aLaCarte"; + private static final String MULTI_STAGE_DESIGN_OFF = "false"; + private static final String MULTI_STAGE_DESIGN_ON = "true"; + private static final String RESOURCE_EXIST_STATUS_MESSAGE = + "The %s was found to already exist, thus no new %s was created in the cloud via this request"; + private static final String RESOURCE_NOT_EXIST_STATUS_MESSAGE = + "The %s was not found, thus no %s was deleted in the cloud via this request"; + private static final Set<ResourceType> cloudResources = + EnumSet.of(ResourceType.VF_MODULE, ResourceType.VOLUME_GROUP, ResourceType.NETWORK); @Autowired private ExtractPojosForBB extractPojosForBB; @@ -59,6 +73,8 @@ public class OrchestrationStatusValidator { private ExceptionBuilder exceptionBuilder; @Autowired private CatalogDbClient catalogDbClient; + @Autowired + RequestsDbClient requestDBClient; /** @@ -160,6 +176,13 @@ public class OrchestrationStatusValidator { execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, orchestrationStatusStateTransitionDirective.getFlowDirective()); + + if (buildingBlockFlowName.matches("Create(.*)|Delete(.*)") && orchestrationStatusStateTransitionDirective + .getFlowDirective() == OrchestrationStatusValidationDirective.SILENT_SUCCESS) { + + updatedResourceStatus(execution, buildingBlockDetail); + } + } catch (BBObjectNotFoundException ex) { logger.error( "Error occurred for bb object notfound in OrchestrationStatusValidator validateOrchestrationStatus ", @@ -175,4 +198,33 @@ public class OrchestrationStatusValidator { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e); } } + + private void updatedResourceStatus(BuildingBlockExecution execution, BuildingBlockDetail buildingBlockDetail) { + + if (cloudResources.contains(buildingBlockDetail.getResourceType())) { + String resource = buildingBlockDetail.getResourceType().toString(); + + String resourceId = execution.getLookupMap() + .get(ResourceKey.valueOf(buildingBlockDetail.getResourceType().getResourceKey())); + + String resourceStatusMessage = RESOURCE_NOT_EXIST_STATUS_MESSAGE; + if (execution.getFlowToBeCalled().matches("Create(.*)")) { + resourceStatusMessage = RESOURCE_EXIST_STATUS_MESSAGE; + } + + updateRequestsDb(resourceId, String.format(resourceStatusMessage, resource, resource)); + } + + } + + private void updateRequestsDb(String requestId, String resourceStatusMessage) { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId(requestId); + request.setResourceStatusMessage(resourceStatusMessage); + try { + requestDBClient.patchInfraActiveRequests(request); + } catch (HttpClientErrorException e) { + logger.warn("Unable to update active request resource status"); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index 9adae88a5a..67ce6bfbe9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -41,6 +41,7 @@ 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.NetworkRequestCommon; import org.onap.so.adapters.nwrest.UpdateNetworkError; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; @@ -224,7 +225,7 @@ public class NetworkAdapterRestV1Test { deleteNetworkRequest.setMessageId(messageId); delegateExecution.setVariable("networkAdapterRequest", deleteNetworkRequest); Status status = Status.OK; - String responseEntity = "createNetworkResponse"; + String responseEntity = "deleteNetworkResponse"; Optional<Response> response = Optional.of(createResponse(status, responseEntity)); when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response); // when @@ -233,6 +234,47 @@ public class NetworkAdapterRestV1Test { verifyExecutionContent(status, responseEntity, messageId); } + @Test + public void callNetworkAdapter_UpdateNetworkRequestSuccess() throws Exception { + // given + String messageId = "UpdateNetReqMessageId"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + updateNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); + Status status = Status.OK; + String responseEntity = "updateNetworkResponse"; + Optional<Response> response = Optional.of(createResponse(status, responseEntity)); + when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(response); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verifyExecutionContent(status, responseEntity, messageId); + } + + @Test + public void callNetworkAdapterError_networkAdapterRequestIsNull() { + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), + any(Exception.class), eq(ONAPComponents.SO)); + } + + @Test + public void callNetworkAdapterError_noResponse() throws Exception { + // given + String messageId = "UpdateNetReqMessageId"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + updateNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); + when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(Optional.empty()); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), + any(Exception.class), eq(ONAPComponents.SO)); + } + private void verifyExecutionContent(Status status, String responseEntity, String messageId) { assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterStatusCode"), Integer.toString(status.getStatusCode())); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index ffe48876c4..b9feeedc14 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -34,8 +34,10 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mockito; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -49,13 +51,19 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; import org.onap.so.db.catalog.beans.ResourceType; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; public class OrchestrationStatusValidatorTest extends BaseTaskTest { - @InjectMocks - protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); + private static final String vfModuleExistExpectedMessage = + "The VfModule was found to already exist, thus no new VfModule was created in the cloud via this request"; + + private static final String vfModuleNotExistExpectedMessage = + "The VfModule was not found, thus no VfModule was deleted in the cloud via this request"; + @InjectMocks + protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator(); @Test public void test_validateOrchestrationStatus() throws Exception { @@ -95,6 +103,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult")); + + Mockito.verifyZeroInteractions(requestsDbClient); } @Test @@ -146,6 +156,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + Mockito.verifyZeroInteractions(requestsDbClient); } @Ignore @@ -192,6 +204,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { OrchestrationAction.ASSIGN); orchestrationStatusValidator.validateOrchestrationStatus(execution); + + Mockito.verifyZeroInteractions(requestsDbClient); } @Ignore @@ -224,6 +238,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { OrchestrationAction.ASSIGN); orchestrationStatusValidator.validateOrchestrationStatus(execution); + + Mockito.verifyZeroInteractions(requestsDbClient); } @Test @@ -293,6 +309,8 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult")); + + Mockito.verifyZeroInteractions(requestsDbClient); } @@ -337,10 +355,21 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + orchestrationStatusValidator.validateOrchestrationStatus(execution); assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } @Test @@ -385,10 +414,21 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + orchestrationStatusValidator.validateOrchestrationStatus(execution); assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } @Test @@ -433,10 +473,21 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, OrchestrationAction.CREATE); + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + orchestrationStatusValidator.validateOrchestrationStatus(execution); assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } @Test @@ -481,10 +532,21 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE); + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + orchestrationStatusValidator.validateOrchestrationStatus(execution); assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } @Test @@ -529,10 +591,21 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + orchestrationStatusValidator.validateOrchestrationStatus(execution); assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } @Test @@ -568,5 +641,66 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult")); + + Mockito.verifyZeroInteractions(requestsDbClient); + } + + @Test + public void test_validateOrchestrationStatusDeleteVfModuleSilentSuccess() throws Exception { + String flowToBeCalled = "DeleteVfModuleBB"; + + execution.setVariable("orchestrationStatusValidationResult", + OrchestrationStatusValidationDirective.SILENT_SUCCESS); + execution.setVariable("aLaCarte", true); + execution.setVariable("flowToBeCalled", flowToBeCalled); + + GenericVnf genericVnf = buildGenericVnf(); + ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf(); + modelInfoGenericVnf.setMultiStageDesign("true"); + setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); + setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = + new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName("DeleteVfModuleBB"); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); + buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + + doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective + .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); + orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE); + + doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient) + .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, + OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId("testVfModuleId1"); + request.setResourceStatusMessage(vfModuleNotExistExpectedMessage); + + Mockito.doNothing().when(requestsDbClient).patchInfraActiveRequests(request); + + orchestrationStatusValidator.validateOrchestrationStatus(execution); + + assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + execution.getVariable("orchestrationStatusValidationResult")); + + ArgumentCaptor<InfraActiveRequests> argument = ArgumentCaptor.forClass(InfraActiveRequests.class); + Mockito.verify(requestsDbClient).patchInfraActiveRequests(argument.capture()); + + assertEquals(vfModuleNotExistExpectedMessage, argument.getValue().getResourceStatusMessage()); } } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java index 75a6ba8280..2d8b12c12f 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java @@ -35,6 +35,8 @@ public class Request { protected String finishTime; protected String requestScope; protected String requestType; + protected String workflowName; + protected String operationName; protected String originalRequestId; protected RequestDetails requestDetails; protected InstanceReferences instanceReferences; @@ -83,6 +85,22 @@ public class Request { this.requestType = requestType; } + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + public RequestStatus getRequestStatus() { return requestStatus; } @@ -136,9 +154,9 @@ public class Request { public String toString() { return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime) .append("finishTime", finishTime).append("requestScope", requestScope) - .append("requestType", requestType).append("requestDetails", requestDetails) - .append("instanceReferences", instanceReferences).append("requestStatus", requestStatus) - .append("requestProcessingData", requestProcessingData).append("cloudRequestData", cloudRequestData) - .append("originalRequestId", originalRequestId).toString(); + .append("requestType", requestType).append("workflowName", workflowName) + .append("requestDetails", requestDetails).append("instanceReferences", instanceReferences) + .append("requestStatus", requestStatus).append("requestProcessingData", requestProcessingData) + .append("cloudRequestData", cloudRequestData).append("originalRequestId", originalRequestId).toString(); } } diff --git a/deployment-configs/src/main/resources/logger/logback-spring.xml b/deployment-configs/src/main/resources/logger/logback-spring.xml index 3f022f55fb..76dbc1d1ab 100644 --- a/deployment-configs/src/main/resources/logger/logback-spring.xml +++ b/deployment-configs/src/main/resources/logger/logback-spring.xml @@ -157,6 +157,7 @@ <pattern>${debugPattern}</pattern> </encoder> </appender> + <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> @@ -190,28 +191,29 @@ <logger name="org.springframework" level="WARN" /> <logger name="org.springframework.security.authentication.dao.DaoAuthenticationProvider" - level="DEBUG" /> + level="${LOG_LEVEL:-DEBUG}" /> <!-- Camunda related loggers --> - <logger name="org.camunda.bpm.engine.jobexecutor.level" level="DEBUG" /> + <logger name="org.camunda.bpm.engine.jobexecutor.level" level="${LOG_LEVEL:-DEBUG}" /> <logger name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" - level="DEBUG" /> + level="${LOG_LEVEL:-DEBUG}" /> - <logger name="org.flywaydb" level="DEBUG"/> - <logger name="org.apache.wire" level="DEBUG" /> - <logger name="org.onap" level="DEBUG" /> - <logger name="org.apache.cxf.interceptor" level="DEBUG" /> - <logger name="com.woorea.openstack.connector" level="DEBUG" /> + <logger name="org.flywaydb" level="${LOG_LEVEL:-DEBUG}"/> + <logger name="org.apache.wire" level="${LOG_LEVEL:-DEBUG}" /> + <logger name="org.onap" level="${LOG_LEVEL:-DEBUG}" /> + <logger name="org.apache.cxf.interceptor" level="${LOG_LEVEL:-DEBUG}" /> + <logger name="com.woorea.openstack.connector" level="${LOG_LEVEL:-DEBUG}" /> <!-- AAF Logs go here--> <logger name="org.apache.catalina.core.ContainerBase" level="INFO" additivity="false"> <appender-ref ref="asyncCadi" /> </logger> - - <logger name="org.reflections.Reflections" level="ERROR" additivity="false"> - <appender-ref ref="asyncCadi" /> - </logger> + + <!-- Jersey Openstack Connector Logs Go Here for Openstack4J --> + <logger name="os" level="${LOG_LEVEL:-DEBUG}" /> + + <logger name="org.reflections" level="ERROR" additivity="false" /> <logger name="AUDIT" level="INFO" additivity="false"> <appender-ref ref="asyncAudit" /> diff --git a/docs/architecture/architecture.rst b/docs/architecture/architecture.rst index 72b108a271..a75591b885 100644 --- a/docs/architecture/architecture.rst +++ b/docs/architecture/architecture.rst @@ -1,6 +1,7 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. .. http://creativecommons.org/licenses/by/4.0 .. Copyright 2018 Huawei Technologies Co., Ltd. +.. _architecture: SO - Architecture ================= @@ -25,7 +26,7 @@ SO Sub-Components * Handle service-level and infrastructure (VNF & network) requests Service-agnostic APIs - * “Service Instantiation API” + * "Service Instantiation API" Model-driven recipe selection * Use SO Catalog to map input requests to BPMN flows @@ -43,7 +44,7 @@ SO Sub-Components Expose RESTful interface to API-H (unique path per recipe) - Make use of common “building block” sub-flows + Make use of common "building block" sub-flows Sequence orchestration steps for each Resource in the recipe * Request and configure network resources via SDN-C @@ -120,4 +121,4 @@ Third Party and Open Source **Other Open Source Components of Note:** Tomcat MySQL/MariaDB - Openstack Java SDK (“woorea”) + Openstack Java SDK ("woorea") diff --git a/docs/index.rst b/docs/index.rst index cae4ff02dc..fbf83063a1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,15 +1,16 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License.
-.. http://creativecommons.org/licenses/by/4.0
-.. Copyright 2018 Huawei Technologies Co., Ltd.
-
-ONAP SO
-========================================
-
-.. toctree::
- :maxdepth: 1
-
- installconfigure/Install_Configure_SO.rst
- architecture/architecture.rst
- api/offered_consumed_apis.rst
- developer_info/developer_information.rst
- release-notes.rst
+.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2018 Huawei Technologies Co., Ltd. +.. _master_index: + +ONAP SO +======================================== + +.. toctree:: + :maxdepth: 1 + + installconfigure/Install_Configure_SO.rst + architecture/architecture.rst + api/offered_consumed_apis.rst + developer_info/developer_information.rst + release-notes.rst diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 4ad5f5876f..d052eb72fe 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -1,6 +1,7 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. .. http://creativecommons.org/licenses/by/4.0 .. Copyright 2018 Huawei Intellectual Property. All rights reserved. +.. _release_notes: Service Orchestrator Release Notes @@ -369,7 +370,7 @@ The main goal of the Dublin release was to: - [`SO-1206 <https://jira.onap.org/browse/SO-1206>`__\ ] - Added groupInstanceId and groupInstanceName columns - [`SO-1205 <https://jira.onap.org/browse/SO-1205>`__\ ] - separate error status from progression status in req db - [`SO-806 <https://jira.onap.org/browse/SO-806>`__\ ] - SO PNF PnP workflow shall not set "in-maint" AAI flag -- [`SO-798 <https://jira.onap.org/browse/SO-798>`__\ ] - Externalize the PNF PnP workflow 鈥?as a Service Instance Deployment workflow 鈥?adding the Controller +- [`SO-798 <https://jira.onap.org/browse/SO-798>`__\ ] - Externalize the PNF PnP workflow? as a Service Instance Deployment workflow? adding the Controller - [`SO-747 <https://jira.onap.org/browse/SO-747>`__\ ] - POC - Enable SO use of Multicloud Generic VNF Instantiation API - [`SO-700 <https://jira.onap.org/browse/SO-700>`__\ ] - SO should be able to support CCVPN service assurance - [`SO-588 <https://jira.onap.org/browse/SO-588>`__\ ] - Automate robot heatbridge manual step to add VF Module stack resources in AAI 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 index 3007ddd7c9..f39a95e92c 100644 --- 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 @@ -197,6 +197,7 @@ public class InstanceManagement { vnfId = sir.getVnfInstanceId(); } + currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); saveCurrentActiveRequest(currentActiveReq); RequestClientParameter requestClientParameter; @@ -293,6 +294,7 @@ public class InstanceManagement { RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); + currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid); saveCurrentActiveRequest(currentActiveReq); RequestClientParameter requestClientParameter; @@ -357,4 +359,14 @@ public class InstanceManagement { } return null; } + + protected InfraActiveRequests setWorkflowNameAndOperationName(InfraActiveRequests currentActiveReq, + String workflowUuid) { + Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid); + if (workflow != null) { + currentActiveReq.setWorkflowName(workflow.getName()); + currentActiveReq.setOperationName(workflow.getOperationName()); + } + return currentActiveReq; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index c43a050500..3993c65008 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -311,6 +311,19 @@ public class OrchestrationRequests { request.setOriginalRequestId(originalRequestId); } + if (!version.matches("v[1-7]")) { + String workflowName = iar.getWorkflowName(); + if (workflowName == null) { + workflowName = iar.getRequestAction(); + } + request.setWorkflowName(workflowName); + + String operationName = iar.getOperationName(); + if (operationName != null) { + request.setOperationName(operationName); + } + } + InstanceReferences ir = new InstanceReferences(); if (iar.getNetworkId() != null) ir.setNetworkInstanceId(iar.getNetworkId()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java index 4e3d8736c2..a522129c31 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java @@ -1,19 +1,29 @@ package org.onap.so.apihandlerinfra.infra.rest; +import java.util.List; import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.Service; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; +import org.onap.so.client.aai.AAIDSLQueryClient; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.entities.DSLQuery; +import org.onap.so.client.graphinventory.entities.DSLQueryBuilder; +import org.onap.so.client.graphinventory.entities.DSLStartNode; +import org.onap.so.client.graphinventory.entities.Node; +import org.onap.so.client.graphinventory.entities.Start; +import org.onap.so.client.graphinventory.entities.TraversalBuilder; +import org.onap.so.client.graphinventory.entities.__; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -25,6 +35,8 @@ public class AAIDataRetrieval { private AAIResourcesClient aaiResourcesClient; + private AAIDSLQueryClient aaiDslQueryClient; + private static final Logger logger = LoggerFactory.getLogger(AAIDataRetrieval.class); public ServiceInstance getServiceInstance(String serviceInstanceId) { @@ -129,6 +141,22 @@ public class AAIDataRetrieval { }); } + public List<LInterface> getLinterfacesOfVnf(String vnfId) { + DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("generic-vnf-id", vnfId)); + DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode) + .to(__.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.L_INTERFACE).output())); + List<LInterface> linterfaces = + getAAIDSLQueryClient().querySingleResource(new DSLQuery(builder.build()), LInterface.class); + return linterfaces; + } + + private AAIDSLQueryClient getAAIDSLQueryClient() { + if (aaiDslQueryClient == null) { + aaiDslQueryClient = new AAIDSLQueryClient(); + } + return aaiDslQueryClient; + } + protected AAIResourcesClient getAaiResourcesClient() { if (aaiResourcesClient == null) { aaiResourcesClient = new AAIResourcesClient(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java index 0c7ba65cf4..61f757ba64 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java @@ -6,11 +6,10 @@ import java.util.regex.Pattern; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; -import org.onap.so.listener.Skip; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; -@Skip + public class ServiceInstanceDeleteValidator implements RequestValidator { @Autowired 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 index ba7fe2b9cb..081f235db1 100644 --- 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 @@ -45,9 +45,11 @@ import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.db.request.beans.InfraActiveRequests; 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; @@ -63,6 +65,9 @@ public class InstanceManagementTest extends BaseTest { private final ObjectMapper mapper = new ObjectMapper(); private ObjectMapper errorMapper = new ObjectMapper(); + @Autowired + InstanceManagement instanceManagement; + @Value("${wiremock.server.port}") private String wiremockPort; @@ -201,4 +206,18 @@ public class InstanceManagementTest extends BaseTest { ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } + + @Test + public void workflowAndOperationNameTest() { + wireMockServer.stubFor(get(urlMatching( + ".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("workflow_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + InfraActiveRequests activeReq = new InfraActiveRequests(); + activeReq = + instanceManagement.setWorkflowNameAndOperationName(activeReq, "71526781-e55c-4cb7-adb3-97e09d9c76be"); + assertEquals(activeReq.getWorkflowName(), "testingWorkflow"); + assertEquals(activeReq.getOperationName(), "testOperation"); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 3db2b2d96d..fdaca3566f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -85,6 +85,9 @@ public class OrchestrationRequestsUnitTest { private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage"; private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage"; private static final String TASK_INFORMATION = " TASK INFORMATION: Last task executed: Call SDNC"; + private static final String WORKFLOW_NAME = "testWorkflowName"; + private static final String OPERATION_NAME = "testOperationName"; + private static final String REQUEST_ACTION = "createInstance"; private InfraActiveRequests iar; boolean includeCloudRequest = false; private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; @@ -152,12 +155,80 @@ public class OrchestrationRequestsUnitTest { expected.setRequestScope(SERVICE); expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + iar.setWorkflowName(WORKFLOW_NAME); + iar.setOperationName(OPERATION_NAME); + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(result, sameBeanAs(expected)); } @Test + public void mapInfraActiveRequestToRequestWithWorkflowNameAndOperationNameTest() throws ApiException { + doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + expected.setWorkflowName(WORKFLOW_NAME); + expected.setOperationName(OPERATION_NAME); + + iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); + iar.setWorkflowName(WORKFLOW_NAME); + iar.setOperationName(OPERATION_NAME); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString(), "v8"); + assertThat(result, sameBeanAs(expected)); + } + + @Test + public void mapInfraActiveRequestToRequestWithNoWorkflowNameAndNoOperationNameTest() throws ApiException { + doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); + + + expected.setWorkflowName(REQUEST_ACTION); + expected.setRequestType(REQUEST_ACTION); + + iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); + iar.setRequestAction(REQUEST_ACTION); + iar.setWorkflowName(null); + iar.setOperationName(null); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString(), "v8"); + assertThat(result, sameBeanAs(expected)); + } + + @Test public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException { doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); InstanceReferences instanceReferences = new InstanceReferences(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json index d6ed585537..5877f43a92 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json @@ -1,5 +1,6 @@ { "artifactUUID": "71526781-e55c-4cb7-adb3-97e09d9c76be", "artifactName": "testingWorkflow.bpmn", - "name": "testingWorkflow" + "name": "testingWorkflow", + "operationName": "testOperation" }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json index 133d8bed9b..1d6cd43bf7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json @@ -1,5 +1,6 @@ { "artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf", "artifactName": "testingPNFWorkflow.bpmn", - "name": "testingPNFWorkflow" + "name": "testingPNFWorkflow", + "operationName": "testPnfOperation" }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 19855bc85e..fd8c273b57 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -1300,6 +1300,8 @@ CREATE TABLE `infra_active_requests` ( `TENANT_NAME` varchar(200) DEFAULT NULL, `PRODUCT_FAMILY_NAME` varchar(200) DEFAULT NULL, `RESOURCE_STATUS_MESSAGE` longtext, + `WORKFLOW_NAME` varchar(200) DEFAULT NULL, + `OPERATION_NAME` varchar(200) DEFAULT NULL, PRIMARY KEY (`REQUEST_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql index 4c376c7af8..e8f2002399 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql @@ -103,8 +103,9 @@ CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS( ROLLBACK_EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1, TENANT_NAME VARCHAR SELECTIVITY 1, PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1, - RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36 - + RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36, + WORKFLOW_NAME VARCHAR SELECTIVITY 1, + OPERATION_NAME VARCHAR SELECTIVITY 1 ); INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, TENANT_ID, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME, REQUEST_URL) VALUES @@ -177,7 +178,9 @@ CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS( REQUEST_URL VARCHAR SELECTIVITY 1, TENANT_NAME VARCHAR SELECTIVITY 1, PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1, - RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36 + RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36, + WORKFLOW_NAME VARCHAR SELECTIVITY 1, + OPERATION_NAME VARCHAR SELECTIVITY 1 ); CREATE TABLE IF NOT EXISTS cloud_api_requests( diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java index 8c4d0718b1..019530aea4 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java @@ -78,7 +78,9 @@ public class ArchivedInfraRequests extends InfraRequests { .append("networkName", getNetworkName()).append("networkType", getNetworkType()) .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId()) .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId()) - .append("operationalEnvName", getOperationalEnvName()).append("requestUrl", getRequestUrl()).toString(); + .append("operationalEnvName", getOperationalEnvName()).append("requestUrl", getRequestUrl()) + .append("tenantName", getTenantName()).append("productFamilyName", getProductFamilyName()) + .append("workflowName", getWorkflowName()).append("operationName", getOperationName()).toString(); } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java index 750fa13c77..02e403c37e 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java @@ -69,10 +69,10 @@ public class InfraActiveRequests extends InfraRequests { @Override public String toString() { return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus()) - .append("statusMessage", getStatusMessage()).append("progress", getProgress()) - .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) - .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType()) - .append("pnfName", getPnfName()).append("serviceType", getServiceType()) + .append("statusMessage", getStatusMessage()).append("resourceStatusMessage", getResourceStatusMessage()) + .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) + .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) + .append("vnfType", getVnfType()).append("pnfName", getPnfName()).append("serviceType", getServiceType()) .append("tenantId", getTenantId()).append("vnfParams", getVnfParams()) .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) @@ -90,6 +90,7 @@ public class InfraActiveRequests extends InfraRequests { .append("originalRequestId", getOriginalRequestId()) .append("extSystemErrorSource", getExtSystemErrorSource()) .append("rollbackExtSystemErrorSource", getRollbackExtSystemErrorSource()) - .append("tenantName", getTenantName()).append("productFamilyName", getProductFamilyName()).toString(); + .append("tenantName", getTenantName()).append("productFamilyName", getProductFamilyName()) + .append("workflowName", getWorkflowName()).append("operationName", getOperationName()).toString(); } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index a6d6af8a07..cf6cf687b0 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -155,6 +155,10 @@ public abstract class InfraRequests implements java.io.Serializable { private String tenantName; @Column(name = "PRODUCT_FAMILY_NAME", length = 80) private String productFamilyName; + @Column(name = "WORKFLOW_NAME", length = 200) + private String workflowName; + @Column(name = "OPERATION_NAME", length = 200) + private String operationName; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID", updatable = false) @@ -580,6 +584,22 @@ public abstract class InfraRequests implements java.io.Serializable { this.productFamilyName = productFamilyName; } + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + @PrePersist protected void onCreate() { if (requestScope == null) @@ -641,6 +661,7 @@ public abstract class InfraRequests implements java.io.Serializable { .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl()) .append("originalRequestId", originalRequestId).append("extSystemErrorSource", extSystemErrorSource) .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).append("tenantName", tenantName) - .append("productFamilyName", productFamilyName).toString(); + .append("productFamilyName", productFamilyName).append("workflowName", workflowName) + .append("operationName", operationName).toString(); } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java index 4fd28c910e..74f58a210c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java @@ -21,24 +21,30 @@ package org.onap.so.db.catalog.beans; public enum ResourceType { - SERVICE("Service"), - VNF("Vnf"), - VOLUME_GROUP("VolumeGroup"), - VF_MODULE("VfModule"), - NETWORK("Network"), - NETWORK_COLLECTION("NetworkCollection"), - CONFIGURATION("Configuration"), - INSTANCE_GROUP("InstanceGroup"), - NO_VALIDATE("NoValidate"); + SERVICE("Service", "SERVICE_INSTANCE_ID"), + VNF("Vnf", "GENERIC_VNF_ID"), + VOLUME_GROUP("VolumeGroup", "VOLUME_GROUP_ID"), + VF_MODULE("VfModule", "VF_MODULE_ID"), + NETWORK("Network", "NETWORK_ID"), + NETWORK_COLLECTION("NetworkCollection", "NETWORK_COLLECTION_ID"), + CONFIGURATION("Configuration", "CONFIGURATION_ID"), + INSTANCE_GROUP("InstanceGroup", "INSTANCE_GROUP_ID"), + NO_VALIDATE("NoValidate", ""); private final String name; + private final String resourceKey; - private ResourceType(String name) { + private ResourceType(String name, String resourceKey) { this.name = name; + this.resourceKey = resourceKey; } @Override public String toString() { return name; } + + public String getResourceKey() { + return resourceKey; + } } @@ -49,7 +49,7 @@ <sonar.cpd.exclusions>**/*</sonar.cpd.exclusions> <jacoco.version>0.8.5</jacoco.version> <org.apache.maven.user-settings /> - <openstack.version>1.5.2-SNAPSHOT</openstack.version> + <openstack.version>1.6.1-SNAPSHOT</openstack.version> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> <originalClassifier>original</originalClassifier> <docker.skip>true</docker.skip> |