diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
12 files changed, 438 insertions, 75 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java index 667ac133af..59f8be50c8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java @@ -20,26 +20,40 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; +import static com.google.common.collect.Sets.newHashSet; +import java.util.Set; +import org.onap.vnfmadapter.v1.model.OperationStateEnum; +import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum; + /** * @author waqas.ikram@est.tech */ public class Constants { - public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest"; - public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; - - public static final String INPUT_PARAMETER = "inputParameter"; + public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest"; + public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; + public static final String INPUT_PARAMETER = "inputParameter"; + public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse"; + + + public static final String DOT = "."; + public static final String UNDERSCORE = "_"; + public static final String SPACE = "\\s+"; + + public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; + public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk"; + + public static final String FORWARD_SLASH = "/"; + public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/"; + - public static final String DOT = "."; - public static final String UNDERSCORE = "_"; - public static final String SPACE = "\\s+"; + public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES = + newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); - public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; - public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk"; - - public static final String FORWARD_SLASH = "/"; - public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/"; + public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet( + OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); + public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus"; - private Constants() {} + private Constants() {} } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java new file mode 100644 index 0000000000..857c5cb6fe --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.google.common.base.Optional; + +/** + * + * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech) + */ +@Component +public class EtsiVnfDeleteTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(EtsiVnfDeleteTask.class); + private final ExtractPojosForBB extractPojosForBB; + private final ExceptionBuilder exceptionUtil; + private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider; + + @Autowired + public EtsiVnfDeleteTask(final ExceptionBuilder exceptionUtil, final ExtractPojosForBB extractPojosForBB, + final VnfmAdapterServiceProvider vnfmAdapterServiceProvider) { + this.exceptionUtil = exceptionUtil; + this.extractPojosForBB = extractPojosForBB; + this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider; + } + + /** + * Invoke VNFM adapter to delete the VNF + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void invokeVnfmAdapter(final BuildingBlockExecution execution) { + try { + LOGGER.debug("Executing invokeVnfmAdapter ..."); + final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + + final Optional<DeleteVnfResponse> response = vnfmAdapterServiceProvider.invokeDeleteRequest(vnf.getVnfId()); + + if (!response.isPresent()) { + final String errorMessage = "Unexpected error while processing delete request"; + LOGGER.error(errorMessage); + exceptionUtil.buildAndThrowWorkflowException(execution, 1211, errorMessage); + } + + final DeleteVnfResponse vnfResponse = response.get(); + + LOGGER.debug("Vnf delete response: {}", vnfResponse); + execution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse); + + LOGGER.debug("Finished executing invokeVnfmAdapter ..."); + } catch (final Exception exception) { + LOGGER.error("Unable to invoke delete request", exception); + exceptionUtil.buildAndThrowWorkflowException(execution, 1212, exception); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java new file mode 100644 index 0000000000..f89931063c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_FINISHED_STATES; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_RETRIEVAL_STATES; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_STATUS_PARAM_NAME; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.vnfmadapter.v1.model.CreateVnfResponse; +import org.onap.vnfmadapter.v1.model.OperationStateEnum; +import org.onap.vnfmadapter.v1.model.QueryJobResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.google.common.base.Optional; + + +/** + * @author waqas.ikram@est.tech + * + */ +@Component +public class MonitorVnfmCreateJobTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmCreateJobTask.class); + private final ExceptionBuilder exceptionUtil; + private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider; + + @Autowired + public MonitorVnfmCreateJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider, + final ExceptionBuilder exceptionUtil) { + this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider; + this.exceptionUtil = exceptionUtil; + } + + /** + * Get the current operation status of instantiation job + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void getCurrentOperationStatus(final BuildingBlockExecution execution) { + LOGGER.debug("Executing getCurrentOperationStatus ..."); + final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); + execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, vnfInstantiateResponse)); + LOGGER.debug("Finished executing getCurrentOperationStatus ..."); + } + + /** + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + * @return boolean to indicate whether job has competed or not + */ + public boolean hasOperationFinished(final BuildingBlockExecution execution) { + LOGGER.debug("Executing hasOperationFinished ..."); + + final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME); + if (operationStatusOption != null && operationStatusOption.isPresent()) { + return OPERATION_FINISHED_STATES.contains(operationStatusOption.get()); + } + LOGGER.debug("OperationStatus is not present yet... "); + LOGGER.debug("Finished executing hasOperationFinished ..."); + return false; + + } + + /** + * Log and throw exception on timeout for job status + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void timeOutLogFailue(final BuildingBlockExecution execution) { + final String message = "Instantiation operation time out"; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1205, message); + } + + /** + * Check the final status of instantiation throw exception if not completed successfully + * + * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} + */ + public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) { + LOGGER.debug("Executing checkIfOperationWasSuccessful ..."); + final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME); + final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME); + if (operationStatusOption == null || !operationStatusOption.isPresent()) { + final String message = "Unable to instantiate jobId: " + + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + + "Unable to retrieve OperationStatus"; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message); + } + if (operationStatusOption.isPresent()) { + final OperationStateEnum operationStatus = operationStatusOption.get(); + if (operationStatus != OperationStateEnum.COMPLETED) { + final String message = "Unable to instantiate jobId: " + + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + " OperationStatus: " + + operationStatus; + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message); + } + LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse); + } + } + + private Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution, + final CreateVnfResponse vnfInstantiateResponse) { + + final Optional<QueryJobResponse> instantiateOperationJobStatus = + vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(vnfInstantiateResponse.getJobId()); + + if (instantiateOperationJobStatus.isPresent()) { + final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get(); + + if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) { + final String message = + "Recevied invalid operation reterivel state: " + queryJobResponse.getOperationStatusRetrievalStatus(); + LOGGER.error(message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message); + } + + if (queryJobResponse.getOperationState() != null) { + final OperationStateEnum operationStatus = queryJobResponse.getOperationState(); + LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(), + operationStatus, queryJobResponse.getOperationStatusRetrievalStatus()); + return Optional.of(queryJobResponse.getOperationState()); + } + + LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", queryJobResponse.getId(), + queryJobResponse.getOperationStatusRetrievalStatus()); + + } + return Optional.absent(); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java index 02303ef09d..1e785074f3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java @@ -22,17 +22,22 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.CreateVnfResponse; - +import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; +import org.onap.vnfmadapter.v1.model.QueryJobResponse; import com.google.common.base.Optional; /** * Provide a service which interacts with VNFM adapter for instantiating, monitoring VNF - * + * * @author waqas.ikram@est.tech */ public interface VnfmAdapterServiceProvider { - Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request); + Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request); + + Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId); + + Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java index afdcccfd36..e8f4c08f38 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java @@ -25,13 +25,14 @@ import org.onap.so.rest.exceptions.RestProcessingException; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.CreateVnfResponse; +import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; +import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; - import com.google.common.base.Optional; /** @@ -40,50 +41,111 @@ import com.google.common.base.Optional; @Service public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvider { - private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class); + private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class); + + private final VnfmAdapterUrlProvider urlProvider; + private final HttpRestServiceProvider httpServiceProvider; + + @Autowired + public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider, + final HttpRestServiceProvider httpServiceProvider) { + this.urlProvider = urlProvider; + this.httpServiceProvider = httpServiceProvider; + } + + @Override + public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, + final CreateVnfRequest request) { + try { + final String url = urlProvider.getCreateInstantiateUrl(vnfId); + + final ResponseEntity<CreateVnfResponse> response = + httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class); + + final HttpStatus httpStatus = response.getStatusCode(); + if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { + LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value()); + return Optional.absent(); + } + + if (!response.hasBody()) { + LOGGER.error("Received response without body: {}", response); + return Optional.absent(); + } - private final VnfmAdapterUrlProvider urlProvider; - private final HttpRestServiceProvider httpServiceProvider; + final CreateVnfResponse createVnfResponse = response.getBody(); - @Autowired - public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider, - final HttpRestServiceProvider httpServiceProvider) { - this.urlProvider = urlProvider; - this.httpServiceProvider = httpServiceProvider; + if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) { + LOGGER.error("Received invalid instantiation response: {}", response); + return Optional.absent(); + } + + return Optional.of(createVnfResponse); + } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { + LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException); + return Optional.absent(); } - @Override - public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, - final CreateVnfRequest request) { - try { - final String url = urlProvider.getCreateInstantiateUrl(vnfId); + } + + @Override + public Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId) { + try { + final String url = urlProvider.getDeleteUrl(vnfId); + LOGGER.debug("Will send request to vnfm adapter using url: {}", url); + + final ResponseEntity<DeleteVnfResponse> response = + httpServiceProvider.deleteHttpRequest(url, DeleteVnfResponse.class); + + LOGGER.debug("Response received: ", response); - final ResponseEntity<CreateVnfResponse> response = - httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class); + final HttpStatus httpStatus = response.getStatusCode(); - final HttpStatus httpStatus = response.getStatusCode(); - if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { - LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value()); - return Optional.absent(); - } + if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { + LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value()); + return Optional.absent(); + } + + if (!response.hasBody()) { + LOGGER.error("Received response without body: {}", response); + return Optional.absent(); + } + final DeleteVnfResponse deleteVnfResponse = response.getBody(); + + if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) { + LOGGER.error("Received invalid delete response: {}", response); + return Optional.absent(); + } + return Optional.of(deleteVnfResponse); + } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { + LOGGER.error("Unexpected error while processing delete request", httpInvocationException); + return Optional.absent(); + } + } - if (!response.hasBody()) { - LOGGER.error("Received response without body: {}", response); - return Optional.absent(); - } + @Override + public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) { + try { + final String url = urlProvider.getJobStatusUrl(jobId); - final CreateVnfResponse createVnfResponse = response.getBody(); + final ResponseEntity<QueryJobResponse> response = + httpServiceProvider.getHttpResponse(url, QueryJobResponse.class); - if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) { - LOGGER.error("Received invalid instantiation response: {}", response); - return Optional.absent(); - } + final HttpStatus httpStatus = response.getStatusCode(); - return Optional.of(createVnfResponse); - } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { - LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException); - return Optional.absent(); - } + if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) { + LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value()); + return Optional.absent(); + } + if (!response.hasBody()) { + LOGGER.error("Received response without body: {}", response); + return Optional.absent(); + } + return Optional.of(response.getBody()); + } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { + LOGGER.error("Unexpected error while processing job request", httpInvocationException); + return Optional.absent(); } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java index 03ee0712e7..97a7197373 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; import java.net.URI; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.util.UriComponentsBuilder; @@ -36,23 +35,43 @@ import org.springframework.web.util.UriComponentsBuilder; @Service public class VnfmAdapterUrlProvider { - private final URI baseUri; + private final URI baseUri; - @Autowired - public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) { - this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri(); - } + @Autowired + public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) { + this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri(); + } + + /** + * Get VNFM create and instantiate URL + * + * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in + * AAI. + * @return VNFM create and instantiate URL + */ + public String getCreateInstantiateUrl(final String vnfId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString(); + } + + /** + * Get VNFM delete URL + * + * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in + * AAI. + * @return VNFM delete URL + */ + public String getDeleteUrl(final String vnfId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString(); + } /** - * Get VNFM create and instantiate URL + * Get job status URL * - * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in - * AAI. - * @return VNFM create and instantiate URL + * @param jobId The instantiation job identifier + * @return job status URL */ - public String getCreateInstantiateUrl(final String vnfId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString(); + public String getJobStatusUrl(final String jobId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("jobs").pathSegment(jobId).build().toString(); } - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java index b11e2caafa..7b86756afa 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -21,6 +21,7 @@ package org.onap.so.client.sdnc.mapper; import java.net.URI; +import java.util.UUID; import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; @@ -52,9 +53,13 @@ public class GCTopologyOperationRequestMapper { Configuration vnrConfiguration, GenericVnf voiceVnf, String sdncReqId,URI callbackUri) { + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false); GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true); GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null); @@ -74,11 +79,15 @@ public class GCTopologyOperationRequestMapper { RequestContext requestContext, Configuration vnrConfiguration, String sdncReqId, URI callbackUri) { + String msoRequestId = null; + if (requestContext != null) { + msoRequestId = requestContext.getMsoRequestId(); + } GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString()); GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE); GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation(); serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index b086b8a7ff..756e5b068e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -60,10 +60,10 @@ public class GeneralTopologyObjectMapper { /* * Build GenericResourceApiRequestinformationRequestInformation */ - public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String sdncReqId, GenericResourceApiRequestActionEnumeration requestAction){ + public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String msoReqId, GenericResourceApiRequestActionEnumeration requestAction){ GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation(); - requestInformation.setRequestId(sdncReqId); + requestInformation.setRequestId(msoReqId); requestInformation.setRequestAction(requestAction); requestInformation.setSource("MSO"); return requestInformation; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index 188a228e5d..aef7e9e044 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -57,8 +57,12 @@ public class NetworkTopologyOperationRequestMapper { Customer customer, RequestContext requestContext, CloudRegion cloudRegion) { GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation(); String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); GenericResourceApiNetworkinformationNetworkInformation networkInformation = generalTopologyObjectMapper.buildNetworkInformation(network); GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = buildNetworkRequestInput(network, serviceInstance, cloudRegion); @@ -68,7 +72,7 @@ public class NetworkTopologyOperationRequestMapper { req.setServiceInformation(serviceInformation); req.setNetworkInformation(networkInformation); - if (requestContext.getUserParams() != null) { + if (requestContext != null && requestContext.getUserParams() != null) { for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java index 505466b22c..cdb4ab96aa 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -49,9 +49,13 @@ public class ServiceTopologyOperationMapper{ SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation(); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, resourceAction); + GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction); GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput(); @@ -62,7 +66,7 @@ public class ServiceTopologyOperationMapper{ servOpInput.setServiceInformation(servInfo); servOpInput.setServiceRequestInput(servReqInfo); - if(requestContext.getUserParams()!=null){ + if(requestContext != null && requestContext.getUserParams()!=null){ for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput(); serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index b8c5fad41d..86c718d165 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -96,8 +96,12 @@ public class VfModuleTopologyOperationRequestMapper { } String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation); GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index 7de393bb2f..85e5b85529 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -59,11 +59,15 @@ public class VnfTopologyOperationRequestMapper { GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) { String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper .buildSdncRequestHeader(svcAction, sdncReqId); GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, requestAction); + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper .buildServiceInformation(serviceInstance, requestContext, customer, true); GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper @@ -84,7 +88,7 @@ public class VnfTopologyOperationRequestMapper { req.setVnfInformation(vnfInformation); GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); - if (requestContext.getUserParams() != null) { + if (requestContext != null && requestContext.getUserParams() != null) { for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); |