Also added missing licence info.
Issue-ID: SO-3768
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I0f39e6ca0e8666ac211d46228409e9c7afb3e9f9
<dependency>
<groupId>org.onap.aai.schema-service</groupId>
<artifactId>aai-schema</artifactId>
- <version>1.9.1</version>
+ <version>1.9.2</version>
</dependency>
</dependencies>
</dependencyManagement>
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf;
import org.springframework.beans.factory.annotation.Value;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf;
import org.springframework.beans.factory.annotation.Value;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.aai;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.healthcheck;
public class HealthCheckInstance {
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.healthcheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.healthcheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public class HealthCheckResponse {
@JsonProperty("result")
- private List<HealthCheckInstanceResponse> instanceResponse;
-
- @JsonProperty("error")
- private String errorMessage;
+ private List<HealthCheckInstanceResponse> result;
public List<HealthCheckInstanceResponse> getInstanceResponse() {
- return instanceResponse;
- }
-
- public void setInstanceResponse(List<HealthCheckInstanceResponse> instanceResponse) {
- this.instanceResponse = instanceResponse;
- }
-
- public String getErrorMessage() {
- return errorMessage;
+ return result;
}
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
+ public void setInstanceResponse(List<HealthCheckInstanceResponse> result) {
+ this.result = result;
}
@Override
public String toString() {
return "HealthCheckResponse{" +
- "instanceResponse=" + instanceResponse +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
+ "result=" + result + '}';
}
}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.healthcheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(value = "true")
+@JsonIgnoreProperties(ignoreUnknown = true)
public class K8sRbInstanceHealthCheck {
+ @JsonProperty("instance-id")
+ private String instanceId;
+
+ @JsonProperty("healthcheck-id")
+ private String healthcheckId;
+
@JsonProperty("status")
private String status;
this.status = status;
}
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public String getHealthcheckId() {
+ return healthcheckId;
+ }
+
+ public void setHealthcheckId(String healthcheckId) {
+ this.healthcheckId = healthcheckId;
+ }
+
@Override
public String toString() {
return "K8sRbInstanceHealthCheck{" +
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.healthcheck;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(value = "true")
public class K8sRbInstanceHealthCheckSimple {
@JsonProperty("healthcheck-id")
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Orange. 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.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.statuscheck;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. 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.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.model.statuscheck;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public class StatusCheckResponse {
@JsonProperty("result")
- private List<StatusCheckInstanceResponse> instanceResponse;
-
- @JsonProperty("error")
- private String errorMessage;
+ private List<StatusCheckInstanceResponse> result;
public List<StatusCheckInstanceResponse> getInstanceResponse() {
- return instanceResponse;
- }
-
- public void setInstanceResponse(List<StatusCheckInstanceResponse> instanceResponse) {
- this.instanceResponse = instanceResponse;
- }
-
- public String getErrorMessage() {
- return errorMessage;
+ return result;
}
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
+ public void setInstanceResponse(List<StatusCheckInstanceResponse> result) {
+ this.result = result;
}
@Override
public String toString() {
return "StatusCheckResponse{" +
- "instanceResponse=" + instanceResponse +
- ", errorMessage='" + errorMessage + '\'' +
+ "result=" + result +
'}';
}
}
* ONAP - SO
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Samsung Technologies Co.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.so.adapters.cnf.model.statuscheck.StatusCheckResponse;
import org.onap.so.adapters.cnf.service.CnfAdapterService;
import org.onap.so.adapters.cnf.service.aai.AaiService;
+import org.onap.so.adapters.cnf.service.healthcheck.HealthCheckService;
import org.onap.so.adapters.cnf.service.statuscheck.SimpleStatusCheckService;
import org.onap.so.client.exception.BadResponseException;
import org.slf4j.Logger;
private static final Logger logger = LoggerFactory.getLogger(CnfAdapterRest.class);
private final CloseableHttpClient httpClient = HttpClients.createDefault();
private final SimpleStatusCheckService simpleStatusCheckService;
+ private final HealthCheckService healthCheckService;
private final CnfAdapterService cnfAdapterService;
private final SoCallbackClient callbackClient;
private final AaiService aaiService;
@Autowired
public CnfAdapterRest(SimpleStatusCheckService simpleStatusCheckService,
+ HealthCheckService healthCheckService,
CnfAdapterService cnfAdapterService,
SoCallbackClient callbackClient,
AaiService aaiService,
MulticloudConfiguration multicloudConfiguration) {
this.simpleStatusCheckService = simpleStatusCheckService;
+ this.healthCheckService = healthCheckService;
this.cnfAdapterService = cnfAdapterService;
this.aaiService = aaiService;
this.callbackClient = callbackClient;
DeferredResult<ResponseEntity> response = new DeferredResult<>();
new Thread(() -> {
- logger.info("Processing healthCheck service");
+ logger.info("Processing health check request");
+
HealthCheckResponse healthCheckResponse = null;
try {
- healthCheckResponse = cnfAdapterService.healthCheck(healthCheckRequest);
+ healthCheckResponse = healthCheckService.healthCheck(healthCheckRequest);
} catch (Exception e) {
- HealthCheckResponse errorHealthCheck = new HealthCheckResponse();
- errorHealthCheck.setErrorMessage(e.getMessage());
- callbackClient.sendPostCallback(healthCheckRequest.getCallbackUrl(), errorHealthCheck);
- return;
+ logger.error("END - Health check process failed", e);
+ healthCheckResponse = healthCheckService.healthCheckError(healthCheckRequest, e);
}
callbackClient.sendPostCallback(healthCheckRequest.getCallbackUrl(), healthCheckResponse);
}).start();
DeferredResult<ResponseEntity> response = new DeferredResult<>();
new Thread(() -> {
- logger.info("Processing healthCheck service");
+ logger.info("Processing status check request");
StatusCheckResponse statusCheckResponse = null;
try {
statusCheckResponse = simpleStatusCheckService.statusCheck(statusCheckRequest);
- } catch (BadResponseException e) {
- StatusCheckResponse errorStatusCheck = new StatusCheckResponse();
- errorStatusCheck.setErrorMessage(e.getMessage());
- callbackClient.sendPostCallback(statusCheckRequest.getCallbackUrl(), e);
- return;
+ } catch (Exception e) {
+ logger.error("END - Status check process failed", e);
+ statusCheckResponse = simpleStatusCheckService.statusCheckError(statusCheckRequest, e);
}
callbackClient.sendPostCallback(statusCheckRequest.getCallbackUrl(), statusCheckResponse);
}).start();
* ONAP - SO
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Samsung Technologies Co.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final String INSTANCE_CREATE_PATH = "/v1/instance";
private final RestTemplate restTemplate;
- private final HealthCheckService healthCheckService;
- private final SimpleStatusCheckService simpleStatusCheckService;
private final String uri;
@Autowired
public CnfAdapterService(RestTemplate restTemplate,
- HealthCheckService healthCheckService,
- SimpleStatusCheckService simpleStatusCheckService,
MulticloudConfiguration multicloudConfiguration) {
this.restTemplate = restTemplate;
- this.healthCheckService = healthCheckService;
- this.simpleStatusCheckService = simpleStatusCheckService;
this.uri = multicloudConfiguration.getMulticloudUrl();
}
- public HealthCheckResponse healthCheck(CheckInstanceRequest healthCheckRequest) throws Exception {
- logger.info("CnfAdapterService healthCheck called");
- return healthCheckService.healthCheck(healthCheckRequest);
- }
-
public String createInstance(BpmnInstanceRequest bpmnInstanceRequest)
throws JsonParseException, JsonMappingException, IOException {
try {
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.service.aai;
import com.google.common.hash.Hashing;
* ONAP - SO
* ================================================================================
* Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.so.adapters.cnf.service.aai;
import org.apache.http.client.utils.URIBuilder;
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.service.aai;
import org.onap.so.adapters.cnf.AaiConfiguration;
* ONAP - SO
* ================================================================================
* Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.service.healthcheck;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
return statuses;
}
+ public HealthCheckResponse healthCheckError(CheckInstanceRequest healthCheckRequest, Exception e) {
+ HealthCheckResponse result = new HealthCheckResponse();
+
+ List<HealthCheckInstanceResponse> instanceHealthCheckList = new ArrayList<>();
+ for (InstanceRequest instanceRequest : healthCheckRequest.getInstances()) {
+ HealthCheckInstanceResponse healthCheck = new HealthCheckInstanceResponse(
+ instanceRequest.getInstanceId(), e.getMessage(), "Failed");
+ instanceHealthCheckList.add(healthCheck);
+ }
+
+ result.setInstanceResponse(instanceHealthCheckList);
+ return result;
+ }
+
private List<HealthCheckInstance> startInstanceHealthCheck(CheckInstanceRequest healthCheckRequest) throws Exception {
log.debug("startInstanceHealthCheck - START");
List<HealthCheckInstance> healthCheckInstanceList = new ArrayList<>();
InstanceStatusTuple instanceStatusTuple = future.get();
String instanceId = instanceStatusTuple.getInstanceId();
String status = instanceStatusTuple.getStatus();
- String reason = null;
- return new HealthCheckInstanceResponse(instanceId, reason, status);
+ return new HealthCheckInstanceResponse(instanceId, null, status);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
sleep(10_000L);
}
- return new InstanceStatusTuple(healthCheckInstance.getInstanceId(), "Timeout");
+ //Timeout
+ instanceApi.deleteInstanceHealthCheck(healthCheckInstance.getInstanceId(), healthCheckInstance.getHealthCheckInstance());
+ return new InstanceStatusTuple(healthCheckInstance.getInstanceId(), "Unknown");
}
}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.adapters.cnf.service.statuscheck;
import org.onap.so.adapters.cnf.client.MulticloudClient;
return result;
}
+ public StatusCheckResponse statusCheckError(CheckInstanceRequest instanceIds, Exception e) {
+ StatusCheckResponse result = new StatusCheckResponse();
+
+ List<StatusCheckInstanceResponse> simpleStatuses = new ArrayList<>();
+ for (InstanceRequest instanceRequest : instanceIds.getInstances()) {
+ StatusCheckInstanceResponse statusCheck = new StatusCheckInstanceResponse(
+ instanceRequest.getInstanceId(), e.getMessage(), false);
+ simpleStatuses.add(statusCheck);
+ }
+
+ result.setInstanceResponse(simpleStatuses);
+ return result;
+ }
+
private StatusCheckInstanceResponse getStatusCheck(String instanceId) throws BadResponseException {
log.debug("SIMPLE STATUS CHECK - START");
K8sRbInstanceStatus instanceStatus = instanceApi.getInstanceStatus(instanceId);
* ONAP - SO
* ================================================================================
* Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.so.adapters.cnf.util;
import com.fasterxml.jackson.core.JsonProcessingException;
* ONAP - SO
* ================================================================================
* Copyright (C) 2021 Samsung Electronics Co. Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 Orange.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.so.adapters.cnf.util;
import org.onap.so.adapters.cnf.model.instantiation.AaiRequest;
@Mock
ResponseEntity<InstanceStatusResponse> instanceStatusResponse;
- @Test
- public void healthCheckTest() throws Exception {
- HealthCheckResponse response = new HealthCheckResponse();
- DeferredResult<HealthCheckResponse> deferredResponse = new DeferredResult<>();
- deferredResponse.setResult(response);
- CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
- CheckInstanceRequest healthCheckRequest = Mockito.mock(CheckInstanceRequest.class);
- Mockito.when(cnfAdapterService.healthCheck(healthCheckRequest)).thenReturn(response);
-
- cnfAdapterRest.healthCheck(healthCheckRequest);
-
- Assert.assertNotNull(response);
- }
-
@Test
public void createInstanceTest() throws Exception {
public void setUp() {
MulticloudConfiguration multicloudConfiguration = mock(MulticloudConfiguration.class);
doReturn("http://test.url").when(multicloudConfiguration).getMulticloudUrl();
- cnfAdapterService = spy(new CnfAdapterService(restTemplate, healthCheckService, simpleStatusCheckService, multicloudConfiguration));
+ cnfAdapterService = spy(new CnfAdapterService(restTemplate, multicloudConfiguration));
}