summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2020-09-09 09:28:56 -0400
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2020-09-09 12:31:14 -0400
commit804942a67bfc0baacb2fa53923a77e8f41cc1079 (patch)
tree3a94b5c341fb63846d587983933191099e557211 /bpmn/so-bpmn-tasks
parentbd86a224c44dcc5192d0b5a142c6be0f779a90a8 (diff)
Bpmn to cnf adapter implementation testing bpmn
BPMN changes related to CNF Adapter Change-Id: I9ccff712cc731bcd7469bd2b6dadaae49133e20f Issue-ID: SO-3199 Signed-off-by: Kalkere Ramesh, Sharan <sk720x@att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java26
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java26
4 files changed, 54 insertions, 24 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java
index c21b467a95..a556d3088c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapter.java
@@ -1,19 +1,16 @@
package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks;
-import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowAction;
import org.onap.so.client.adapter.cnf.CnfAdapterClient;
-import org.onap.so.client.adapter.cnf.CnfAdapterClientException;
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.Labels;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class CnfAdapter {
@@ -25,8 +22,19 @@ public class CnfAdapter {
public void callCnfAdapter(DelegateExecution execution) throws Exception {
try {
- final String instanceRequest = (String) execution.getVariable("instanceRequest");
- InstanceRequest request = new ObjectMapper().readValue(instanceRequest, InstanceRequest.class);
+ InstanceRequest request = new InstanceRequest();
+ request.setRbName("test-rbdef");
+ request.setRbVersion("v1");
+ request.setCloudRegion("krd");
+ request.setVfModuleUUID("VF module UUID");
+ request.setProfileName("p1");
+ Map<String, String> overrideValues = new HashMap<>();
+ overrideValues.put("image.tag", "latest");
+ overrideValues.put("dcae_collector_ip", "1.2.3.4");
+ Map<String, String> labels = new HashMap<String, String>();
+ labels.put("custom-label-1", "abcdef");
+ request.setLabels(labels);
+ request.setOverrideValues(overrideValues);
InstanceResponse response = cnfAdapterClient.createVfModule(request);
} catch (Exception ex) {
logger.error("Exception in callCnfAdapter", ex);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
index 93d30512b6..7624bcb811 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
@@ -112,7 +112,7 @@ public class CnfAdapterCreateTasks {
request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID());
request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID());
request.setCloudRegion(cloudRegion.getLcpCloudRegionId());
- request.setReleaseName(vfModule.getVfModuleId());
+ request.setVfModuleUUID(vfModule.getVfModuleId());
request.setProfileName(sdncDirectives.get("k8s-rb-profile-name"));
request.setOverrideValues(sdncDirectives);
return request;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
index f44c15ac54..b74aa9056d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
@@ -34,6 +34,7 @@ import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
@@ -75,11 +76,32 @@ public class CnfAdapterClient {
}
}
+ @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 endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/healthcheck").build().toString();
+ HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
+ ResponseEntity<InstanceResponse> result =
+ restTemplate.exchange(endpoint, HttpMethod.GET, entity, InstanceResponse.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<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
- acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ List<MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
headers.setAccept(acceptableMediaTypes);
+ headers.setContentType(MediaType.APPLICATION_JSON);
/*
* try { String userCredentials = CryptoUtils.decrypt(env.getRequiredProperty("mso.cnf.adapter.auth"),
* env.getRequiredProperty("mso.msoKey")); if (userCredentials != null) { headers.add(HttpHeaders.AUTHORIZATION,
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
index e4058097ab..37d4e41553 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
@@ -11,18 +11,18 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
"override-values"})
public class InstanceRequest {
- @JsonProperty("rb-name")
+ @JsonProperty("modelInvariantId")
private String rbName;
- @JsonProperty("rb-version")
+ @JsonProperty("modelVersionId")
private String rbVersion;
- @JsonProperty("profile-name")
+ @JsonProperty("k8sRBProfileName")
private String profileName;
- @JsonProperty("release-name")
- private String releaseName;
- @JsonProperty("cloud-region")
+ @JsonProperty("vfModuleUUID")
+ private String vfModuleUUID;
+ @JsonProperty("cloudRegionId")
private String cloudRegion;
@JsonProperty("labels")
- private Labels labels;
+ private Map<String, String> labels;
@JsonProperty(value = "override-values")
private Map<String, String> overrideValues;
@@ -67,21 +67,21 @@ public class InstanceRequest {
}
@JsonProperty("labels")
- public Labels getLabels() {
+ public Map<String, String> getLabels() {
return labels;
}
@JsonProperty("labels")
- public void setLabels(Labels labels) {
+ public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
- public String getReleaseName() {
- return releaseName;
+ public String getVfModuleUUID() {
+ return vfModuleUUID;
}
- public void setReleaseName(String releaseName) {
- this.releaseName = releaseName;
+ public void setVfModuleUUID(String vfModuleUUID) {
+ this.vfModuleUUID = vfModuleUUID;
}
public Map<String, String> getOverrideValues() {