public static final String SDC_ROOT_URL = "/sdc/v1/catalog/services";
public static final String SDC_GET_PATH = "/metadata";
public static final String SDC_TOSCA_PATH = "/toscaModel";
+ public static final String SDC_HEALTH_CHECK = "/sdc2/rest/healthCheck";
+
// AAI
public static final String AAI_GET_TENANTS_PATH =
"/aai/v14/business/customers/customer/$customerId/service-subscriptions";
public static final String AAI_PUT_SERVICE_FOR_CUSTOMER_PATH =
"/aai/v14/business/customers/customer/$customerId/service-subscriptions/service-subscription/";
+ public static final String AAI_HEALTH_CHECK =
+ "aai/util/echo?action=long";
public static final String AAI_GET_SERVICE =
"/aai/v14/nodes/service-instances/service-instance/$serviceId";
public static final String AAI_GET_SERVICE_CUSTOMER =
public static final String AAI_GET_SERVICE_INSTANCES_PATH =
"/aai/v14/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/";
+
// MSO
public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/onap/so/infra/serviceInstantiation/v7/serviceInstances/";
public static final String MSO_GET_REQUEST_STATUS_PATH = "/onap/so/infra/orchestrationRequests/v7/";
public static final String MSO_CREATE_E2ESERVICE_INSTANCE_PATH = "/onap/so/infra/e2eServiceInstances/v3";
public static final String MSO_DELETE_E2ESERVICE_INSTANCE_PATH = "/onap/so/infra/e2eServiceInstances/v3/";
public static final String MSO_GET_E2EREQUEST_STATUS_PATH = "/onap/so/infra/e2eServiceInstances/v3/$serviceId/operations/$operationId";
-
+ public static final String MSO_HEALTH_CHECK = "/globalhealthcheck";
+
// DMaaP Message Router REST Client
public static final String DMAAP_CONSUME_EVENTS =
"/events/$topic/$consumergroup/$consumerid?timeout=$timeout";
ObjectMapper mapper = new ObjectMapper();
- String dmaapGetEventsUrlFormated = dmaapGetEventsUrl.replace("$topic", topic);
- dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$consumergroup", consumerGroup);
- dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$consumerid", consumerId);
- dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$timeout", timeout);
- List<String> dmaapResponse = callDMaaPGetEvents(dmaapGetEventsUrlFormated);
+ List<String> dmaapResponse = callDMaaPGetEvents();
if (!CollectionUtils.isEmpty(dmaapResponse)) {
for (int i = 0; i < dmaapResponse.size(); i++) {
String aaiEventString = dmaapResponse.get(i);
JsonNode serviceInstances = childserviceInstances.get("service-instance");
JsonNode serviceInstance = serviceInstances.get(0);
serviceInstanceEvent.setId(serviceInstance.get("service-instance-id").asText());
+ serviceInstanceEvent.setHref("service/" + serviceInstance.get("service-instance-id").asText());
serviceInstanceEvent.setState(serviceInstance.get("orchestration-status").asText());
if (action.equals("CREATE")) {
if (logger.isDebugEnabled()) {
}
}
- public List<String> callDMaaPGetEvents(String dmaapGetEventsUrlFormated) {
+ public List<String> callDMaaPGetEvents() {
+
+ String dmaapGetEventsUrlFormated = dmaapGetEventsUrl.replace("$topic", topic);
+ dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$consumergroup", consumerGroup);
+ dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$consumerid", consumerId);
+ dmaapGetEventsUrlFormated = dmaapGetEventsUrlFormated.replace("$timeout", timeout);
+
if (logger.isDebugEnabled()) {
logger.debug("Calling DMaaP Url : " + dmaapGetEventsUrlFormated);
private String sdcGetUrl;
private String sdcFindUrl;
+ private String sdcHealthCheck;
@PostConstruct
private void setUpAndLogSDCUrl() {
sdcGetUrl= new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL+"/{id}"+OnapComponentsUrlPaths.SDC_GET_PATH).toString();
sdcFindUrl = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL).toString();
+ sdcHealthCheck = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_HEALTH_CHECK).toString();
+
LOGGER.info("SDC GET url : "+sdcGetUrl);
LOGGER.info("SDC FIND url : "+ sdcFindUrl);
+ LOGGER.info("SDC HealthCheck : "+ sdcHealthCheck);
}
}
+ public LinkedHashMap callCheckConnectivity() {
+
+ UriComponentsBuilder callURI = UriComponentsBuilder.fromHttpUrl(sdcHealthCheck);
+ ResponseEntity<Object> response = callSdc(callURI.build().encode().toUri());
+ return (LinkedHashMap) response.getBody();
+
+ }
+
+
public File callGetWithAttachment(String toscaModelUrl) {
StringBuilder urlBuilder = new StringBuilder().append(sdcHost).append(toscaModelUrl);
/**
* Copyright (c) 2018 Orange
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.nbi.apis.serviceinventory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Service;
@Service
public class AaiClient extends BaseClient {
- public static final String CUSTOMER_ID = "$customerId";
+ public static final String CUSTOMER_ID = "$customerId";
- @Value("${aai.host}")
- private String aaiHost;
+ @Value("${aai.host}")
+ private String aaiHost;
- @Value("${aai.header.authorization}")
- private String aaiHeaderAuthorization;
+ @Value("${aai.header.authorization}")
+ private String aaiHeaderAuthorization;
- @Value("${aai.api.id}")
- private String aaiApiId;
+ @Value("${aai.api.id}")
+ private String aaiApiId;
- @Value("${aai.header.transaction.id}")
- private String aaiTransactionId;
+ @Value("${aai.header.transaction.id}")
+ private String aaiTransactionId;
- private static final String HEADER_AUTHORIZATION = "Authorization";
- private static final String X_FROM_APP_ID = "X-FromAppId";
- private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
- private static final String X_TRANSACTION_ID = "X-TransactionId";
+ private static final String HEADER_AUTHORIZATION = "Authorization";
+ private static final String X_FROM_APP_ID = "X-FromAppId";
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
+ private static final String X_TRANSACTION_ID = "X-TransactionId";
- private String aaiServiceUrl;
- private String aaiServiceCustomerUrl;
- private String aaiServicesUrl;
- private String aaiServicesInstancesUrl;
+ private String aaiServiceUrl;
+ private String aaiServiceCustomerUrl;
+ private String aaiServicesUrl;
+ private String aaiServicesInstancesUrl;
+ private String aaiHealthCheckUrl;
- @PostConstruct
- private void setUpAndlogAAIUrl() {
- aaiServiceUrl = new StringBuilder().append(aaiHost)
- .append(OnapComponentsUrlPaths.AAI_GET_SERVICE).toString();
- aaiServiceCustomerUrl = new StringBuilder().append(aaiHost)
- .append(OnapComponentsUrlPaths.AAI_GET_SERVICE_CUSTOMER).toString();
- aaiServicesUrl = new StringBuilder().append(aaiHost)
- .append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH).toString();
- aaiServicesInstancesUrl = new StringBuilder().append(aaiHost)
- .append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH).toString();
+ @PostConstruct
+ private void setUpAndlogAAIUrl() {
+ aaiServiceUrl = new StringBuilder().append(aaiHost)
+ .append(OnapComponentsUrlPaths.AAI_GET_SERVICE).toString();
+ aaiServiceCustomerUrl = new StringBuilder().append(aaiHost)
+ .append(OnapComponentsUrlPaths.AAI_GET_SERVICE_CUSTOMER).toString();
+ aaiServicesUrl = new StringBuilder().append(aaiHost)
+ .append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH).toString();
+ aaiServicesInstancesUrl = new StringBuilder().append(aaiHost)
+ .append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH).toString();
+ aaiHealthCheckUrl = new StringBuilder().append(aaiHost)
+ .append(OnapComponentsUrlPaths.AAI_HEALTH_CHECK).toString();
- LOGGER.info("AAI service url : " + aaiServiceUrl);
- LOGGER.info("AAI services url : " + aaiServicesUrl);
- LOGGER.info("AAI service instances url : " + aaiServicesInstancesUrl);
+ LOGGER.info("AAI service url : " + aaiServiceUrl);
+ LOGGER.info("AAI services url : " + aaiServicesUrl);
+ LOGGER.info("AAI service instances url : " + aaiServicesInstancesUrl);
+ LOGGER.info("AAI aaiHealthCheckUrl : " + aaiHealthCheckUrl);
- }
+ }
- private HttpHeaders buildRequestHeaderForAAI() {
+ private HttpHeaders buildRequestHeaderForAAI() {
- HttpHeaders httpHeaders = new HttpHeaders();
- httpHeaders.add(HEADER_AUTHORIZATION, aaiHeaderAuthorization);
- httpHeaders.add(X_FROM_APP_ID, aaiApiId);
- httpHeaders.add("Accept", "application/json");
- httpHeaders.add("Content-Type", "application/json");
- httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.add(HEADER_AUTHORIZATION, aaiHeaderAuthorization);
+ httpHeaders.add(X_FROM_APP_ID, aaiApiId);
+ httpHeaders.add("Accept", "application/json");
+ httpHeaders.add("Content-Type", "application/json");
+ httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
- return httpHeaders;
+ return httpHeaders;
- }
+ }
- public Map getCatalogService(String customerId, String serviceSpecName, String serviceId) {
+ public Map getCatalogService(String customerId, String serviceSpecName, String serviceId) {
- String callUrlFormated = aaiServiceUrl.replace(CUSTOMER_ID, customerId);
- callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceSpecName);
- callUrlFormated = callUrlFormated.replace("$serviceId", serviceId);
+ String callUrlFormated = aaiServiceUrl.replace(CUSTOMER_ID, customerId);
+ callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceSpecName);
+ callUrlFormated = callUrlFormated.replace("$serviceId", serviceId);
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
- return (LinkedHashMap) response.getBody();
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
+ return (LinkedHashMap) response.getBody();
+ }
+ return null;
}
- return null;
- }
-
- public Map getService(String serviceId) {
- // Retrieve the Service Instance using AAI node query
- String callUrlFormated = aaiServiceUrl.replace("$serviceId", serviceId);
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
- return (LinkedHashMap) response.getBody();
+
+ public Map getService(String serviceId) {
+ // Retrieve the Service Instance using AAI node query
+ String callUrlFormated = aaiServiceUrl.replace("$serviceId", serviceId);
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
+ return (LinkedHashMap) response.getBody();
+ }
+ return null;
}
- return null;
- }
- public Map getServiceCustomer(String serviceId) {
+ public Map getServiceCustomer(String serviceId) {
- String callUrlFormated = aaiServiceCustomerUrl.replace("$serviceId", serviceId);
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
- return (LinkedHashMap) response.getBody();
+ String callUrlFormated = aaiServiceCustomerUrl.replace("$serviceId", serviceId);
+ try {
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}", callUrlFormated.toString(), e);
+ return null;
+ }
}
- return null;
- }
-
- public Map getVNF(String relatedLink) {
-
- StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink);
- try {
- ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
- } catch (BackendFunctionalException e) {
- LOGGER.error("error on calling {} , {}", callURL.toString(), e);
- return null;
+
+ public void callCheckConnectivity() {
+ String customersUrl = new StringBuilder().append(aaiHealthCheckUrl).toString();
+ ResponseEntity<String> response = callApiGetHealthCheck(customersUrl, buildRequestHeaderForAAI());
}
- }
-
- public Map getServicesInAaiForCustomer(String customerId) {
- String callUrlFormated = aaiServicesUrl.replace(CUSTOMER_ID, customerId);
- try {
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
- } catch (BackendFunctionalException e) {
- LOGGER.error("error on calling {} , {}", callUrlFormated, e);
- return null;
+
+ public Map getVNF(String relatedLink) {
+
+ StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink);
+ try {
+ ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}", callURL.toString(), e);
+ return null;
+ }
+ }
+
+ public Map getServicesInAaiForCustomer(String customerId) {
+ String callUrlFormated = aaiServicesUrl.replace(CUSTOMER_ID, customerId);
+ try {
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}", callUrlFormated, e);
+ return null;
+ }
}
- }
-
- public Map getServiceInstancesInAaiForCustomer(String customerId, String serviceType) {
- String callUrlFormated = aaiServicesInstancesUrl.replace(CUSTOMER_ID, customerId);
- callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceType);
-
- try {
- ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
- } catch (BackendFunctionalException e) {
- LOGGER.error("error on calling {} , {}", callUrlFormated, e);
- return null;
+
+ public Map getServiceInstancesInAaiForCustomer(String customerId, String serviceType) {
+ String callUrlFormated = aaiServicesInstancesUrl.replace(CUSTOMER_ID, customerId);
+ callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceType);
+
+ try {
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}", callUrlFormated, e);
+ return null;
+ }
}
- }
}
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
public abstract class BaseClient {
return response;
}
+
+ protected ResponseEntity<String> callApiGetHealthCheck(String callURL, HttpHeaders httpHeaders) {
+
+
+ if(LOGGER.isDebugEnabled()){
+ LOGGER.debug("log request : "+callURL+ " "+httpHeaders);
+ }
+
+ ResponseEntity<String> response = null;
+ response = restTemplate.exchange(callURL, HttpMethod.GET,
+ new HttpEntity<>("parameters", httpHeaders), String.class);
+
+ if(LOGGER.isDebugEnabled()){
+ LOGGER.debug("response body : {}",response.getBody().toString());
+ }
+ LOGGER.info("response status : {}", response.getStatusCodeValue());
+ if (LOGGER.isWarnEnabled() && !response.getStatusCode().equals(HttpStatus.OK)) {
+ LOGGER.warn("HTTP call on {} returns {}, {}", callURL , response.getStatusCodeValue() ,response.getBody().toString());
+ }
+ return response;
+ }
+
}
LinkedHashMap serviceInventoryResponse =
(LinkedHashMap) getServiceInventoryJsonTransformer.transform(serviceResponse);
addrelatedPartyIdIdandSpecName(serviceId, serviceInventoryResponse);
+ String href = "service/" + serviceId;
+ serviceInventoryResponse.put("href", href );
return serviceInventoryResponse;
} else {
throw new BackendFunctionalException(HttpStatus.NOT_FOUND, "no catalog service found",
if (!CollectionUtils.isEmpty(serviceInstances)) {
serviceInventoryResponse = findServiceInventoryJsonTransformer.transform(serviceInstances);
for (LinkedHashMap serviceInventory : serviceInventoryResponse) {
+ String href = "service/" + serviceInventory.get("id");
+ serviceInventory.put("href", href);
LinkedHashMap party = (LinkedHashMap) serviceInventory.get("relatedParty");
party.put("id", customerId);
}
private String getE2ESoStatus;
private String deleteE2ESoUrl;
private String deleteSoUrl;
+ private String SoHealthCheck;
@PostConstruct
.toString();
getE2ESoStatus = new StringBuilder().append(soHostname)
.append(OnapComponentsUrlPaths.MSO_GET_E2EREQUEST_STATUS_PATH).toString();
+ SoHealthCheck = new StringBuilder().append(soHostname)
+ .append(OnapComponentsUrlPaths.MSO_HEALTH_CHECK).toString();
LOGGER.info("SO create service url : " + createSoUrl);
LOGGER.info("SO create e2e service url : " + createE2ESoUrl);
LOGGER.info("SO delete e2e service url : " + deleteE2ESoUrl);
LOGGER.info("SO get so status url : " + getSoStatus);
LOGGER.info("SO get e2e so status url : " + getE2ESoStatus);
+ LOGGER.info("SO healthCheck : " + SoHealthCheck);
}
}
}
+
+ public void callCheckConnectivity() {
+ String url = SoHealthCheck;
+ restTemplate.exchange(url, HttpMethod.GET,
+ new HttpEntity<>(buildRequestHeader()), String.class);
+
+ }
+
public GetE2ERequestStatusResponse callE2EGetRequestStatus(String operationId, String serviceId) {
String callUrlFormated = getE2ESoStatus.replace("$serviceId", serviceId);
--- /dev/null
+/**
+ * Copyright (c) 2018 Orange
+ *
+ * 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.
+ */
+package org.onap.nbi.apis.status;
+
+import java.text.MessageFormat;
+import org.onap.nbi.apis.hub.service.CheckDMaaPEventsManager;
+import org.onap.nbi.apis.servicecatalog.SdcClient;
+import org.onap.nbi.apis.serviceinventory.AaiClient;
+import org.onap.nbi.apis.serviceorder.SoClient;
+import org.onap.nbi.apis.status.model.ApplicationStatus;
+import org.onap.nbi.apis.status.model.OnapModuleType;
+import org.onap.nbi.apis.status.model.StatusType;
+import org.onap.nbi.exceptions.BackendFunctionalException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.ResourceAccessException;
+
+@Service
+public class OnapClient {
+
+ @Autowired
+ private SdcClient sdcClient;
+
+ @Autowired
+ private AaiClient aaiClient;
+
+ @Autowired
+ private SoClient soClient;
+
+ @Autowired
+ private CheckDMaaPEventsManager checkDMaaPEventsManager;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OnapClient.class);
+
+
+ public ApplicationStatus checkConnectivity(OnapModuleType onapModuleType) {
+ try {
+
+ switch (onapModuleType) {
+ case SDC:
+ sdcClient.callCheckConnectivity();
+ break;
+ case AAI:
+ aaiClient.callCheckConnectivity();
+ break;
+ case SO:
+ soClient.callCheckConnectivity();
+ break;
+ case DMAAP:
+ checkDMaaPEventsManager.callDMaaPGetEvents();
+ break;
+ }
+ } catch (BackendFunctionalException e) {
+ String message = MessageFormat
+ .format("backend exception for {0}, status code {1}, body response {2}", onapModuleType,
+ e.getHttpStatus(), e.getBodyResponse());
+ LOGGER.error(message);
+ return new ApplicationStatus(onapModuleType.getValue() + " connectivity", StatusType.KO, null);
+ } catch (ResourceAccessException e) {
+ String message = MessageFormat
+ .format("resource access exception for {0}, response {1}", onapModuleType, e.getMessage());
+ LOGGER.error(message);
+ return new ApplicationStatus(onapModuleType.getValue() + " connectivity", StatusType.KO, null);
+ }
+ return new ApplicationStatus(onapModuleType.getValue() + " connectivity", StatusType.OK, null);
+ }
+
+
+}
\ No newline at end of file
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * 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
+ * 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
+ * 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.
+ * 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.
*/
package org.onap.nbi.apis.status;
import org.onap.nbi.apis.status.model.ApplicationStatus;
+import org.onap.nbi.apis.status.model.OnapModuleType;
import org.onap.nbi.apis.status.model.StatusType;
import org.onap.nbi.commons.JsonRepresentation;
import org.onap.nbi.commons.ResourceManagement;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
.add("components.name").add("components.status");
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<Object> status(HttpServletRequest request) {
+ public ResponseEntity<Object> status(HttpServletRequest request, @RequestParam MultiValueMap<String, String> params) {
ResponseEntity<Object> responseEntity = null;
-
final String[] splitPath = request.getRequestURI().split("/");
final String applicationName = splitPath[1];
-
- final ApplicationStatus applicationStatus = this.statusService.get(applicationName, version);
-
- final boolean isServiceFullyFunctional =
- StatusType.OK.equals(applicationStatus.getStatus()) ? applicationStatus.getComponents().stream()
- .allMatch(componentStatus -> StatusType.OK.equals(componentStatus.getStatus())) : false;
+ boolean fullStatus = Boolean.valueOf(params.getFirst("fullStatus"));
+ final ApplicationStatus applicationStatus = buildNbiStatus(applicationName,fullStatus);
// filter object
Object response = this.getEntity(applicationStatus, fullRepresentation);
- if (isServiceFullyFunctional) {
- responseEntity = ResponseEntity.ok(response);
- } else {
- responseEntity = ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
- }
+ responseEntity = ResponseEntity.ok(response);
return responseEntity;
}
+ private ApplicationStatus buildNbiStatus(String applicationName, boolean fullStatus) {
+ final ApplicationStatus applicationStatus = this.statusService.get(applicationName, version);
+
+ if(fullStatus) {
+ final ApplicationStatus sdcConnectivityStatus = this.statusService.getOnapConnectivity(OnapModuleType.SDC);
+ final ApplicationStatus aaiConnectivityStatus = this.statusService.getOnapConnectivity(OnapModuleType.AAI);
+ final ApplicationStatus soConnectivityStatus = this.statusService.getOnapConnectivity(OnapModuleType.SO);
+ final ApplicationStatus dmaapConnectivityStatus = this.statusService.getOnapConnectivity(OnapModuleType.DMAAP);
+ applicationStatus.addComponent(sdcConnectivityStatus).addComponent(aaiConnectivityStatus)
+ .addComponent(soConnectivityStatus).addComponent(dmaapConnectivityStatus);
+ }
+
+ return applicationStatus;
+ }
+
}
package org.onap.nbi.apis.status;
import org.onap.nbi.apis.status.model.ApplicationStatus;
+import org.onap.nbi.apis.status.model.OnapModuleType;
public interface StatusService {
ApplicationStatus get(String serviceName, String serviceVersion);
+
+ ApplicationStatus getOnapConnectivity(OnapModuleType onapModuleType);
+
+
}
package org.onap.nbi.apis.status;
import org.onap.nbi.apis.status.model.ApplicationStatus;
+import org.onap.nbi.apis.status.model.OnapModuleType;
import org.onap.nbi.apis.status.model.StatusType;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("statusService")
public class StatusServiceImpl implements StatusService {
+ @Autowired
+ private OnapClient onapClient;
+
+
@Override
public ApplicationStatus get(final String serviceName, final String serviceVersion) {
}
+ @Override
+ public ApplicationStatus getOnapConnectivity(OnapModuleType onapModuleType) {
- public boolean serviceIsUp() {
- return true;
+ return onapClient.checkConnectivity(onapModuleType);
}
+
}
* Builds a new {@code ApplicationStatus} with the following attributes :
*
* @param name name of the service
- * @param state state of the service ({@code OK} | {@code KO})
+ * @param status status of the service ({@code OK} | {@code KO})
* @param version version of the service ({@code x.y.z})
*/
public ApplicationStatus(final String name, final StatusType status, final String version) {
return this.components;
}
- public ApplicationStatus component(final ApplicationStatus componentStatus) {
+ public ApplicationStatus addComponent(final ApplicationStatus componentStatus) {
this.components.add(componentStatus);
return this;
}
--- /dev/null
+/**
+ * Copyright (c) 2018 Orange
+ *
+ * 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.
+ */
+package org.onap.nbi.apis.status.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public enum OnapModuleType {
+
+ SDC("sdc"), AAI("aai"),SO("so"), DMAAP("dmaap");
+
+ private final String value;
+
+ OnapModuleType(String v) {
+ this.value = v;
+ }
+
+ @JsonValue
+ public String getValue() {
+ return this.value;
+ }
+
+ @JsonCreator
+ public static OnapModuleType fromValue(String v) {
+ for (OnapModuleType c : OnapModuleType.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
nbi.version = v3
# SERVER
-server.servlet.context-path = /nbi/api/${nbi.version}
+server.servlet.context-path = /nbi/api/${nbi.version}
server.port = 8080
# LOGGING
-logging.level. = ERROR
+logging.level.org.springframework = OFF
+logging.level.root = OFF
+spring.main.banner-mode = off
# ONAP
onap.lcpCloudRegionId = RegionOne
so.project.name = Project-generic
# DMAAP
-dmaap.host = http://127.0.0.1:8091
-dmaap.topic = AAI-EVENT
-dmaap.consumergroup = NBICG1
-dmaap.consumerid = NBIC1
-dmaap.timeout = 2000
+dmaap.host = http://127.0.0.1:8091
+dmaap.topic = AAI-EVENT
+dmaap.consumergroup = NBICG1
+dmaap.consumerid = NBIC1
+dmaap.timeout = 2000
# MSB
msb.enabled = false
server.port = 8080
# LOGGING
-logging.level. = INFO
+logging.level. = WARN
+logging.level.org.springframework = OFF
+logging.level.org.onap = INFO
+logging.level.root = WARN
+spring.main.banner-mode = off
# ONAP
onap.lcpCloudRegionId = RegionOne
serviceOrder.initial = 1
executionTask.schedule = 2000
executionTask.initial = 1
-dmaapCheck.schedule = 10000
-dmaapCheck.initial = 1
+dmaapCheck.schedule = 10000
+dmaapCheck.initial = 1
# SDC
sdc.host = http://10.0.3.1:8080
Given path 'service','e4688e5f-61a0-4f8b-ae02-a2fbde623bcb'
When method get
Then status 200
-And match $ contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01', type : 'service-instance', @type : 'serviceONAP' }
+And match $ contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , href : 'service/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01', type : 'service-instance', @type : 'serviceONAP' }
And match $.serviceSpecification contains { id : '98d95267-5e0f-4531-abf8-f14b90031dc5' , invariantUUID : '709d157b-52fb-4250-976e-7133dff5c347' , @type : 'ONAPservice', name :'servicename2' }
And match $.relatedParty contains { role : 'ONAPcustomer' , id : 'DemoTest2' }
And match $.supportingResource[0] contains { id : 'cb80fbb6-9aa7-4ac5-9541-e14f45de533e' , name : 'NewFreeRadius-VNF-instance-01' , status : 'PREPROV' , modelInvariantId : 'f5993703-977f-4346-a1c9-c1884f8cfd8d' , modelVersionId : '902438f7-1e4c-492d-b7cc-8650e13b8aeb' , @referredType : 'ONAP resource' }
Given path 'service','e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList'
When method get
Then status 200
-And match $ contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' , type : 'service-instance' , @type : 'serviceONAP' }
+And match $ contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList' , href : 'service/e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList' , name : 'NewFreeRadius-service-instance-01' , type : 'service-instance' , @type : 'serviceONAP' }
And match $.serviceSpecification contains { id : '98d95267-5e0f-4531-abf8-f14b90031dc5' , invariantUUID : '709d157b-52fb-4250-976e-7133dff5c347' , @type : 'ONAPservice', name : 'servicename3' }
And match $.relatedParty contains { role : 'ONAPcustomer' , id : 'DemoTest3' }
And match $.supportingResource == '#[0]'
When method get
Then status 200
And match $ == '#[1]'
-And match $[0] contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' }
+And match $[0] contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , href : 'service/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' }
And match $[0].relatedParty contains { role : 'ONAPcustomer' , id : '6490' }
And match $[0].serviceSpecification contains { name : 'vFW' , id : '98d95267-5e0f-4531-abf8-f14b90031dc5' }
When method get
Then status 200
And match $ == '#[1]'
-And match $[0] contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' }
+And match $[0] contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , href : 'service/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' }
And match $[0].relatedParty contains { role : 'ONAPcustomer' , id : '6490' }
And match $[0].serviceSpecification contains { name : 'vFW' , id : '98d95267-5e0f-4531-abf8-f14b90031dc5' }
When method get
Then status 200
And match $ == '#[2]'
-And match $[0] contains { id : 'vfw-service-id' , name : 'vfw-service-name' }
+And match $[0] contains { id : 'vfw-service-id' , href : 'service/vfw-service-id' , name : 'vfw-service-name' }
And match $[0].relatedParty contains { role : 'ONAPcustomer' , id : '6490' }
And match $[0].serviceSpecification contains { name : 'vFW-service-2VF-based' , id : '9vfw-service-modek-version-id' }
And match $[1] contains { id : 'e4688e5f-61a0-4f8b-ae02-a2fbde623bcb' , name : 'NewFreeRadius-service-instance-01' }
* call Context.startServers();
Scenario: testHealthCheck
+Given path 'status'
+When method get
+Then status 200
+And match response.status == 'ok'
+And match response.name == 'nbi'
+
+Scenario: testFullHealthCheck
+Given path 'status'
+And params {fullStatus :true}
+When method get
+Then status 200
+And match response.status == 'ok'
+And match response.name == 'nbi'
+And assert response.components.length == 4
+And match each $.components contains {status :'ok'}
+
+
+Scenario: testFullHealthChecWithoutWiremock
+* call Context.stopWiremock();
+Given path 'status'
+And params {fullStatus :true}
+When method get
+Then status 200
+And match response.status == 'ok'
+And match response.name == 'nbi'
+And assert response.components.length == 4
+And match each response.components contains { status: 'ko'}
+Scenario: testFullHealthCheckWithSDCNotResponding
+* call Context.removeWireMockMapping("/sdc2/rest/healthCheck");
Given path 'status'
+And params {fullStatus :true}
When method get
Then status 200
And match response.status == 'ok'
-And match response.name == 'nbi'
\ No newline at end of file
+And match response.name == 'nbi'
+And assert response.components.length == 4
+And match response.components contains [{name:'sdc connectivity', status: 'ko'},{name:'so connectivity', status: 'ok'},{name:'aai connectivity', status: 'ok'},{name:'dmaap connectivity', status: 'ok'},]
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2019 Orange
+
+ 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.
+
+-->
+<configuration>
+ <include resource="org/springframework/boot/logging/logback/base.xml"/>
+ <logger level="OFF" name="org.springframework"/>
+</configuration>
\ No newline at end of file
--- /dev/null
+{
+ "request": {
+ "method": "GET",
+ "url": "/aai/v14/business/customers"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody": {
+ "customer": [
+ {
+ "global-customer-id": "generic",
+ "subscriber-name": "generic",
+ "subscriber-type": "INFRA",
+ "resource-version": "1550238542827"
+ },
+ {
+ "global-customer-id": "Generic-Vendor",
+ "subscriber-name": "Generic-Vendor",
+ "subscriber-type": "INFRA",
+ "resource-version": "1550569650318"
+ },
+ {
+ "global-customer-id": "customerRG",
+ "subscriber-name": "customerRG",
+ "subscriber-type": "INFRA",
+ "resource-version": "1551445667218"
+ }
+ ]
+ },
+ "headers": {
+ "Content-Type": "application/xml"
+ }
+ }
+}
--- /dev/null
+{
+ "request": {
+ "method": "GET",
+ "url": "/aai/util/echo?action=long"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody":{
+ "responseMessages": {
+ "responseMessage": [
+ {
+ "messageId": "INF0001",
+ "text": "Success X-FromAppId=%1 X-TransactionId=%2 (msg=%3) (rc=%4)",
+ "variables": {
+ "variable": [
+ "AAI",
+ "808b54e3-e563-4144-a1b9-e24e2ed93d4f",
+ "Successful health check:OK",
+ "0.0.0002"
+ ]
+ }
+ }
+ ]
+ }
+ },
+ "headers": {
+ "Content-Type": "application/xml"
+ }
+ }
+}
"response": {
"status": 200,
"jsonBody": {
- "service-instance-id": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb",
+ "service-instance-id": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList",
"service-instance-name": "NewFreeRadius-service-instance-01",
"model-invariant-id": "709d157b-52fb-4250-976e-7133dff5c347",
"model-version-id": "98d95267-5e0f-4531-abf8-f14b90031dc5",
--- /dev/null
+{
+ "request": {
+ "method": "GET",
+ "url": "/sdc/v1/artifactTypes"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody":
+[
+ "CHEF",
+ "PUPPET",
+ "YANG",
+ "SHELL_SCRIPT",
+ "SHELL",
+ "ICON",
+ "UNKNOWN",
+ "HEAT",
+ "DG_XML",
+ "MURANO_PKG",
+ "HEAT_ENV",
+ "YANG_XML",
+ "HEAT_VOL",
+ "HEAT_NET",
+ "OTHER",
+ "WORKFLOW",
+ "NETWORK_CALL_FLOW",
+ "TOSCA_TEMPLATE",
+ "TOSCA_CSAR",
+ "VNF_CATALOG",
+ "VF_LICENSE",
+ "BPEL",
+ "VENDOR_LICENSE",
+ "MODEL_INVENTORY_PROFILE",
+ "MODEL_QUERY_SPEC",
+ "APPC_CONFIG",
+ "HEAT_NESTED",
+ "HEAT_ARTIFACT",
+ "VF_MODULES_METADATA",
+ "LIFECYCLE_OPERATIONS",
+ "VES_EVENTS",
+ "PERFORMANCE_COUNTER",
+ "UCPE_LAYER_2_CONFIGURATION",
+ "DCAE_TOSCA",
+ "DCAE_JSON",
+ "DCAE_POLICY",
+ "DCAE_DOC",
+ "DCAE_EVENT",
+ "DCAE_INVENTORY_TOSCA",
+ "DCAE_INVENTORY_JSON",
+ "DCAE_INVENTORY_POLICY",
+ "DCAE_INVENTORY_DOC",
+ "DCAE_INVENTORY_BLUEPRINT",
+ "DCAE_INVENTORY_EVENT",
+ "AAI_SERVICE_MODEL",
+ "AAI_VF_MODEL",
+ "AAI_VF_MODULE_MODEL",
+ "AAI_VF_INSTANCE_MODEL",
+ "SNMP_POLL",
+ "SNMP_TRAP",
+ "GUIDE",
+ "PLAN"
+]
+ ,
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "request": {
+ "method": "GET",
+ "url": "/sdc2/rest/healthCheck"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody":
+ {
+ "sdcVersion": "1.3.6",
+ "siteMode": "unknown",
+ "componentsInfo": [
+ {
+ "healthCheckComponent": "BE",
+ "healthCheckStatus": "UP",
+ "version": "1.3.6",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "TITAN",
+ "healthCheckStatus": "UP",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "ES",
+ "healthCheckStatus": "UP",
+ "version": "1.3.6",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "DE",
+ "healthCheckStatus": "UP",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "CASSANDRA",
+ "healthCheckStatus": "UP",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "ON_BOARDING",
+ "healthCheckStatus": "UP",
+ "version": "1.3.6",
+ "description": "OK",
+ "componentsInfo": [
+ {
+ "healthCheckComponent": "ZU",
+ "healthCheckStatus": "UP",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "BE",
+ "healthCheckStatus": "UP",
+ "version": "1.3.6",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "CAS",
+ "healthCheckStatus": "UP",
+ "version": "2.1.17",
+ "description": "OK"
+ }
+ ]
+ },
+ {
+ "healthCheckComponent": "DCAE",
+ "healthCheckStatus": "UP",
+ "version": "1.3.0",
+ "description": "OK",
+ "componentsInfo": [
+ {
+ "healthCheckComponent": "BE",
+ "healthCheckStatus": "UP",
+ "version": "1.3.0",
+ "description": "OK"
+ },
+ {
+ "healthCheckComponent": "TOSCA_LAB",
+ "healthCheckStatus": "UP",
+ "version": "1.3.0",
+ "description": "OK"
+ }
+ ]
+ }
+ ]
+ }
+ ,
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "request": {
+ "method": "GET",
+ "url": "/globalhealthcheck"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody": {
+ "bodyFileName": "so_healthcheck.xml"
+ }
+ }
+}
--- /dev/null
+<!--
+ Copyright (c) 2019 Orange
+
+ 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.
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="ISO-8859-1">
+ <title>Health Check</title>
+ </head>
+ <body>Application ready</body>
+</html>
\ No newline at end of file