import org.apache.http.HttpStatus;
import org.onap.so.client.adapter.cnf.entities.InstanceRequest;
import org.onap.so.client.adapter.cnf.entities.InstanceResponse;
+import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceResponse;
+import org.onap.so.client.adapter.cnf.entities.UpgradeInstanceRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired
private Environment env;
- private static final String INSTANCE_CREATE_PATH = "/api/multicloud-k8s/v1/v1/instance";
+ private static final String INSTANCE_CREATE_PATH = "/api/cnf-adapter/v1/instance";
@Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
public InstanceResponse createVfModule(InstanceRequest request) throws CnfAdapterClientException {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "https://localhost:32780"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
HttpEntity<?> entity = getHttpEntity(request);
ResponseEntity<InstanceResponse> result =
}
}
+
+ @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
+ public void deleteVfModule(String heatStackId) throws CnfAdapterClientException {
+ try {
+ // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
+ // for configuration
+ String uri = "http://so-cnf-adapter:8090";
+ String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH + "/" + heatStackId).build().toString();
+ HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
+ restTemplate.exchange(endpoint, HttpMethod.DELETE, entity, String.class);
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling CNF Adapter, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ }
+ }
+
@Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
public InstanceResponse healthcheck() throws CnfAdapterClientException {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "https://localhost:32780"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/healthcheck").build().toString();
HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
ResponseEntity<InstanceResponse> result =
}
}
+ @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000))
+ public UpgradeInstanceResponse upgradeVfModule(UpgradeInstanceRequest request, String heatStackId)
+ throws CnfAdapterClientException {
+ try {
+ String uri = "http://so-cnf-adapter:8090";
+ String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH + "/" + heatStackId + "/upgrade")
+ .build().toString();
+ HttpEntity<?> entity = getHttpEntity(request);
+ ResponseEntity<UpgradeInstanceResponse> result =
+ restTemplate.exchange(endpoint, HttpMethod.POST, entity, UpgradeInstanceResponse.class);
+ return result.getBody();
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling CNF Adapter, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ }
+ }
+
protected HttpHeaders getHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
List<MediaType> acceptableMediaTypes = new ArrayList<>();
return new HttpEntity<>(request, headers);
}
+ protected HttpEntity<?> getHttpEntity(UpgradeInstanceRequest request) {
+ HttpHeaders headers = getHttpHeaders();
+ return new HttpEntity<>(request, headers);
+ }
}