2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.sdno.tasks;
26 import org.onap.so.bpmn.common.BuildingBlockExecution;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
28 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
29 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
30 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
31 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
32 import org.onap.so.client.exception.ExceptionBuilder;
33 import org.onap.so.client.orchestration.SDNOHealthCheckResources;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.stereotype.Component;
40 public class SDNOHealthCheckTasks {
41 private static final Logger logger = LoggerFactory.getLogger(SDNOHealthCheckTasks.class);
43 private ExceptionBuilder exceptionUtil;
45 private ExtractPojosForBB extractPojosForBB;
47 private SDNOHealthCheckResources sdnoHealthCheckResources;
49 public void sdnoHealthCheck(BuildingBlockExecution execution) {
50 boolean response = false;
52 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
53 RequestContext requestContext = gBBInput.getRequestContext();
55 GenericVnf vnf = null;
56 Map<ResourceKey, String> lookupMap = execution.getLookupMap();
57 for (Map.Entry<ResourceKey, String> entry : lookupMap.entrySet()) {
58 if (entry.getKey().equals(ResourceKey.GENERIC_VNF_ID)) {
59 vnf = extractPojosForBB.extractByKey(execution, entry.getKey());
63 response = sdnoHealthCheckResources.healthCheck(vnf, requestContext);
64 } catch (Exception ex) {
65 logger.error("Exception occurred", ex);
66 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex.getMessage());
70 logger.error("SDNO Health Check failed");
71 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SDNO Health Check failed");