summaryrefslogtreecommitdiffstats
path: root/adapters/mso-cnf-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-cnf-adapter')
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java7
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java66
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java62
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java45
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java87
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java84
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java71
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java54
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java39
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java353
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java269
-rw-r--r--adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties2
-rw-r--r--adapters/mso-cnf-adapter/src/main/resources/application.yaml4
-rw-r--r--adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java3
14 files changed, 939 insertions, 207 deletions
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java
index e94c283a98..0ba40e2700 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java
@@ -28,8 +28,10 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@ComponentScan(basePackages = {"org.onap.so.adapters.cnf"})
@@ -42,4 +44,9 @@ public class MSOCnfApplication {
public static void main(String... args) {
SpringApplication.run(MSOCnfApplication.class, args);
}
+
+ @Bean
+ public RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java
new file mode 100644
index 0000000000..bfa5505ccc
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/GroupVersionKind.java
@@ -0,0 +1,66 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"Group", "Version", "Kind"})
+public class GroupVersionKind {
+ @JsonProperty("Group")
+ private String group;
+ @JsonProperty("Version")
+ private String version;
+ @JsonProperty("Kind")
+ private String kind;
+
+ @JsonProperty("Group")
+ public String getGroup() {
+ return group;
+ }
+
+ @JsonProperty("Group")
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+ @JsonProperty("Version")
+ public String getVersion() {
+ return version;
+ }
+
+ @JsonProperty("Version")
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @JsonProperty("Kind")
+ public String getKind() {
+ return kind;
+ }
+
+ @JsonProperty("Kind")
+ public void setKind(String kind) {
+ this.kind = kind;
+ }
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java
new file mode 100644
index 0000000000..58040826dd
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponse.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(value = "true")
+public class InstanceMiniResponse extends Response {
+
+ private String id;
+ private MulticloudInstanceRequest request;
+ private String nameSpace;
+
+ public InstanceMiniResponse(String errorMsg) {
+ super(errorMsg);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public MulticloudInstanceRequest getRequest() {
+ return request;
+ }
+
+ public void setRequest(MulticloudInstanceRequest request) {
+ this.request = request;
+ }
+
+ public String getNameSpace() {
+ return nameSpace;
+ }
+
+ public void setNameSpace(String nameSpace) {
+ this.nameSpace = nameSpace;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java
new file mode 100644
index 0000000000..ad70fbb7d0
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceMiniResponseList.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(value = "true")
+public class InstanceMiniResponseList extends Response {
+
+ public InstanceMiniResponseList(String errorMsg) {
+ super(errorMsg);
+ }
+
+ private List<InstanceMiniResponse> instancList;
+
+ public List<InstanceMiniResponse> getInstancList() {
+ return instancList;
+ }
+
+ public void setInstancList(List<InstanceMiniResponse> instancList) {
+ this.instancList = instancList;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
new file mode 100644
index 0000000000..effaaf5f78
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
@@ -0,0 +1,87 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"id", "request", "namespace", "resources"})
+@JsonIgnoreProperties(value = "true")
+public class InstanceResponse extends Response {
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("request")
+ private MulticloudInstanceRequest request;
+ @JsonProperty("namespace")
+ private String namespace;
+ @JsonProperty("resources")
+ private List<Resource> resources = null;
+
+ public InstanceResponse(String errorMsg) {
+ super(errorMsg);
+ }
+
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("request")
+ public MulticloudInstanceRequest getRequest() {
+ return request;
+ }
+
+ @JsonProperty("request")
+ public void setRequest(MulticloudInstanceRequest request) {
+ this.request = request;
+ }
+
+ @JsonProperty("namespace")
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @JsonProperty("namespace")
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ @JsonProperty("resources")
+ public List<Resource> getResources() {
+ return resources;
+ }
+
+ @JsonProperty("resources")
+ public void setResources(List<Resource> resources) {
+ this.resources = resources;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java
new file mode 100644
index 0000000000..2472684bc0
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceStatusResponse.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import java.util.List;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(value = "true")
+public class InstanceStatusResponse extends Response {
+
+ public InstanceStatusResponse(String errorMsg) {
+ super(errorMsg);
+ }
+
+ private MulticloudInstanceRequest request;
+
+ private boolean ready;
+
+ private String resourceCount;
+
+ private List<PodStatus> podStatuses;
+
+ private List<?> servicesStatuses;
+
+ public MulticloudInstanceRequest getRequest() {
+ return request;
+ }
+
+ public void setRequest(MulticloudInstanceRequest request) {
+ this.request = request;
+ }
+
+ public boolean isReady() {
+ return ready;
+ }
+
+ public void setReady(boolean ready) {
+ this.ready = ready;
+ }
+
+ public String getResourceCount() {
+ return resourceCount;
+ }
+
+ public void setResourceCount(String resourceCount) {
+ this.resourceCount = resourceCount;
+ }
+
+ public List<PodStatus> getPodStatuses() {
+ return podStatuses;
+ }
+
+ public void setPodStatuses(List<PodStatus> podStatuses) {
+ this.podStatuses = podStatuses;
+ }
+
+ public List<?> getServicesStatuses() {
+ return servicesStatuses;
+ }
+
+ public void setServicesStatuses(List<?> servicesStatuses) {
+ this.servicesStatuses = servicesStatuses;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java
new file mode 100644
index 0000000000..ed04601b2c
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/PodStatus.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+public class PodStatus {
+
+ private String name;
+ private String nameSpace;
+ private boolean ready;
+ private String status;
+ private String[] ipAddresses;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNameSpace() {
+ return nameSpace;
+ }
+
+ public void setNameSpace(String nameSpace) {
+ this.nameSpace = nameSpace;
+ }
+
+ public boolean isReady() {
+ return ready;
+ }
+
+ public void setReady(boolean ready) {
+ this.ready = ready;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String[] getIpAddresses() {
+ return ipAddresses;
+ }
+
+ public void setIpAddresses(String[] ipAddresses) {
+ this.ipAddresses = ipAddresses;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java
new file mode 100644
index 0000000000..d18cd76039
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Resource.java
@@ -0,0 +1,54 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"GVK", "Name"})
+public class Resource {
+ @JsonProperty("GVK")
+ private GroupVersionKind gVK;
+ @JsonProperty("Name")
+ private String name;
+
+ @JsonProperty("GVK")
+ public GroupVersionKind getGVK() {
+ return gVK;
+ }
+
+ @JsonProperty("GVK")
+ public void setGVK(GroupVersionKind gVK) {
+ this.gVK = gVK;
+ }
+
+ @JsonProperty("Name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("Name")
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java
new file mode 100644
index 0000000000..423022393c
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/Response.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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;
+
+public class Response {
+
+ private String errorMsg;
+
+ public Response(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
index b6d50da557..825778b89a 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
@@ -1,6 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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.rest;
import java.io.File;
+import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
@@ -20,12 +41,17 @@ import org.onap.so.adapters.cnf.model.ConfigTemplateEntity;
import org.onap.so.adapters.cnf.model.ConfigurationEntity;
import org.onap.so.adapters.cnf.model.ConfigurationRollbackEntity;
import org.onap.so.adapters.cnf.model.ConnectivityInfo;
-import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest;
+import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
+import org.onap.so.adapters.cnf.model.InstanceResponse;
+import org.onap.so.adapters.cnf.model.InstanceStatusResponse;
import org.onap.so.adapters.cnf.model.ProfileEntity;
import org.onap.so.adapters.cnf.model.ResourceBundleEntity;
import org.onap.so.adapters.cnf.model.Tag;
+import org.onap.so.adapters.cnf.service.CnfAdapterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,6 +60,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -43,23 +71,78 @@ public class CnfAdapterRest {
private static final Logger logger = LoggerFactory.getLogger(CnfAdapterRest.class);
private final CloseableHttpClient httpClient = HttpClients.createDefault();
+ @Autowired
+ private CnfAdapterService cnfAdapterService;
+
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/healthcheck"}, method = RequestMethod.GET,
produces = "application/json")
- public String healthCheck() throws Exception {
+ public ResponseEntity<String> healthCheck() throws Exception {
- logger.info("health check called.");
+ logger.info("healthCheck called.");
+ return cnfAdapterService.healthCheck();
+
+ }
+
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.POST,
+ produces = "application/json", consumes = "application/json")
+ public ResponseEntity<InstanceResponse> createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("createInstance called.");
+ return cnfAdapterService.createInstance(bpmnInstanceRequest);
+ }
+
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.GET,
+ produces = "application/json")
+ public ResponseEntity<InstanceResponse> getInstanceByInstanceId(@PathVariable("instID") String instanceId)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("getInstanceByInstanceId called.");
+
+ return cnfAdapterService.getInstanceByInstanceId(instanceId);
+
+ }
+
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}/status"}, method = RequestMethod.GET,
+ produces = "application/json")
+ public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(
+ @PathVariable("instID") String instanceId) throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("getInstanceStatusByInstanceId called.");
+
+ return cnfAdapterService.getInstanceStatusByInstanceId(instanceId);
+
+ }
+
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.GET, produces = "application/json")
+ public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(
+ @RequestParam(value = "rb-name", required = false) String rbName,
+ @RequestParam(value = "rb-version", required = false) String rbVersion,
+ @RequestParam(value = "profile-name", required = false) String profileName)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("getInstanceByRBNameOrRBVersionOrProfileName called.");
+ return cnfAdapterService.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName);
+
+ }
+
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.DELETE,
+ produces = "application/json")
+ public ResponseEntity<String> deleteInstanceByInstanceId(@PathVariable("instID") String instanceID)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("deleteInstanceByInstanceId called.");
+ return cnfAdapterService.deleteInstanceByInstanceId(instanceID);
- // TODO
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/healthcheck");
- try (CloseableHttpResponse response = httpClient.execute(req)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition"}, method = RequestMethod.POST,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition"}, method = RequestMethod.POST,
produces = "application/json")
public String createRB(@RequestBody ResourceBundleEntity rB) throws Exception {
@@ -67,7 +150,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/rb/definition");
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
String requestBody = objectMapper.writeValueAsString(rB);
@@ -82,7 +165,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}"}, method = RequestMethod.GET,
produces = "application/json")
public String getRB(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion)
throws Exception {
@@ -91,7 +174,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion);
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
return EntityUtils.toString(response.getEntity());
@@ -99,8 +182,8 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}"},
- method = RequestMethod.DELETE, produces = "application/json")
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}"}, method = RequestMethod.DELETE,
+ produces = "application/json")
public String deleteRB(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion)
throws Exception {
@@ -108,7 +191,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion);
+ HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -118,7 +201,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}"}, method = RequestMethod.GET,
produces = "application/json")
public String getListOfRB(@PathVariable("rb-name") String rbName) throws Exception {
@@ -126,7 +209,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition/" + rbName);
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -136,7 +219,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition"}, method = RequestMethod.GET,
produces = "application/json")
public String getListOfRBWithoutUsingRBName() throws Exception {
@@ -144,7 +227,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition");
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition");
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -154,7 +237,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/content"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/content"},
method = RequestMethod.POST, produces = "multipart/form-data")
public String uploadArtifactForRB(@RequestParam("file") MultipartFile file, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion) throws Exception {
@@ -172,7 +255,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
HttpPost post =
- new HttpPost("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/content");
+ new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/content");
post.setHeader("Content-Type", "multipart/form-data");
logger.info(String.valueOf(post));
post.setEntity(entity);
@@ -185,7 +268,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/profile"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile"},
method = RequestMethod.POST, produces = "application/json")
public String createProfile(@RequestBody ProfileEntity fE, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion) throws Exception {
@@ -195,7 +278,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
HttpPost post =
- new HttpPost("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
+ new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(fE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -209,7 +292,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"},
method = RequestMethod.GET, produces = "application/json")
public String getProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@PathVariable("pr-name") String prName) throws Exception {
@@ -219,7 +302,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
HttpGet req = new HttpGet(
- "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
+ "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -228,7 +311,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/profile"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile"},
method = RequestMethod.GET, produces = "application/json")
public String getListOfProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion)
throws Exception {
@@ -237,7 +320,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
+ HttpGet req =
+ new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -246,7 +330,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"},
method = RequestMethod.DELETE, produces = "application/json")
public String deleteProfile(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@PathVariable("pr-name") String prName) throws Exception {
@@ -256,7 +340,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
HttpDelete req = new HttpDelete(
- "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
+ "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -266,7 +350,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}/content"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}/content"},
method = RequestMethod.POST, produces = "multipart/form-data")
public String uploadArtifactForProfile(@RequestParam("file") MultipartFile file,
@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@@ -284,7 +368,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion
+ "/profile/" + prName + "/content");
post.setHeader("Content-Type", "multipart/form-data");
@@ -299,144 +383,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance"}, method = RequestMethod.POST,
- produces = "application/json")
- public String createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest) throws Exception {
-
- logger.info("create Instance called.");
-
- MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest();
-
- if (bpmnInstanceRequest.getK8sRBProfileName() != null) {
- multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId());
- multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels());
- multicloudInstanceRequest.setOverrideValues(bpmnInstanceRequest.getOverrideValues());
- multicloudInstanceRequest.setProfileName(bpmnInstanceRequest.getK8sRBProfileName());
- multicloudInstanceRequest.setRbName(bpmnInstanceRequest.getModelInvariantId());
- multicloudInstanceRequest.setRbVersion(bpmnInstanceRequest.getModelVersionId());
- multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID());
- } else {
-
- logger.info("K8sRBProfileName is required");
- return "K8sRBProfileName is required";
- }
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/instance");
- ObjectMapper objectMapper = new ObjectMapper();
-
- String requestBody = objectMapper.writeValueAsString(multicloudInstanceRequest);
- StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
- post.setEntity(requestEntity);
-
- try (CloseableHttpClient httpClient = HttpClients.createDefault();
- CloseableHttpResponse response = httpClient.execute(post)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
- }
-
- // This api is not enabled in multicloud project ,but this is required in
- // future.
- @ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance/{vnfInstanceId}"}, method = RequestMethod.PUT,
- produces = "application/json")
- public String updateInstance(@RequestBody MulticloudInstanceRequest iE,
- @PathVariable("vnfInstanceId") String instanceId) throws Exception {
-
- logger.info("create Instance called.");
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpPut post = new HttpPut("http://172.17.0.2:31770/v1/instance/" + instanceId);
- ObjectMapper objectMapper = new ObjectMapper();
-
- String requestBody = objectMapper.writeValueAsString(iE);
- StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
- post.setEntity(requestEntity);
-
- try (CloseableHttpClient httpClient = HttpClients.createDefault();
- CloseableHttpResponse response = httpClient.execute(post)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
- }
-
- @ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance/{instID}"}, method = RequestMethod.GET,
- produces = "application/json")
- public String getInstance(@PathVariable("instID") String instanceId) throws Exception {
-
- logger.info("get Instance called.");
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/instance/" + instanceId);
-
- try (CloseableHttpResponse response = httpClient.execute(req)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
- }
-
- @ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance/{instID}/status"}, method = RequestMethod.GET,
- produces = "application/json")
- public String getInstanceStatus(@PathVariable("instID") String instanceId) throws Exception {
-
- logger.info("getInstanceStatus called.");
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/instance/" + instanceId + "/status");
-
- try (CloseableHttpResponse response = httpClient.execute(req)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
- }
-
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance"}, method = RequestMethod.GET,
- produces = "application/json")
- public String getInstanceBasedOnRBNameOrRBVersionOrProfileName(
- @RequestParam(value = "rb-name", required = false) String rbName,
- @RequestParam(value = "rb-version", required = false) String rbVersion,
- @RequestParam(value = "profile-name", required = false) String profileName) throws Exception {
-
- logger.info("getInstanceBasedOnRBNameOrRBVersionOrProfileName called.");
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/instance?rb-name=" + rbName + "&rb-version=" + rbVersion
- + "&profile-name=" + profileName);
-
- try (CloseableHttpResponse response = httpClient.execute(req)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
- }
-
- @ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/instance/{instID}"}, method = RequestMethod.DELETE,
- produces = "application/json")
- public String deleteInstance(@PathVariable("instID") String instanceID) throws Exception {
-
- logger.info("delete Instance called.");
-
- // TODO
- // Below URL should be changed as appropriate multicloud URL.
- HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/instance/" + instanceID);
-
- try (CloseableHttpResponse response = httpClient.execute(req)) {
- logger.info("response:" + response.getEntity());
- return EntityUtils.toString(response.getEntity());
- }
-
- }
-
- @ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config"},
method = RequestMethod.POST, produces = "application/json")
public String createConfiguration(@RequestBody ConfigurationEntity cE, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName)
@@ -446,8 +393,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost(
- "http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/" + prName + "/config");
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion
+ + "/profile/" + prName + "/config");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(cE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -461,8 +408,8 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {
- "/api/cnf-adapter/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
+ @RequestMapping(
+ value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
method = RequestMethod.GET, produces = "application/json")
public String getConfiguration(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@PathVariable("profile-name") String prName, @PathVariable("cfg-name") String cfgName) throws Exception {
@@ -471,7 +418,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
+ prName + "/config/" + cfgName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
@@ -481,8 +428,8 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {
- "/api/cnf-adapter/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
+ @RequestMapping(
+ value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
method = RequestMethod.DELETE, produces = "application/json")
public String deleteConfiguration(@PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName,
@@ -492,7 +439,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion
+ HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion
+ "/profile/" + prName + "/config/" + cfgName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
@@ -503,8 +450,8 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {
- "/api/cnf-adapter/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
+ @RequestMapping(
+ value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
method = RequestMethod.PUT, produces = "application/json")
public String updateConfiguration(@RequestBody ConfigurationEntity cE, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion, @PathVariable("profile-name") String prName,
@@ -514,7 +461,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPut post = new HttpPut("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
+ HttpPut post = new HttpPut("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
+ prName + "/config/" + cfgName);
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(cE);
@@ -529,7 +476,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/tagit"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/tagit"},
method = RequestMethod.POST, produces = "application/json")
public String tagConfigurationValue(@RequestBody Tag tag, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion, @PathVariable("pr-name") String prName) throws Exception {
@@ -537,8 +484,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
- + prName + "/config/tagit");
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion
+ + "/profile/" + prName + "/config/tagit");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(tag);
@@ -553,7 +500,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/connectivity-info"}, method = RequestMethod.POST,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info"}, method = RequestMethod.POST,
produces = "application/json")
public String createConnectivityInfo(@RequestBody ConnectivityInfo cIE) throws Exception {
@@ -561,7 +508,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/connectivity-info");
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/connectivity-info");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(cIE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -575,7 +522,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info/{connname}"}, method = RequestMethod.GET,
produces = "application/json")
public String getConnectivityInfo(@PathVariable("connname") String connName) throws Exception {
@@ -583,7 +530,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/connectivity-info/" + connName);
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/connectivity-info/" + connName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -592,7 +539,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.DELETE,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/connectivity-info/{connname}"}, method = RequestMethod.DELETE,
produces = "application/json")
public String deleteConnectivityInfo(@PathVariable("connname") String connName) throws Exception {
@@ -600,7 +547,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/connectivity-info/" + connName);
+ HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/connectivity-info/" + connName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -610,7 +557,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template"},
method = RequestMethod.POST, produces = "application/json")
public String createConfigTemplate(@RequestBody ConfigTemplateEntity tE, @PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion) throws Exception {
@@ -620,7 +567,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
HttpPost post = new HttpPost(
- "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template");
+ "http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(tE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -634,7 +581,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"},
method = RequestMethod.GET, produces = "application/json")
public String getConfigTemplate(@PathVariable("rb-name") String rbName,
@PathVariable("rb-version") String rbVersion, @PathVariable("tname") String tName) throws Exception {
@@ -643,8 +590,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet(
- "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template/" + tName);
+ HttpGet req = new HttpGet("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion
+ + "/config-template/" + tName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -653,7 +600,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"},
method = RequestMethod.DELETE, produces = "application/json")
public String deleteTemplate(@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@PathVariable("tname") String tName) throws Exception {
@@ -662,8 +609,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpDelete req = new HttpDelete(
- "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template/" + tName);
+ HttpDelete req = new HttpDelete("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion
+ + "/config-template/" + tName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -674,7 +621,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(
- value = {"/api/cnf-adapter/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}/content"},
+ value = {"/api/cnf-adapter/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}/content"},
method = RequestMethod.POST, produces = "multipart/form-data")
public String uploadTarFileForTemplate(@RequestParam("file") MultipartFile file,
@PathVariable("rb-name") String rbName, @PathVariable("rb-version") String rbVersion,
@@ -692,7 +639,7 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/rb/definition/" + rbName + "/" + rbVersion
+ "/config-template/" + tName + "/content");
post.setHeader("Content-Type", "multipart/form-data");
@@ -707,7 +654,7 @@ public class CnfAdapterRest {
}
@ResponseBody
- @RequestMapping(value = {"/api/cnf-adapter/v1/v1/definition/{rbName}/{rbVersion}/profile/{prName}/config/rollback"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/definition/{rbName}/{rbVersion}/profile/{prName}/config/rollback"},
method = RequestMethod.DELETE, produces = "application/json")
public String rollbackConfiguration(@RequestBody ConfigurationRollbackEntity rE,
@PathVariable("rbName") String rbName, @PathVariable("rbVersion") String rbVersion,
@@ -716,8 +663,8 @@ public class CnfAdapterRest {
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
- + prName + "/config/rollback");
+ HttpPost post = new HttpPost("http://multicloud-k8s:9015/v1/definition/" + rbName + "/" + rbVersion
+ + "/profile/" + prName + "/config/rollback");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(rE);
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
new file mode 100644
index 0000000000..06c09e3431
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
@@ -0,0 +1,269 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies 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.service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.EntityNotFoundException;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.http.HttpStatus;
+import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
+import org.onap.so.adapters.cnf.model.InstanceMiniResponse;
+import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
+import org.onap.so.adapters.cnf.model.InstanceResponse;
+import org.onap.so.adapters.cnf.model.InstanceStatusResponse;
+import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+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.stereotype.Service;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+@Service
+public class CnfAdapterService {
+ private static final Logger logger = LoggerFactory.getLogger(CnfAdapterService.class);
+ @Autowired
+ private RestTemplate restTemplate;
+ private static final String INSTANCE_CREATE_PATH = "/v1/instance";
+ private static final String HEALTH_CHECK = "/v1/healthcheck";
+
+ public ResponseEntity<String> healthCheck() {
+
+ logger.info("CnfAdapterService createInstance called");
+ ResponseEntity<String> result = null;
+ try {
+
+ logger.info("CnfAdapterService createInstance called");
+
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String endpoint = UriBuilder.fromUri(uri).path(HEALTH_CHECK).build().toString();
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ result = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class);
+ return result;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ return ResponseEntity.status(e.getStatusCode()).body(responseString);
+ }
+ }
+
+ public ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest)
+ throws JsonParseException, JsonMappingException, IOException {
+ try {
+ logger.info("CnfAdapterService createInstance called");
+ MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest();
+ ResponseEntity<InstanceResponse> instanceResponse = null;
+ if (bpmnInstanceRequest.getK8sRBProfileName() != null) {
+ multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId());
+ multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels());
+ multicloudInstanceRequest.setOverrideValues(bpmnInstanceRequest.getOverrideValues());
+ multicloudInstanceRequest.setProfileName(bpmnInstanceRequest.getK8sRBProfileName());
+ multicloudInstanceRequest.setRbName(bpmnInstanceRequest.getModelInvariantId());
+ multicloudInstanceRequest.setRbVersion(bpmnInstanceRequest.getModelVersionId());
+ multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID());
+ } else {
+ logger.error("k8sProfileName should not be null");
+ return instanceResponse;
+ }
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
+ HttpEntity<?> entity = getHttpEntity(multicloudInstanceRequest);
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class);
+ return instanceResponse;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ InstanceResponse result = new InstanceResponse(responseString.trim());
+ return ResponseEntity.status(e.getStatusCode()).body(result);
+ }
+ }
+
+ public ResponseEntity<InstanceResponse> getInstanceByInstanceId(String instanceId)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("CnfAdapterService createInstance called");
+ ResponseEntity<InstanceResponse> instanceResponse = null;
+ try {
+
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String path = "/v1/instance/" + instanceId;
+ String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceResponse.class);
+ return instanceResponse;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ InstanceResponse result = new InstanceResponse(responseString.trim());
+ return ResponseEntity.status(e.getStatusCode()).body(result);
+ }
+ }
+
+ public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(String instanceId)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("CnfAdapterService createInstance called");
+ ResponseEntity<InstanceStatusResponse> instanceResponse = null;
+ try {
+
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String path = "/v1/instance/" + instanceId + "/status";
+ String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ instanceResponse =
+ restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceStatusResponse.class);
+ return instanceResponse;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ InstanceStatusResponse result = new InstanceStatusResponse(responseString.trim());
+ return ResponseEntity.status(e.getStatusCode()).body(result);
+ }
+
+ }
+
+ public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(String rbName,
+ String rbVersion, String profileName) throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("CnfAdapterService createInstance called");
+ ResponseEntity<InstanceMiniResponseList> instanceMiniResponseList = null;
+ try {
+
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String path =
+ "/v1/instance" + "?rb-name=" + rbName + "&rb-version=" + rbVersion + "&profile-name=" + profileName;
+ String endPoint = uri + path;
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ instanceMiniResponseList =
+ restTemplate.exchange(endPoint, HttpMethod.GET, requestEntity, InstanceMiniResponseList.class);
+ return instanceMiniResponseList;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ InstanceMiniResponseList result = new InstanceMiniResponseList(responseString.trim());
+ return ResponseEntity.status(e.getStatusCode()).body(result);
+ }
+ }
+
+ public ResponseEntity<String> deleteInstanceByInstanceId(String instanceId)
+ throws JsonParseException, JsonMappingException, IOException {
+
+ logger.info("CnfAdapterService createInstance called");
+ ResponseEntity<String> result = null;
+ try {
+
+ // String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
+ // This needs to be added as well
+ // for configuration
+ String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
+ String path = "/v1/instance/" + instanceId;
+ String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ result = restTemplate.exchange(endpoint, HttpMethod.DELETE, requestEntity, String.class);
+ return result;
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling Multicloud, e");
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ } catch (HttpStatusCodeException e) {
+ logger.error("Error in Multicloud, e");
+ String responseString = e.getResponseBodyAsString();
+ return ResponseEntity.status(e.getStatusCode()).body(responseString);
+ }
+ }
+
+ protected HttpHeaders getHttpHeaders() {
+ HttpHeaders headers = new HttpHeaders();
+ 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,
+ * "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } } catch
+ * (GeneralSecurityException e) { logger.error("Security exception", e); }
+ */
+ return headers;
+ }
+
+ protected HttpEntity<?> getHttpEntity(MulticloudInstanceRequest request) {
+ HttpHeaders headers = getHttpHeaders();
+ return new HttpEntity<>(request, headers);
+ }
+}
diff --git a/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
index f93ec63f37..bccd43aea7 100644
--- a/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
+++ b/adapters/mso-cnf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
@@ -1 +1 @@
-org.onap.so.adapters.nssmf.extclients.aai.AaiClientPropertiesImpl \ No newline at end of file
+org.onap.so.adapters.cnf.extclients.aai.AaiClientPropertiesImpl \ No newline at end of file
diff --git a/adapters/mso-cnf-adapter/src/main/resources/application.yaml b/adapters/mso-cnf-adapter/src/main/resources/application.yaml
index 30b1b626a5..5a9adbfd04 100644
--- a/adapters/mso-cnf-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-cnf-adapter/src/main/resources/application.yaml
@@ -38,14 +38,14 @@
# naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
# enable-lazy-load-no-trans: true
server:
- port: 9013
+ port: 9012
tomcat:
max-threads: 50
#mso:
# key: 07a7159d3bf51a0e53be7a8f89699be7
# site-name: localSite
-# logPath: ./logs/nssmf
+# logPath: ./logs/cnf
# msb-ip: msb-iag.{{ include "common.namespace" . }}
# msb-port: 80
# adapters:
diff --git a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java
index 38a10918bc..ee7a771034 100644
--- a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java
+++ b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.java
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+
package org.onap.so.adapters.cnf;
@@ -60,3 +60,4 @@ public class CnfAdapterRestTest {
}
}
+*/